summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68>2009-02-25 17:37:43 +0000
committerbeckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68>2009-02-25 17:37:43 +0000
commitb3716a99191639dc40db89b8c32a6909b799bc6e (patch)
tree29b81972508a3e1a3752295ef9b0df56a3d21efc
parentfd31a1072875989d90434af4881d5020114e08d4 (diff)
TUSCANY-2857 Correct handling of JMSDeliveryMode and JMSPriority
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@747867 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite4
-rw-r--r--branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java12
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java41
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java15
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java6
5 files changed, 28 insertions, 50 deletions
diff --git a/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite b/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
index 6fb6330a21..8902f1d32a 100644
--- a/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
+++ b/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
@@ -25,13 +25,13 @@
<implementation.java class="org.apache.tuscany.sca.binding.jms.MsgClientImpl" />
<reference name="myService" requires="priority.medium">
<binding.jms uri="jms:ServiceQueue">
- <!-- headers JMSType="myType"
+ <headers JMSType="myType"
JMSCorrelationID="xyz"
JMSDeliveryMode="PERSISTENT"
JMSTimeToLive="4321"
JMSPriority="7">
<property name="headP1">myHeadP1</property>
- </headers-->
+ </headers>
</binding.jms>
</reference>
</component>
diff --git a/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java b/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
index c0c90cea95..5e208a3081 100644
--- a/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
+++ b/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import javax.jms.DeliveryMode;
+import javax.jms.Message;
import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.junit.After;
@@ -49,19 +50,16 @@ public class PolicyHeadersTestCase {
// wait for up to 5 seconds but should wake up as soon as done
synchronized(MsgServiceImpl.lock) {
if (MsgServiceImpl.msg == null) {
- MsgServiceImpl.lock.wait(5000);
+ MsgServiceImpl.lock.wait(5000); // For debugging set higher.
}
}
assertNotNull(MsgServiceImpl.msg);
-
- assertEquals(4, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ
- /*
assertEquals("myType", MsgServiceImpl.msg.getJMSType());
assertEquals("xyz", MsgServiceImpl.msg.getJMSCorrelationID());
assertEquals(DeliveryMode.PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
+ assertEquals(7, MsgServiceImpl.msg.getJMSPriority());
assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
- */
}
@Test
@@ -81,8 +79,8 @@ public class PolicyHeadersTestCase {
assertEquals("op2Type", MsgServiceImpl.msg.getJMSType());
assertEquals("op2CID", MsgServiceImpl.msg.getJMSCorrelationID());
- // assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode()); // Doesn't seem to work with ActiveMQ
- // assertEquals(3, MsgServiceImpl.msg.getJMSPriority()); // Doesn't seem to work with ActiveMQ
+ assertEquals(DeliveryMode.NON_PERSISTENT, MsgServiceImpl.msg.getJMSDeliveryMode());
+ assertEquals(3, MsgServiceImpl.msg.getJMSPriority());
assertEquals("myHeadP1", MsgServiceImpl.msg.getStringProperty("headP1"));
assertEquals("foo", MsgServiceImpl.msg.getStringProperty("op2P2"));
assertEquals("nativeOp2", MsgServiceImpl.msg.getStringProperty("scaOperationName"));
diff --git a/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
index 58100cfb8d..3c7b4467ba 100644
--- a/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
@@ -81,53 +81,14 @@ public class JMSHeaderReferencePolicyInterceptor implements Interceptor {
}
public Message invoke(Message msg) {
- try {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
javax.jms.Message jmsMsg = msg.getBody();
- String operationName = msg.getOperation().getName();
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getDeliveryModePersistent() != null)) {
- if (jmsHeaderPolicy.getDeliveryModePersistent()) {
- jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
- } else {
- jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
- }
-
- }
-
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getJmsCorrelationId() != null)) {
- jmsMsg.setJMSCorrelationID(jmsHeaderPolicy.getJmsCorrelationId());
- }
-
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getJmsPriority() != null)) {
- jmsMsg.setJMSPriority(jmsHeaderPolicy.getJmsPriority());
- }
-
- if ((jmsHeaderPolicy != null) &&
- (jmsHeaderPolicy.getJmsType() != null)) {
- jmsMsg.setJMSType(jmsHeaderPolicy.getJmsType());
- }
-
- if (jmsHeaderPolicy != null){
- for (String propName : jmsHeaderPolicy.getProperties().keySet()) {
- jmsMsg.setObjectProperty(propName, jmsHeaderPolicy.getProperties().get(propName));
- }
- }
-
- if (jmsHeaderPolicy != null &&
- jmsHeaderPolicy.getTimeToLive() != null) {
- context.setTimeToLive(jmsHeaderPolicy.getTimeToLive());
- }
+ // JMS header attrs set on MessageProducer via interceptors.
return getNext().invoke(msg);
- } catch (JMSException e) {
- throw new JMSBindingException(e);
- }
}
public Invoker getNext() {
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
index 20ee4c8942..c3e6031b85 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
@@ -86,10 +86,23 @@ public class TransportReferenceInterceptor implements Interceptor {
MessageProducer producer = session.createProducer(context.getRequestDestination());
+ // Set JMS header attributes in producer, not message.
+ String opName = msg.getOperation().getName();
if (jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()) != null) {
producer.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()));
}
-
+ Integer priority = jmsBinding.getOperationJMSPriority( opName );
+ if (priority != null) {
+ producer.setPriority(priority.intValue());
+ }
+ Boolean deliveryModePersistent = jmsBinding.getOperationJMSDeliveryMode(opName);
+ if (deliveryModePersistent != null) {
+ if (deliveryModePersistent.booleanValue())
+ producer.setDeliveryMode(javax.jms.DeliveryMode.PERSISTENT);
+ else
+ producer.setDeliveryMode(javax.jms.DeliveryMode.NON_PERSISTENT);
+ }
+
try {
producer.send((javax.jms.Message)msg.getBody());
} finally {
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
index 7687b368b0..eebac3a8b7 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
@@ -153,6 +153,12 @@ public class TransportServiceInterceptor implements Interceptor {
}
MessageProducer producer = session.createProducer(replyDest);
+
+ // Set jms header attributes in producer, not message.
+ int deliveryMode = requestJMSMsg.getJMSDeliveryMode();
+ producer.setDeliveryMode(deliveryMode);
+ int deliveryPriority = requestJMSMsg.getJMSPriority();
+ producer.setPriority(deliveryPriority);
producer.send((javax.jms.Message)msg.getBody());