Announcement Announcement Module
Collapse
No announcement yet.
JMS inbound and outbound Transformer in another JVM Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMS inbound and outbound Transformer in another JVM

    Hi,

    Here is what I am trying to achieve

    (JVM 1) jms:outbound-gateway --> (JVM 2) jms:inbound-gateway --> (JVM 3) jms:message-driven-channel-adapter / jms:inbound-channel-adapter + transformer --> jms:outbound-gateway (JVM 1)

    From the above setup, I have no issue transforming the message JVM1 --> JVM2 (thus I have left it out of the diagram). The issue I face is when I want to transform the response message but it always fail to receive the JMS response in JVM1

    Below are my configuration
    JVM 1
    Code:
    <gateway id="clientSearchGateway" service-interface="com.xxx.IClientSearch"
    		default-request-channel="request.channel" default-reply-channel="reply.channel">
    		
    		<method name="searchClient"></method>
    	</gateway>
    	
    	<jms:outbound-gateway request-channel="request.channel" request-destination="request.queue" reply-destination="reply.queue"/>
    JVM2
    Code:
    <jms:inbound-gateway id="jmsMessageIn" request-channel="request.channel" request-destination="request.queue"/>
    	<chain input-channel="request.channel">
    		<header-enricher>
    			<header name="header" value="transform2"/>
    		</header-enricher>
    		<service-activator  ref="clientSearchService" method="searchClient" />
    	</chain>
     	<beans:bean id="clientSearchService" class="com.xxx.ClientSearchService" />
    JVM3
    Code:
            <!-- Part 1 : Begin configuration to transform from JVM 1 to JVM 2. This part works! -->
    	<jms:message-driven-channel-adapter id="jmsin" destination="request.queue" channel="request.incoming" />
    	<chain input-channel="request.incoming" output-channel="request.outgoing">
    		<transformer method="transform1" ref="messageTransformer" />
    	</chain>
    	<jms:outbound-channel-adapter channel="request.outgoing" destination="request.queue"/>
            <!-- Part 1 : End -->	
    
            <!-- Part 2 : Idea is to transform reposne from JVM 2 to JVM 1. Doesn't work-->
    	<jms:message-driven-channel-adapter id="jmsin2" destination="reply.queue" channel="reply.incoming"/>
    	<header-value-router input-channel="reply.incoming" header-name="header">
    	    <mapping value="transform2" channel="reply.routed" />
    	</header-value-router>
    	
    	<chain input-channel="reply.routed" output-channel="reply.outgoing">
    		<header-filter header-names="header"/>
    		<transformer method="transform2" ref="messageTransformer" />
    	</chain>
    	<jms:outbound-channel-adapter destination="reply.queue" channel="reply.outgoing"/>
    	
            <!-- Part 2 : ends-->
    	<beans:bean id="messageTransformer" class="com.xxx.MessageTransformer" />

  • #2
    This is very confusing; it looks like you have JVM2 and JVM3 listening on the same queue.

    JVM3 (part 1) receives messages from request.queue and also sends messages to request.queue.

    In part 2 you have the adapter listening on the reply.queue which looks like the reply.queue from JVM1.

    I assume the actual queues (<bean id="request.queue" ...>) for these destinations have different queue names, but we can't see what's going on without that configuration too.

    Also, if you run with DEBUG logging for org.springframework.integration, you should be able to trace messages through the systems and figure out what's going on.

    Comment


    • #3
      I'm sorry but i got lost a number of times going through it. I'll try to tell what I figured out let me know if it makes sense.

      1. On JVM 1 your application puts a message on request.channel and the gateway sends it to the request.queue destination, now here you are waiting for a response on reply.queue.
      2. On JVM 2 your application receives message from destination request.channel (JVM 1 is supposed to publish on this) and then reaches subsequently to the SA. I'm not sure what happens in the SA.
      3. On JVM 3 you have a message driven channel adpter which receives from request.queue (again? JVM 2 receives from the same queue too right? )
      4. On JVM 3 then you have a transformer which transforms and eventually using an outbound channel adapter publishes to request.queue (on which both processes on JVM 2 and JVM 3 are listening)
      5. On JVM 3 again you have a a message driven channel adapter next which listens to reply.queue on which the JVM 1's gateway is expecting reply too.

      What are we exactly trying to achieve?

      Comment


      • #4
        Hi All,

        Thanks for the speedy response. First of all, I must say that the whole JMS + Spring Integration is really new for me.
        The basic idea is to separate the transformers into one single layer (JVM3). What I am trying to achieve is to create a gateway(JVM1) without any dependency on the java input and output object from JVM2. For this, I am separating the mappings into JVM 3.

        Outbound Gateway-[request.queue]->Transformer1-[request.queue]->Inbound Gateway-[reply.queue]->Transformer2-[reply.queue]->Outbound Gateway



        Right now, through this configuration, I am able to get JVM1 -> JVM3 (Part One transformation) -> JVM2 all through the same request.queue. From JVM2 it will send the response to reply.queue. JVM3 (Part two transfomer) is able to receive from reply.queu and execute but the problem is I need to pass this transformation from JVM3 to JVM1.

        1) Do I need to define different queues between the different JVMs?

        Comment


        • #5
          OK, I finally able to make it to work.

          1) Can someone advise if the following setup is recommended or is there a more elegant way to achieve it?
          2) I am using ActiveMQ for testing but potentially we may go for WebSphere MQ. Will there be a change in the header to manage since my configuration are explicitly setting the jms_correlationId field. (Note: using the <correlation-id> does not work)

          Anyway below are my new configs that work

          Changes :

          1) Defined two new queues cris.request.queue and cris.reply.queue that is to be used exclusively between the transformers (JVM3) and JVM2.
          2) Manually managed the correlation id.
          3) Introduced an jms:outbound-channel-adapter in JVM 2 to redirect to cris.reply.queue.



          No change in JVM 1 configs.

          JVM 3 :
          Code:
          <jms:message-driven-channel-adapter id="jmsin" destination="request.queue" channel="request.incoming" />
          	<chain input-channel="request.incoming" output-channel="request.outgoing">
          		<transformer method="transform1" ref="messageTransformer" />
          		<header-enricher>
          			<header name="cris.header" value="cris.search.client"/>
          			<header name="preserve_id" expression="Headers.jms_messageId" />
          			<header name="jms_correlationId" expression="Headers.jms_messageId"/>
          			<correlation-id expression="Headers.jms_messageId"/>
          		</header-enricher>
          	</chain>
          	<jms:outbound-channel-adapter channel="request.outgoing" destination="cris.request.queue"/>
          	
          	<jms:message-driven-channel-adapter id="jmsin2" destination="cris.reply.queue" channel="reply.incoming"/>
          	<header-value-router input-channel="reply.incoming" header-name="header">
          	    <mapping value="transform2" channel="reply.routed" />
          	</header-value-router>
          	
          	<chain input-channel="reply.routed" output-channel="reply.outgoing">
          		<header-filter header-names="header"/>
          		<transformer method="transform2" ref="messageTransformer" />
          		<header-enricher >
          			<header name="jms_correlationId" expression="Headers.preserve_id"/>
          			<correlation-id expression="Headers.preserve_id"/>
          		</header-enricher>
          	</chain>
          	<jms:outbound-channel-adapter destination="reply.queue" channel="reply.outgoing"/>
          	
          
          	<beans:bean id="messageTransformer" class="com.xxx.MessageTransformer" />
          JVM 2

          Code:
          	<jms:inbound-gateway id="jmsMessageIn" request-channel="request.channel" request-destination="cris.request.queue"/>
                  <header-value-router input-channel="request.channel" header-name="cris.header">
          	    <mapping value="cris.search.client" channel="cris.search.client" />
          	</header-value-router>
          	
          	<chain input-channel="cris.search.client" output-channel="cris.output.channel">
          		<header-filter header-names="header"/>
          		<header-enricher>
          			<header name="header" value="transform2"/>
          		</header-enricher>
          		<service-activator  ref="clientSearchService" method="searchClient" />
          	</chain>
           	<beans:bean id="clientSearchService" class="com.xxx.ClientSearchService" /> 
           	<jms:outbound-channel-adapter channel="cris.output.channel" destination="cris.reply.queue"/>

          Comment

          Working...
          X