http - Using Spring EL to decide which outbound gateway to use -


my application can use 1 of 2 web services, lets call them ws , ws b. both contain same interface.

i want perform logic on http headers , request channel. ws b should used on request channels. decide channel used have created java class takes request channel string parameter.

<http:outbound-gateway request-channel="xxxxx"         url-expression="'${el exp}'" http-method="get"         extract-request-payload="true" expected-response-type="java.lang.string"         charset="utf-8" reply-timeout="3000" reply-channel="xxxxx">     </http:outbound-gateway> 

i read url-expression evaluated when context initialised.

source : http://forum.springsource.org/showthread.php?113446-usage-of-expressions-in-http-namespace-element-url

<int-http:outbound-gateway  request-channel="requestchannel"         url="dummy"         http-method="get" extract-request-payload="true" expected-response-type="java.lang.string"         charset="utf-8" reply-timeout="3000" reply-channel="sysloggerrequestchannel">            <int-http:uri-variable name="teststring" expression="test"/>           <int-http:uri-variable name="url" expression="evalclass.getdestinationforchannel(teststring)"/>     </int-http:outbound-gateway> 

the problem approach expressions in int-http:uri-variable not seem evaluation.

all makes me believe taking wrong approach. appreciated.

if have 2 separate web service end points , way determine 1 use per message spring integration router better suited directing messages around. has added advantage can further processing on messages specific endpoint prior sending.

there many many ways configure router, including writing entirely custom one, suggest reading through whole section see work best you.

a quick example based on message type:

<int:payload-type-router input-channel="requests">    <int:mapping type="my.business.webservicearequest" channel="wsa" />    <int:mapping type="my.business.webservicebrequest" channel="wsb" /> </int:payload-type-router>  <int-http:outbound-gateway request-channel="wsa" url="http://wsa.com/whatever"       ... /> <int-http:outbound-gateway request-channel="wsb" url="http://wsb.com/foo"       ... /> 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -