cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r941984 - in /cxf/trunk: rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ rt/transports/jms/src/main/resources/schemas/wsdl/ systests/transports/src/test/java/org/apache/cxf/systest/jms/ testutils/src/main/resources/wsdl/
Date Fri, 07 May 2010 02:42:18 GMT
Author: ningjiang
Date: Fri May  7 02:42:17 2010
New Revision: 941984

URL: http://svn.apache.org/viewvc?rev=941984&view=rev
Log:
CXF-2793 Provide capability for JMS client to specify separate ReplyTo queue and listener
queue by applying the patch with thanks to Seumas

Modified:
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
    cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
    cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java
    cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=941984&r1=941983&r2=941984&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
Fri May  7 02:42:17 2010
@@ -213,8 +213,14 @@ public class JMSConduit extends Abstract
 
             public javax.jms.Message createMessage(Session session) throws JMSException {
                 String messageType = jmsConfig.getMessageType();
+                Destination destination = rtd;
+                String replyToAddress = jmsConfig.getReplyToDestination();
+                if (replyToAddress != null) {
+                    destination = JMSFactory.resolveOrCreateDestination(jmsTemplate, replyToAddress,
+                                                                        jmsConfig.isPubSubDomain());
+                }
                 jmsMessage = JMSUtils.buildJMSMessageFromCXFMessage(jmsConfig, outMessage,
request,
-                                                                    messageType, session,
rtd,
+                                                                    messageType, session,
destination,
                                                                     cid);
                 if (!exchange.isSynchronous() && !exchange.isOneWay()) {
                     correlationMap.put(cid, exchange);

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java?rev=941984&r1=941983&r2=941984&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
Fri May  7 02:42:17 2010
@@ -80,6 +80,7 @@ public class JMSConfiguration implements
 
     private String targetDestination;
     private String replyDestination;
+    private String replyToDestination;
     private String messageType = JMSConstants.TEXT_MESSAGE_TYPE;
     private boolean pubSubDomain;
     private Boolean useConduitIdSelector;
@@ -277,6 +278,14 @@ public class JMSConfiguration implements
         this.replyDestination = replyDestination;
     }
 
+    public String getReplyToDestination() {
+        return replyToDestination;
+    }
+
+    public void setReplyToDestination(String replyToDestination) {
+        this.replyToDestination = replyToDestination;
+    }
+    
     public String getMessageType() {
         return messageType;
     }

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java?rev=941984&r1=941983&r2=941984&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
Fri May  7 02:42:17 2010
@@ -268,10 +268,16 @@ public class JMSOldConfigHolder {
                 jmsConfig.setDestinationResolver(jndiDestinationResolver);
                 jmsConfig.setTargetDestination(endpoint.getDestinationName());
                 jmsConfig.setReplyDestination(endpoint.getReplyToName());
+                if (address != null) {
+                    jmsConfig.setReplyToDestination(address.getJndiReplyToDestinationName());
+                }
             } else {
                 // Use the default dynamic destination resolver
                 jmsConfig.setTargetDestination(endpoint.getDestinationName());
                 jmsConfig.setReplyDestination(endpoint.getReplyToName());
+                if (address != null) {
+                    jmsConfig.setReplyToDestination(address.getJmsReplyToDestinationName());
+                }
             }
         }
         

Modified: cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd?rev=941984&r1=941983&r2=941984&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd (original)
+++ cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd Fri May  7 02:42:17
2010
@@ -232,6 +232,28 @@
     					</xs:documentation>
     				</xs:annotation>
     			</xs:attribute>
+    			
+    			<xs:attribute name="jndiReplyToDestinationName"
+    				type="xs:string">
+    				<xs:annotation>
+    					<xs:documentation>
+    						Used when the ReplyTo address on the message needs to be different
+    						than the listening address of the consumer. This mostly applies to 
+    						MQSeries users who are interacting with remote queues.
+    					</xs:documentation>
+    				</xs:annotation>
+    			</xs:attribute>
+
+    			<xs:attribute name="jmsReplyToDestinationName"
+    				type="xs:string">
+    				<xs:annotation>
+    					<xs:documentation>
+    						Used when the ReplyTo address on the message needs to be different
+    						than the listening address of the consumer. This mostly applies to 
+    						MQSeries users who are interacting with remote queues.
+    					</xs:documentation>
+    				</xs:annotation>
+    			</xs:attribute>    			
 
     			<xs:attribute name="connectionUserName"
     				type="xs:string">

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=941984&r1=941983&r2=941984&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Fri May  7 02:42:17 2010
@@ -30,6 +30,10 @@ import java.util.concurrent.Future;
 
 import javax.activation.DataHandler;
 import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
 import javax.xml.namespace.QName;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Binding;
@@ -70,18 +74,29 @@ import org.apache.cxf.testutil.common.Ab
 import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
 import org.apache.cxf.transport.jms.AddressType;
 import org.apache.cxf.transport.jms.JMSConduit;
+import org.apache.cxf.transport.jms.JMSConfiguration;
 import org.apache.cxf.transport.jms.JMSConstants;
+import org.apache.cxf.transport.jms.JMSFactory;
 import org.apache.cxf.transport.jms.JMSMessageHeadersType;
 import org.apache.cxf.transport.jms.JMSNamingPropertyType;
+import org.apache.cxf.transport.jms.JMSOldConfigHolder;
 import org.apache.cxf.transport.jms.JMSPropertyType;
+import org.apache.cxf.transport.jms.JNDIConfiguration;
 import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
+import org.apache.cxf.transport.jms.uri.JMSEndpoint;
 import org.apache.hello_world_doc_lit.Greeter;
 import org.apache.hello_world_doc_lit.PingMeFault;
 import org.apache.hello_world_doc_lit.SOAPService2;
