You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ni...@apache.org on 2010/05/02 09:02:21 UTC
svn commit: r940168 - in /cxf/branches/2.1.x-fixes:
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/resour...
Author: ningjiang
Date: Sun May 2 07:02:21 2010
New Revision: 940168
URL: http://svn.apache.org/viewvc?rev=940168&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
Added:
cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/SoapService8SoapPort8Impl.java (with props)
Modified:
cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java
cxf/branches/2.1.x-fixes/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=940168&r1=940167&r2=940168&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java Sun May 2 07:02:21 2010
@@ -213,7 +213,7 @@ public class JMSConduit extends Abstract
replyToName,
jmsConfig.isPubSubDomain());
}
- }
+ }
final Destination replyToDestination = replyTo;
final String cid = correlationId;
@@ -223,8 +223,19 @@ public class JMSConduit extends Abstract
public javax.jms.Message createMessage(Session session) throws JMSException {
String messageType = jmsConfig.getMessageType();
+
+ Destination destination = replyToDestination;
+ String replyToAddress = jmsConfig.getReplyToDestination();
+ if (replyToAddress != null) {
+ destination =
+ JMSFactory.resolveOrCreateDestination(jmsTemplate,
+ replyToAddress,
+ jmsConfig.isPubSubDomain());
+ }
+
jmsMessage = JMSUtils.buildJMSMessageFromCXFMessage(outMessage, request,
- messageType, session, replyToDestination,
+ messageType, session,
+ destination,
cid);
LOG.log(Level.FINE, "client sending request: ", jmsMessage);
return jmsMessage;
Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java?rev=940168&r1=940167&r2=940168&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java Sun May 2 07:02:21 2010
@@ -78,6 +78,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;
@@ -263,6 +264,14 @@ public class JMSConfiguration implements
public void setReplyDestination(String replyDestination) {
this.replyDestination = replyDestination;
}
+
+ public String getReplyToDestination() {
+ return replyToDestination;
+ }
+
+ public void setReplyToDestination(String replyToDestination) {
+ this.replyToDestination = replyToDestination;
+ }
public String getMessageType() {
return messageType;
Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java?rev=940168&r1=940167&r2=940168&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java Sun May 2 07:02:21 2010
@@ -133,10 +133,12 @@ public class JMSOldConfigHolder {
jmsConfig.setDestinationResolver(jndiDestinationResolver);
jmsConfig.setTargetDestination(address.getJndiDestinationName());
jmsConfig.setReplyDestination(address.getJndiReplyDestinationName());
+ jmsConfig.setReplyToDestination(address.getJndiReplyToDestinationName());
} else {
// Use the default dynamic destination resolver
jmsConfig.setTargetDestination(address.getJmsDestinationName());
jmsConfig.setReplyDestination(address.getJmsReplyDestinationName());
+ jmsConfig.setReplyToDestination(address.getJmsReplyToDestinationName());
}
}
return jmsConfig;
Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd?rev=940168&r1=940167&r2=940168&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/resources/schemas/wsdl/jms.xsd Sun May 2 07:02:21 2010
@@ -204,6 +204,26 @@
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="jndiReplyToDestinationName"
+ type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Used when specifying a replyTo address separate from
+ address used to listen for reply.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="jmsReplyToDestinationName"
+ type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Used when specifying a replyTo address separate from
+ address used to listen for reply.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
<xs:attribute name="connectionUserName"
type="xs:string">
<xs:annotation>
Modified: cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=940168&r1=940167&r2=940168&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java Sun May 2 07:02:21 2010
@@ -24,11 +24,16 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import javax.activation.DataHandler;
+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;
@@ -64,19 +69,29 @@ import org.apache.cxf.service.model.Endp
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
import org.apache.cxf.transport.jms.AddressType;
+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.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.apache.hello_world_doc_lit.SOAPService8;
import org.junit.BeforeClass;
//import org.junit.Ignore;
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 {
@@ -938,7 +953,6 @@ public class JMSClientServerTest extends
String request = "Message: " + idx + " from Client: " + client;
String expected = "Hello " + request;
String response = port.greetMe(request);
- //System.out.println("RESPONSE: " + response);
assertEquals("Response didn't match expected request", expected, response);
}
} catch (Throwable e) {
@@ -1025,4 +1039,77 @@ public class JMSClientServerTest extends
System.gc();
}
+ @Test
+ public void testReplyToConfig() throws Exception {
+ JMSNamingPropertyType p1 = new JMSNamingPropertyType();
+ p1.setName("java.naming.factory.initial");
+ p1.setValue("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+ JMSNamingPropertyType p2 = new JMSNamingPropertyType();
+ p2.setName("java.naming.provider.url");
+ p2.setValue("tcp://localhost:61500");
+ final AddressType address = new AddressType();
+ address.setJndiConnectionFactoryName("ConnectionFactory");
+ List<JMSNamingPropertyType> props = address.getJMSNamingProperty();
+ props.add(p1);
+ props.add(p2);
+
+ final JMSConfiguration jmsConfig = new JMSConfiguration();
+
+ JndiTemplate jt = new JndiTemplate();
+ jt.setEnvironment(JMSOldConfigHolder.getInitialContextEnv(address));
+
+ JNDIConfiguration jndiConfig = new JNDIConfiguration();
+ jndiConfig.setJndiConnectionFactoryName(address.getJndiConnectionFactoryName());
+ jmsConfig.setJndiTemplate(jt);
+ jmsConfig.setJndiConfig(jndiConfig);
+
+ jmsConfig.setTargetDestination("dynamicQueues/SoapService8.replyto.queue");
+ jmsConfig.setReplyDestination("dynamicQueues/SoapService8.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",
+ "SOAPService8"));
+ QName portName = getPortName(new QName("http://apache.org/hello_world_doc_lit", "SoapPort8"));
+ URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
+ assertNotNull(wsdl);
+
+ SOAPService8 service = new SOAPService8(wsdl, serviceName);
+ Greeter greeter = service.getPort(portName, Greeter.class);
+ String name = "FooBar";
+ String reply = greeter.greetMe(name);
+ assertEquals(reply, "Hello " + name);
+ }
+
}
Modified: cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java?rev=940168&r1=940167&r2=940168&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java (original)
+++ cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/Server.java Sun May 2 07:02:21 2010
@@ -37,6 +37,7 @@ public class Server extends AbstractBusT
Object impl5 = new SoapService6SoapPort6Impl();
Object impl6 = new JmsDestPubSubImpl();
Object impl7 = new SoapService7SoapPort7Impl();
+ Object impl8 = new SoapService8SoapPort8Impl();
Object i1 = new GreeterImplTwoWayJMSAppCorrelationIDNoPrefix();
Object i2 = new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixEng();
Object i3 = new GreeterImplTwoWayJMSAppCorrelationIDStaticPrefixSales();
@@ -57,6 +58,7 @@ public class Server extends AbstractBusT
Endpoint.publish("http://testaddr.not.required.jms/", impl5);
Endpoint.publish("http://ignore", impl6);
Endpoint.publish("", impl7);
+ Endpoint.publish("", impl8);
Endpoint.publish("", i1);
Endpoint.publish("", i2);
Endpoint.publish("", i3);
Added: cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/SoapService8SoapPort8Impl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/SoapService8SoapPort8Impl.java?rev=940168&view=auto
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/SoapService8SoapPort8Impl.java (added)
+++ cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/SoapService8SoapPort8Impl.java Sun May 2 07:02:21 2010
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.jms;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "SOAPService8",
+ portName = "SoapPort8",
+ endpointInterface = "org.apache.hello_world_doc_lit.Greeter",
+ targetNamespace = "http://apache.org/hello_world_doc_lit",
+ wsdlLocation = "testutils/hello_world_doc_lit.wsdl")
+public class SoapService8SoapPort8Impl extends GreeterImplDocBase {
+
+}
Propchange: cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/SoapService8SoapPort8Impl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/branches/2.1.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/jms/SoapService8SoapPort8Impl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/branches/2.1.x-fixes/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl?rev=940168&r1=940167&r2=940168&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl (original)
+++ cxf/branches/2.1.x-fixes/testutils/src/main/resources/wsdl/hello_world_doc_lit.wsdl Sun May 2 07:02:21 2010
@@ -253,6 +253,20 @@ targetNamespace="http://apache.org/hello
</wsdl:port>
</wsdl:service>
+ <wsdl:service name="SOAPService8">
+ <wsdl:port name="SoapPort8" binding="tns:Greeter_SOAPBinding">
+ <jms:address
+ jndiConnectionFactoryName="ConnectionFactory"
+ jmsDestinationName="dynamicQueues/messageidascorrelationid.SOAPService8Q.text"
+ jmsReplyDestinationName="dynamicQueues/SoapService8.reply.queue"
+ jmsReplyToDestinationName="dynamicQueues/SoapService8.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">