Repository: cxf Updated Branches: refs/heads/3.0.x-fixes e2f73f233 -> 4bb0d4ea2
[CXF-7008] Regression: CXF-5788 - JMS replyToDestination doesn't work (cherry picked from commit 0f51e22bc7e13630aeac1996fba4d06e97dea37c) (cherry picked from commit 7d19676c18dd98b82be79bce79d9c82c302a7e11) Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4bb0d4ea Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4bb0d4ea Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4bb0d4ea Branch: refs/heads/3.0.x-fixes Commit: 4bb0d4ea2c15484f4bc032dbe90405a43a99fd6f Parents: e2f73f2 Author: Tadayoshi Sato <sato.tadayo...@gmail.com> Authored: Fri Aug 12 16:06:48 2016 +0900 Committer: Freeman Fang <freeman.f...@gmail.com> Committed: Fri Aug 12 17:06:45 2016 +0800 ---------------------------------------------------------------------- .../apache/cxf/transport/jms/JMSConduit.java | 2 +- .../cxf/transport/jms/JMSConfiguration.java | 22 ++++++++++--- .../cxf/systest/jms/JMSClientServerTest.java | 34 ++++++++++++++++++++ 3 files changed, 53 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/4bb0d4ea/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java ---------------------------------------------------------------------- diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java index 00eba50..4c40da4 100644 --- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java +++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java @@ -212,7 +212,7 @@ public class JMSConduit extends AbstractConduit implements JMSExchangeSender, Me String jmsMessageID = sendMessage(request, outMessage, replyToDestination, correlationId, closer, session); boolean useSyncReceive = ((correlationId == null || userCID != null) && !jmsConfig.isPubSubDomain()) - || !replyToDestination.equals(staticReplyDestination); + || (!replyToDestination.equals(staticReplyDestination) && headers.getJMSReplyTo() != null); if (correlationId == null) { correlationId = jmsMessageID; correlationMap.put(correlationId, exchange); http://git-wip-us.apache.org/repos/asf/cxf/blob/4bb0d4ea/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java ---------------------------------------------------------------------- diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java index 5dc0e31..46a0d95 100644 --- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java +++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java @@ -75,6 +75,7 @@ public class JMSConfiguration { * Destination name to send out as replyTo address in the message */ private String replyToDestination; + private volatile Destination replyToDestinationDest; private String messageType = JMSConstants.TEXT_MESSAGE_TYPE; private boolean pubSubDomain; private boolean replyPubSubDomain; @@ -418,14 +419,27 @@ public class JMSConfiguration { } return resolver.resolveDestinationName(session, replyToDestinationName, pubSubDomain); } - + public Destination getReplyToDestination(Session session, String userDestination) throws JMSException { - if (userDestination == null) { + if (userDestination != null) { + return destinationResolver.resolveDestinationName(session, userDestination, replyPubSubDomain); + } + if (replyToDestination == null) { return getReplyDestination(session); } - return destinationResolver.resolveDestinationName(session, userDestination, replyPubSubDomain); + Destination result = replyToDestinationDest; + if (result == null) { + synchronized (this) { + result = replyToDestinationDest; + if (result == null) { + result = destinationResolver.resolveDestinationName(session, replyToDestination, replyPubSubDomain); + replyToDestinationDest = result; + } + } + } + return result; } - + public Destination getReplyDestination(Session session) throws JMSException { Destination result = replyDestinationDest; if (result == null) { http://git-wip-us.apache.org/repos/asf/cxf/blob/4bb0d4ea/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java ---------------------------------------------------------------------- diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java index 973985b..7e97b43 100644 --- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java +++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java @@ -33,6 +33,7 @@ import javax.xml.ws.BindingProvider; import javax.xml.ws.Endpoint; import javax.xml.ws.Response; import javax.xml.ws.soap.AddressingFeature; +import javax.xml.ws.soap.SOAPFaultException; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.cxf.Bus; @@ -52,8 +53,11 @@ import org.apache.cxf.hello_world_jms.HelloWorldService; import org.apache.cxf.hello_world_jms.NoSuchCodeLitFault; import org.apache.cxf.interceptor.LoggingInInterceptor; import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher; +import org.apache.cxf.transport.jms.JMSConfigFeature; +import org.apache.cxf.transport.jms.JMSConfiguration; import org.apache.cxf.transport.jms.JMSConstants; import org.apache.cxf.transport.jms.JMSMessageHeadersType; import org.apache.cxf.transport.jms.JMSPropertyType; @@ -609,4 +613,34 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase { ((Closeable)greeter).close(); } + @Test(expected = SOAPFaultException.class) + public void testReplyAndReplyToDestinations() throws Exception { + JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); + factory.setWsdlLocation("classpath:/wsdl/jms_test.wsdl"); + factory.setServiceName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService")); + factory.setEndpointName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort")); + factory.setAddress("jms://"); + JMSConfigFeature feature = new JMSConfigFeature(); + JMSConfiguration config = new JMSConfiguration(); + config.setConnectionFactory(new ActiveMQConnectionFactory(broker.getBrokerURL())); + config.setRequestURI("test.jmstransport.text"); + config.setTargetDestination("test.jmstransport.text"); + // replyDestination and replyToDestination intentionally differ in this test scenario + // replyDestination = Destination name to listen on for reply messages + config.setReplyDestination("test.jmstransport.text.reply"); + // replyToDestination = Destination name to send out as replyTo address in the message + config.setReplyToDestination("test.jmstransport.text.replyTo"); + config.setReceiveTimeout(1000L); + feature.setJmsConfig(config); + factory.getFeatures().add(feature); + HelloWorldPortType greeter = factory.create(HelloWorldPortType.class); + + try { + greeter.greetMe("FooBar"); + // Timeout exception should be thrown + } finally { + ((java.io.Closeable)greeter).close(); + } + } + }