+import org.apache.hello_world_doc_lit.SOAPService7;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.core.MessageCreator;
+import org.springframework.jms.core.SessionCallback;
+import org.springframework.jms.support.destination.DestinationResolver;
+import org.springframework.jndi.JndiTemplate;
 
 public class JMSClientServerTest extends AbstractBusClientServerTestBase {
     
@@ -1192,4 +1207,70 @@ public class JMSClientServerTest extends
         }
 
     }
+    
+    @Test
+    public void testReplyToConfig() throws Exception {
+        JMSEndpoint endpoint = new JMSEndpoint();
+        endpoint.setJndiInitialContextFactory("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+        endpoint.setJndiURL("tcp://localhost:61500");
+        endpoint.setJndiConnectionFactoryName("ConnectionFactory");
+
+        final JMSConfiguration jmsConfig = new JMSConfiguration();        
+        JndiTemplate jt = new JndiTemplate();
+        
+        jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(endpoint));
+        
+        JNDIConfiguration jndiConfig = new JNDIConfiguration();
+        jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
+        jmsConfig.setJndiTemplate(jt);
+        jmsConfig.setJndiConfig(jndiConfig);
+        
+        jmsConfig.setTargetDestination("dynamicQueues/SoapService7.replyto.queue");
+        jmsConfig.setReplyDestination("dynamicQueues/SoapService7.reply.queue");
+        
+        final JmsTemplate jmsTemplate = JMSFactory.createJmsTemplate(jmsConfig, null);
+
+        Thread t = new Thread() {
+            public void run() {
+                Destination destination = (Destination)jmsTemplate.execute(new SessionCallback()
{
+                    public Object doInJms(Session session) throws JMSException {
+                        DestinationResolver resolv = jmsTemplate.getDestinationResolver();
+                        return resolv.resolveDestinationName(session, jmsConfig.getTargetDestination(),
+                                                             false);
+                    }
+                });
+                
+                final Message message = jmsTemplate.receive(destination);
+                MessageCreator messageCreator = new MessageCreator() {
+                    public Message createMessage(Session session) {
+                        return message;
+                    }
+                };
+                    
+                destination = (Destination)jmsTemplate.execute(new SessionCallback() {
+                    public Object doInJms(Session session) throws JMSException {
+                        DestinationResolver resolv = jmsTemplate.getDestinationResolver();
+                        return resolv.resolveDestinationName(session,
+                                                             jmsConfig.getReplyDestination(),
+                                                             false);
+                    }
+                });
+                jmsTemplate.send(destination, messageCreator);
+            }
+        };
+
+        t.start();
+        
+        QName serviceName = getServiceName(new QName("http://apache.org/hello_world_doc_lit",
+                                                     "SOAPService7"));
+        QName portName = getPortName(new QName("http://apache.org/hello_world_doc_lit", "SoapPort7"));
+        URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
+        assertNotNull(wsdl);
+
+        SOAPService7 service = new SOAPService7(wsdl, serviceName);        
+        Greeter greeter = service.getPort(portName, Greeter.class);
+        String name = "FooBar";
+        String reply = greeter.greetMe(name);
+        assertEquals(reply, "Hello " + name);
+    }    
 }

Modified: cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java?rev=941984&r1=941983&r2=941984&view=diff
==============================================================================
--- cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java (original)
+++ cxf/trunk/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java Fri
May  7 02:42:17 2010
@@ -38,6 +38,7 @@ public class Server extends AbstractBusT
         Object impl4 = new GreeterByteMessageImpl();
         Object impl5 =  new SoapService6SoapPort6Impl();
         Object impl6 = new JmsDestPubSubImpl();
+        Object impl7 =  new SoapService7SoapPort7Impl();
         Object i1 = new GreeterImplTwoWayJMSAppCorrelationIDNoPrefix();
         Object i2 = new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixEng();
         Object i3 = new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixSales();
@@ -56,6 +57,7 @@ public class Server extends AbstractBusT
         Endpoint.publish("http://testaddr.not.required.byte/", impl4);
         Endpoint.publish("http://testaddr.not.required.jms/", impl5);
         Endpoint.publish("http://ignore", impl6);
+        Endpoint.publish("", impl7);
         Endpoint.publish("", i1);
         Endpoint.publish("", i2);
         Endpoint.publish("", i3);

Modified: cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl?rev=941984&r1=941983&r2=941984&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl (original)
+++ cxf/trunk/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl Fri May  7 02:42:17
2010
@@ -239,6 +239,20 @@ targetNamespace="http://apache.org/hello
         </wsdl:port>
     </wsdl:service>
 
+    <wsdl:service name="SOAPService7">
+        <wsdl:port name="SoapPort7" binding="tns:Greeter_SOAPBinding">
+               <jms:address
+                   jndiConnectionFactoryName="ConnectionFactory"
+                   jmsDestinationName="dynamicQueues/messageidascorrelationid.SOAPService7Q.text"
+                   jmsReplyDestinationName="dynamicQueues/SoapService7.reply.queue"
+                   jmsReplyToDestinationName="dynamicQueues/SoapService7.replyto.queue">
+
+                   <jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
+                   <jms:JMSNamingProperty name="java.naming.provider.url" value="tcp://localhost:61500"/>
+               </jms:address>
+        </wsdl:port>
+    </wsdl:service>
+
     <!-- XML Binding based Services-->
     <wsdl:service name="XMLService1">
         <wsdl:port name="XMLPort1" binding="tns:Greeter_XMLBinding">



Mime
View raw message