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
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="com.simon.external.jms.spring"/>
<beans:bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<beans:property name="environment">
<beans:props>
<beans:prop key="java.naming.factory.initial">
${java.naming.factory.initial}
</beans:prop>
<beans:prop key="java.naming.provider.url">
${java.naming.provider.url}
</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<beans:bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<beans:property name="jndiTemplate">
<beans:ref bean="jndiTemplate" />
</beans:property>
<beans:property name="jndiName">
<beans:value>${simon.jms.connectionfactory.queue.name}</beans:value>
</beans:property>
</beans:bean>
<beans:bean id="jobRequestQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<beans:property name="jndiTemplate">
<beans:ref bean="jndiTemplate" />
</beans:property>
<beans:property name="jndiName">
<beans:value>${simon.jms.queue.request}</beans:value>
</beans:property>
</beans:bean>
<beans:bean id="jobResponseQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<beans:property name="jndiTemplate">
<beans:ref bean="jndiTemplate" />
</beans:property>
<beans:property name="jndiName">
<beans:value>${simon.jms.queue.response}</beans:value>
</beans:property>
</beans:bean>
<beans:bean id="simonResponseConverter" class="com.simon.external.jms.spring.ResponseConverterImpl"/>
<beans:bean id="simpleMessageConverter" class="org.springframework.jms.support.converter.SimpleMessageConverter"/>
<beans:bean id="avoidingResponseConverter" class="com.simon.external.jms.spring.AvoidingResponseConverter">
<beans:property name="responseConverter" ref="simonResponseConverter"/>
</beans:bean>
<beans:bean id="simonMessageConverter1" class="com.simon.external.jms.spring.SimonMessageConverter1">
<beans:property name="converter" ref="avoidingResponseConverter"/>
<beans:property name="simpleConverter" ref="simpleMessageConverter"/>
</beans:bean>
<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"/>
</beans:beans>
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