Announcement Announcement Module
No announcement yet.
single queue and multiple client Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • single queue and multiple client

    we have two jms clients subscribing to the same jms queue. Can the clients select and dequeue the messages based on the message.
    something like
    client 1 will dequeue only when messages are of type 1
    (type1 being generated in response to a request 1 from client1)
    client 2 will dequeue only when messages are of type 2.
    (type2 being generated in response to a request 2 from client2).

    can this be achieved with the spring integration modules.

    In fact what i want to do is implement a simple queue browsing mechanism with the spring integration modules.
    Is there an inbuilt support for queue browsing ?

    Thanks in advance for any help..
    Last edited by rainman; May 8th, 2008, 07:37 AM. Reason: explaining the issue

  • #2
    If the messages in the queue are of same class then using message slectors will be helpful. To achieve that you need to use JMs message properties.


    • #3
      thanks for the reply.
      unfortunately i do not have any property inside the JmsMessage properties to distinguish the messages. I have no control on the message producer since they are a third party application . But i have information in the payload to distinguish the message responses.

      I tried using a message selector with accept returning false for all messages (just to try the functionality). But the messages are dequeued even after they return false.

      So what i am currently doing on the client side is keeping the session transacted and throwing an exception in the message converter if i encounter a message meant for the other client. This would re deliver the messages to the same client till its dequeued by the other. But the same approach is filling up my logs with exception traces since each request is followed by almost 10 responses from the producer. Can we achieve this without an exception throw?

      I tried using channel interceptors to decline a send to the adpter associated channel by forcing the preSend to return false on encountering a message meant for another client. But the session still gets committed and the message dequeued.

      Hereforth is the full version of the spring config i use
      <?xml version="1.0" encoding="UTF-8"?>
      <beans:beans xmlns=""
      	<context:component-scan base-package="com.simon.external.jms.spring"/>
      	<beans:bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
      		<beans:property name="environment">
      				<beans:prop key="java.naming.factory.initial">
      				<beans:prop key="java.naming.provider.url">
      	<beans:bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
      		<beans:property name="jndiTemplate">
      			<beans:ref bean="jndiTemplate" />
      		<beans:property name="jndiName">
      	<beans:bean id="jobRequestQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
      		<beans:property name="jndiTemplate">
      			<beans:ref bean="jndiTemplate" />
      		<beans:property name="jndiName">
      	<beans:bean id="jobResponseQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
      		<beans:property name="jndiTemplate">
      			<beans:ref bean="jndiTemplate" />
      		<beans:property name="jndiName">
      	<beans:bean id="simonResponseConverter" class="com.simon.external.jms.spring.ResponseConverterImpl"/>
      	<beans:bean id="simpleMessageConverter" class=""/>
      	<beans:bean id="avoidingResponseConverter" class="com.simon.external.jms.spring.AvoidingResponseConverter">
      		<beans:property name="responseConverter" ref="simonResponseConverter"/>
      	<beans:bean id="simonMessageConverter1" class="com.simon.external.jms.spring.SimonMessageConverter1">
      		<beans:property name="converter" ref="avoidingResponseConverter"/>
      		<beans:property name="simpleConverter" ref="simpleMessageConverter"/>
      	<jms-target id="request" connection-factory="connectionFactory" destination="jobRequestQueue" channel="externalJobRequestChannel"/>
      	<jms-source id="response" acknowledge="transacted" message-converter="simonMessageConverter1" connection-factory="connectionFactory" destination="jobResponseQueue" channel="externalJobResponseChannel"/>
      	<channel id="externalJobRequestChannel"/>
      	<channel id="externalJobResponseChannel"/>
      	<channel id="internalJobRequestChannel"/>
      	<channel id="internalJobResponseChannel"/>
      	<endpoint input-channel="internalJobRequestChannel"  handler-ref="simonRequestMessageHandler" handler-method="processMessage" default-output-channel="externalJobRequestChannel"/>
      	<endpoint input-channel="externalJobResponseChannel"  handler-ref="simonResponseMessageHandler" handler-method="processMessage" default-output-channel="internalJobResponseChannel"/>

      is there anyway to do a rollback or ( not to commit) other than triggered by an exception. so far the exception throw is the only way it has worked.Maybe i am missing something