Announcement Announcement Module
Collapse
No announcement yet.
How to acheive this Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to acheive this

    In code below i need to put a message (String whichResultType:batchID format) in webResponseChannel to enable posting it on a HTTP URl as outlined in the config. The String is made of two attributes available in message that was published on JMS.
    Please let me know how to achieve this, thanks for your help.

    This is part of much larger configuration so i will like to keep it direct as much as possible, so if possible would like to eliminate the chain below.

    Code:
           <int-jms:outbound-channel-adapter 	
    	channel="requestChannel"
    	connection-factory="connectionFactory"
    	id="jmsOut" 	
    	destination="streamingTopic" extract-payload="true">
    	<int:poller fixed-rate="1"/>
    	</int-jms:outbound-channel-adapter>	
    	
    	 
    	<chain input-channel="webResponseChannel" output-channel="webResponseChannel2">
    	<transformer ref="webResponseTransformerBean" method="transform"/>
    	</chain>
    	<channel id="webResponseChannel2">		
    		<queue capacity="10" />
    		<interceptors>
    			<wire-tap channel="logger" />
    		</interceptors>
    	</channel>
    
            <int-http:outbound-gateway request-channel="webResponseChannel2" 
    					           url="http://www.abc.com/{whichResultType}?batchid={batchID}"
    					           http-method="GET"
    					           expected-response-type="java.lang.String"					        
    					           reply-channel="abc">
    		<int-http:uri-variable name="whichResultType" expression="payload.getWhichResultType()"/>
    	    <int-http:uri-variable name="batchID" expression="payload.getBatchID()"/>
    	</int-http:outbound-gateway>

  • #2
    You need to explain more about the payload types and/or show the code for webResponseTransformerBean.

    Comment


    • #3
      Thanks Gary.

      I have upstream configuration that polls another HTTP URL and through a series of steps it finally creates a XML message that wraps all business messages retrieved in the HTTP poll and a 'router' sends it to 'requestChannel' (or rejected channel) for the jms adapter to send it to a JMS topic.

      So far i have done a 'workaround' that the router also send a message to 'webResponseChannel' and webResponseTransformerBean code creates a custom payload object type that has two fields whichResultType and batchID populated from the message that is received in input queue.

      but this makes these two steps independent of each other, i would like to trigger the webResponseChannel based on jms adapter success, to make sure the http:outbound-gateway only send the http call if message was successfully published to JMS.

      The problem i need to address is JMS channel could be down so jms publishing will fail so http call should fail too.

      let me know if any other detail will help to answer it more appropriately.

      Comment


      • #4
        This is a different question; you said you wanted to eliminate the chain (containing the transformer).

        To do what you now want, simply make requestChannel a <publish-subscribe-channel/>; set the order attribute on the jms adapter to "1" and subscribe the chain directly to request channel set the order to "2" on the chain.

        That way the chain will be invoked on the same thread immediately after the adapter and, by default, won't be invoked if the JMS operation fails.

        Comment


        • #5
          Thanks, will try that.

          Comment


          • #6
            Ok, this is great now. I was also able to eliminate the chain (containing the transformer), that i wanted to by moving the values i need to header and populating them at an earlier stage.
            Here is the config now, thanks for your help.
            Code:
                 <int:publish-subscribe-channel id="reqChannel" />
            	<int-jms:outbound-channel-adapter 	
            	channel="reqChannel" order="1"
            	connection-factory="connectionFactory"
            	id="jmsOut" 	
            	destination="streamingTopic" extract-payload="true">
            	</int-jms:outbound-channel-adapter>	
            		
            	<int-http:outbound-gateway request-channel="reqChannel" order="2"
            					           url="http://www.abc.com/{whichResultType}?batchid={batchID}"
            					           http-method="GET"
            					           expected-response-type="java.lang.String"					        
            					           reply-channel="abc">
            	    <int-http:uri-variable name="whichResultType" expression="headers.whichResultType"/>
            	    <int-http:uri-variable name="batchID" expression="headers.batchId"/>
            	</int-http:outbound-gateway>
            	
                  <stream:stdout-channel-adapter id="abc" charset="UTF-8" append-newline="true"/>

            Comment


            • #7
              In the config above if the JMS publishing fails, the message is lost and it moves to next polling cycle. Just wondering if there a way i can tell it to keep retrying with some delay or may be max number of retry attempts before quitting.
              The JMS could come back soon and it can continue as soon as it can publish.
              In current config it goes on and on for next poll even though all of them are going to fail at JMS step.


              Thanks for your help.

              Comment


              • #8
                http://static.springsource.org/sprin...l#retry-advice


                and sample...


                https://github.com/SpringSource/spri...retry-and-more

                Comment


                • #9
                  Thanks again

                  Comment

                  Working...
                  X