diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-04 10:44:08 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-04 10:44:08 +0000 |
commit | d4faa4ee042bbfd5cfa9e34f05d28b55a406e5ab (patch) | |
tree | 220a385f50c6fceec659d42c802a0d24431b1300 /java | |
parent | 61b972955ffdf4cc2d790aeee925990ab7d070af (diff) |
Tidy up header processing
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@682318 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r-- | java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java index 5f30ff980a..cb1ced3423 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingInvoker.java @@ -20,6 +20,7 @@ package org.apache.tuscany.sca.binding.jms.provider; import java.lang.reflect.InvocationTargetException; +import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; @@ -41,7 +42,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.osoa.sca.ServiceRuntimeException; /** - * Interceptor for the JMS binding. + * Invoker for the JMS binding. * * @version $Rev$ $Date$ */ @@ -259,12 +260,16 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { setHeaders(tuscanyMsg, requestMsg); - requestMessageProcessor.setOperationName(operationName, requestMsg); requestMsg.setJMSReplyTo(replyToDest); Destination requestDest = getRequestDestination(tuscanyMsg, session); MessageProducer producer = session.createProducer(requestDest); + + if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) { + producer.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(operationName)); + } + try { producer.send(requestMsg); } finally { @@ -293,8 +298,23 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { protected void setHeaders(org.apache.tuscany.sca.invocation.Message tuscanyMsg, Message jmsMsg) throws JMSException { - jmsMsg.setJMSDeliveryMode(jmsBinding.getDeliveryMode()); - jmsMsg.setJMSPriority(jmsBinding.getPriority()); + requestMessageProcessor.setOperationName(jmsBinding.getNativeOperationName(operationName), jmsMsg); + + if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) { + if (jmsBinding.getOperationJMSDeliveryMode(operationName)) { + jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); + } else { + jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); + } + } + + if (jmsBinding.getOperationJMSPriority(operationName) != null) { + jmsMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName)); + } + + if (jmsBinding.getOperationJMSType(operationName) != null) { + jmsMsg.setJMSType(jmsBinding.getOperationJMSType(operationName)); + } ReferenceParameters parameters = tuscanyMsg.getFrom().getReferenceParameters(); @@ -329,10 +349,18 @@ public class JMSBindingInvoker implements Invoker, DataExchangeSemantics { protected Message receiveReply(Session session, Destination replyToDest, String requestMsgId) throws JMSException, NamingException { String msgSelector = "JMSCorrelationID = '" + requestMsgId + "'"; MessageConsumer consumer = session.createConsumer(replyToDest, msgSelector); + + long receiveWait; + if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) { + receiveWait = jmsBinding.getOperationJMSTimeToLive(operationName) * 2; + } else { + receiveWait = JMSBindingConstants.DEFAULT_TIME_TO_LIVE; + } + Message replyMsg; try { jmsResourceFactory.startConnection(); - replyMsg = consumer.receive(jmsBinding.getTimeToLive()); + replyMsg = consumer.receive(receiveWait); } finally { consumer.close(); } |