java - JMS Message Selector doesn't work in Multi-Server Environment -


i've implemented spring jms hornetq. works if 1 app-server hornetq. if 2 app servers accessing hornetq. doesn't work. inorder identify different server i've introduced clientid, still doesn't work. here flow.

  1. prepare message send clientid(unique serverid sending message) correlation id , send horentq quename 'q1' producercallback , wait response.

    request.setstringproperty("clientid", clientid); request.setjmscorrelationid(correlationid); 
  2. in consumder side i've defaultmessagelistenercontainer listening queue q1. once message received process , set correlaionid , clientid in response object , send q 'q2'

    final string clientid = request.getstringproperty("clientid"); final string correlationid = request.getjmscorrelationid();   response.setjmscorrelationid(correlationid); response.setstringproperty("clientid", clientid); 
  3. in sender side i've defaultmessagelistenercontainer listening q2. message selector select message based on clientid.

    <bean id="jmscontatiner"     class="org.springframework.jms.listener.defaultmessagelistenercontainer">     <property name="messageselector" value="clientid='server1'" />     <property name="concurrency" value="1" />     <property name="messagelistener" ref="responselistener" />     <property name="destinationname" value="q2" />     <property name="connectionfactory" ref="connectionfactory" /> </bean> 

the code works fine when 1 server envolved. second server's message never recieved listener in server, listens q2(as see in jconsole of hornetq). here happens.
server1 sends message q1 , consumer receives message processes , puts on q2 , server1 receives message q1 selecting message on clientid server1. when server2 sends message q1 , consumer receives message processes , puts on q2. server2 listener not able select message based on clientid server2. when restart server , start of test server2, notw server2 works server1 doesn't pick message.

any appreciated.

fixed issue added cache level cache_connection , client id. started working perfectly.

<bean id="jmscontatiner"     class="org.springframework.jms.listener.defaultmessagelistenercontainer">     <property name="messageselector" value="clientid='server1'" />     <property name="concurrency" value="1" />     <property name="clientid" value="server1" />     <property name="cachelevel" value="1" />     <property name="messagelistener" ref="responselistener" />     <property name="destinationname" value="q2" />     <property name="connectionfactory" ref="connectionfactory" /> </bean> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -