tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From becke...@apache.org
Subject svn commit: r747867 - in /tuscany/branches/sca-java-1.x: itest/jms/src/main/resources/policyHeaders/ itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/ ...
Date Wed, 25 Feb 2009 17:37:43 GMT
Author: beckerdo
Date: Wed Feb 25 17:37:43 2009
New Revision: 747867

URL: http://svn.apache.org/viewvc?rev=747867&view=rev
Log:
TUSCANY-2857 Correct handling of JMSDeliveryMode and JMSPriority

Modified:
    tuscany/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
    tuscany/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
    tuscany/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
    tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
    tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java

Modified: tuscany/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite?rev=747867&r1=747866&r2=747867&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
(original)
+++ tuscany/branches/sca-java-1.x/itest/jms/src/main/resources/policyHeaders/policyHeaders.composite
Wed Feb 25 17:37:43 2009
@@ -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>

Modified: tuscany/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java?rev=747867&r1=747866&r2=747867&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
(original)
+++ tuscany/branches/sca-java-1.x/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java
Wed Feb 25 17:37:43 2009
@@ -22,6 +22,7 @@
 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 @@
         // 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 @@
 
         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"));

Modified: tuscany/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java?rev=747867&r1=747866&r2=747867&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-jms-policy/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
Wed Feb 25 17:37:43 2009
@@ -81,53 +81,14 @@
     }
 
     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() {

Modified: tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java?rev=747867&r1=747866&r2=747867&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
Wed Feb 25 17:37:43 2009
@@ -86,10 +86,23 @@
             
             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 {

Modified: tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java?rev=747867&r1=747866&r2=747867&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
Wed Feb 25 17:37:43 2009
@@ -153,6 +153,12 @@
             }                
                        
             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());
     



Mime
View raw message