From d5a65eb652f6359e30b7e7a6f0db9ad07fdcd497 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 20 Oct 2010 19:42:00 +0000 Subject: Fix JMS refernces to honour the correlation attribute of the JMS binding git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1025695 13f79535-47bb-0310-9956-ffa450edef68 --- .../jms/transport/TransportReferenceInterceptor.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'sca-java-2.x/trunk/modules/binding-jms-runtime') diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java index 6681870612..cafcd12cf2 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java @@ -26,6 +26,7 @@ import javax.jms.Session; import javax.naming.NamingException; import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.JMSBindingException; import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; @@ -110,10 +111,20 @@ public class TransportReferenceInterceptor implements Interceptor { javax.jms.Message requestMessage = (javax.jms.Message)msg.getBody(); - String msgSelector = "JMSCorrelationID = '" + - requestMessage.getJMSMessageID() + - "'"; - MessageConsumer consumer = session.createConsumer(context.getReplyToDestination(), msgSelector); + String msgSelector = null; + String correlationScheme = jmsBinding.getCorrelationScheme(); + if (correlationScheme == null || JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) { + msgSelector = "JMSCorrelationID = '" + requestMessage.getJMSMessageID() + "'"; + } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) { + msgSelector = "JMSCorrelationID = '" + requestMessage.getJMSCorrelationID() + "'"; + } + + MessageConsumer consumer; + if (msgSelector != null) { + consumer = session.createConsumer(context.getReplyToDestination(), msgSelector); + } else { + consumer = session.createConsumer(context.getReplyToDestination()); + } javax.jms.Message replyMsg; try { -- cgit v1.2.3