You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2016/06/02 16:03:58 UTC
activemq git commit: test for uuid temp request/reply from camel
across network
Repository: activemq
Updated Branches:
refs/heads/master 76b70545f -> 1f9b139f5
test for uuid temp request/reply from camel across network
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/1f9b139f
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/1f9b139f
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/1f9b139f
Branch: refs/heads/master
Commit: 1f9b139f59707fd37bd3613212896dea695510cf
Parents: 76b7054
Author: gtully <ga...@gmail.com>
Authored: Thu Jun 2 16:25:36 2016 +0100
Committer: gtully <ga...@gmail.com>
Committed: Thu Jun 2 16:58:03 2016 +0100
----------------------------------------------------------------------
.../network/DemandForwardingBridgeSupport.java | 3 +-
.../camel/CamelJmsRequestReplyNobTest.java | 111 +++++++++++++++++++
.../org/apache/activemq/camel/requestReply.xml | 76 +++++++++++++
3 files changed, 188 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/1f9b139f/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
index d46f73b..c1319f5 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
@@ -992,9 +992,8 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
Message message = configureMessage(md);
LOG.debug("bridging ({} -> {}), consumer: {}, destination: {}, brokerPath: {}, message: {}", new Object[]{
- configuration.getBrokerName(), remoteBrokerName, (LOG.isTraceEnabled() ? message : message.getMessageId()), md.getConsumerId(), message.getDestination(), Arrays.toString(message.getBrokerPath()), message
+ configuration.getBrokerName(), remoteBrokerName, md.getConsumerId(), message.getDestination(), Arrays.toString(message.getBrokerPath()), (LOG.isTraceEnabled() ? message : message.getMessageId())
});
-
if (isDuplex() && NetworkBridgeFilter.isAdvisoryInterpretedByNetworkBridge(message)) {
try {
// never request b/c they are eventually acked async
http://git-wip-us.apache.org/repos/asf/activemq/blob/1f9b139f/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsRequestReplyNobTest.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsRequestReplyNobTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsRequestReplyNobTest.java
new file mode 100644
index 0000000..1f678b8
--- /dev/null
+++ b/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsRequestReplyNobTest.java
@@ -0,0 +1,111 @@
+/**
+ * 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.activemq.camel;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.network.DiscoveryNetworkConnector;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.net.URI;
+import java.util.Arrays;
+
+public class CamelJmsRequestReplyNobTest extends CamelSpringTestSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CamelJmsRequestReplyNobTest.class);
+
+ @Test
+ public void testRoundTrip() throws Exception {
+ Destination destination = getMandatoryBean(Destination.class, "consumeFrom");
+
+ // lets create a message
+ ConnectionFactory factoryCON = getMandatoryBean(ConnectionFactory.class, "CON");
+
+ Connection consumerConnection = factoryCON.createConnection();
+ consumerConnection.start();
+ Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ LOG.info("Consuming from: " + destination);
+ MessageConsumer consumer = consumerSession.createConsumer(destination);
+
+ // lets create a message
+ ConnectionFactory factoryPRO = getMandatoryBean(ConnectionFactory.class, "PRO");
+
+ Connection producerConnection = factoryPRO.createConnection();
+ producerConnection.start();
+ Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer producer = producerSession.createProducer(producerSession.createQueue("incoming1"));
+ Message message = producerSession.createTextMessage("Where are you");
+ message.setStringProperty("foo", "bar");
+ producer.send(message);
+
+ message = consumer.receive(10000);
+ assertNotNull("Should have received a message from destination: " + destination, message);
+
+ TextMessage textMessage = assertIsInstanceOf(TextMessage.class, message);
+ assertEquals("Message body", "If you don't ask me my name, I'm not going to tell you!", textMessage.getText());
+
+ }
+
+ private BrokerService createBroker(String name) throws Exception {
+ BrokerService brokerService = new BrokerService();
+ brokerService.setDeleteAllMessagesOnStartup(true);
+ brokerService.setBrokerName(name);
+ brokerService.setUseJmx(false);
+ brokerService.setPersistent(false);
+ brokerService.addConnector("tcp://0.0.0.0:0");
+ return brokerService;
+ }
+
+ BrokerService producerBroker, consumerBroker;
+ @SuppressWarnings("unchecked")
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ try {
+ consumerBroker = createBroker("CON");
+ producerBroker = createBroker("PRO");
+ DiscoveryNetworkConnector discoveryNetworkConnector = new DiscoveryNetworkConnector();
+ discoveryNetworkConnector.setUri(new URI("static:" + consumerBroker.getTransportConnectorByScheme("tcp").getPublishableConnectString()));
+ discoveryNetworkConnector.setDuplex(true);
+ discoveryNetworkConnector.setNetworkTTL(2);
+ discoveryNetworkConnector.setDynamicallyIncludedDestinations(Arrays.asList(new ActiveMQDestination[]{new ActiveMQQueue("service1")}));
+ discoveryNetworkConnector.setDestinationFilter("ActiveMQ.Advisory.Consumer.Queue.service1,ActiveMQ.Advisory.TempQueue,ActiveMQ.Advisory.TempTopic,ActiveMQ.Advisory.Consumer.Queue.*.*");
+ producerBroker.addNetworkConnector(discoveryNetworkConnector);
+ consumerBroker.start();
+ producerBroker.start();
+
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to start broker", e);
+ }
+ return new ClassPathXmlApplicationContext("org/apache/activemq/camel/requestReply.xml");
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq/blob/1f9b139f/activemq-camel/src/test/resources/org/apache/activemq/camel/requestReply.xml
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/requestReply.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/requestReply.xml
new file mode 100644
index 0000000..c5c6621
--- /dev/null
+++ b/activemq-camel/src/test/resources/org/apache/activemq/camel/requestReply.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route id="initial-consume-reply1">
+ <from uri="amqPRO:queue:incoming1"/>
+ <to uri="amqPRO:queue:service1?replyToType=Temporary&requestTimeout=35000" pattern="InOut"/>
+ <log message="After inOut via temp: body ${body}"/>
+ <to uri="seda:consumer"/>
+ </route>
+
+ <route id="consume-process-reply1">
+ <from uri="amqCON:queue:service1"/>
+ <choice>
+ <when>
+ <simple>${body} contains 'What is your name?'</simple>
+ <transform>
+ <simple>bobbie!</simple>
+ </transform>
+ </when>
+ <otherwise>
+ <transform>
+ <simple>If you don't ask me my name, I'm not going to tell you!</simple>
+ </transform>
+ </otherwise>
+ </choice>
+ <log message="${body}"/>
+ </route>
+ </camelContext>
+
+ <bean id="CON" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="vm://CON?create=false"/>
+ </bean>
+
+ <bean id="PRO" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="vm://PRO??create=false"/>
+ </bean>
+
+ <bean id="consumeFrom" class="org.apache.activemq.camel.CamelDestination">
+ <property name="uri" value="seda:consumer"/>
+ </bean>
+
+ <bean id="camelTemplate" class="org.apache.camel.spring.CamelProducerTemplateFactoryBean"/>
+
+ <bean id="amqPRO" class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="brokerURL" value="vm://PRO?create=false"></property>
+ </bean>
+
+ <bean id="amqCON" class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="brokerURL" value="vm://CON?create=false"></property>
+ </bean>
+
+
+</beans>