From c1a2ff25c127192686b62d19d8af798330e8fc0f Mon Sep 17 00:00:00 2001 From: Matt Pavlovich Date: Fri, 3 Sep 2021 11:21:13 -0500 Subject: [PATCH] [AMQ-8033] Remove activemq-camel (#701) * [AMQ-8033] Remove activemq-camel - Prerequisite for JMS v2.0 support * [AMQ-8033] Remove activemq-camel - Prerequisite for JMS v2.0 support * [AMQ-8033] Assembly and karaf clean-ups --- activemq-all/pom.xml | 12 - activemq-camel/pom.xml | 306 ------------------ .../activemq/camel/CamelConnection.java | 45 --- .../camel/CamelConnectionFactory.java | 55 ---- .../activemq/camel/CamelDestination.java | 162 ---------- .../activemq/camel/CamelMessageConsumer.java | 173 ---------- .../activemq/camel/CamelMessageProducer.java | 106 ------ .../org/apache/activemq/camel/CamelQueue.java | 48 --- .../activemq/camel/CamelQueueReceiver.java | 50 --- .../activemq/camel/CamelQueueSender.java | 91 ------ .../activemq/camel/CamelShutdownHook.java | 73 ----- .../org/apache/activemq/camel/CamelTopic.java | 50 --- .../activemq/camel/CamelTopicPublisher.java | 146 --------- .../activemq/camel/CamelTopicSubscriber.java | 65 ---- .../camel/camelplugin/CamelRoutesBroker.java | 294 ----------------- .../camelplugin/CamelRoutesBrokerPlugin.java | 67 ---- .../camel/component/ActiveMQComponent.java | 249 -------------- .../component/ActiveMQConfiguration.java | 203 ------------ .../camel/component/ActiveMQEndpoint.java | 33 -- .../camel/component/CamelEndpointLoader.java | 179 ---------- .../OriginalDestinationPropagateStrategy.java | 56 ---- .../component/broker/BrokerComponent.java | 95 ------ .../component/broker/BrokerConfiguration.java | 39 --- .../component/broker/BrokerConsumer.java | 66 ---- .../component/broker/BrokerEndpoint.java | 138 -------- .../component/broker/BrokerJmsMessage.java | 53 --- .../component/broker/BrokerProducer.java | 115 ------- .../activemq/camel/component/package.html | 29 -- .../camel/converter/ActiveMQConverter.java | 42 --- .../converter/ActiveMQMessageConverter.java | 103 ------ .../activemq/camel/converter/package.html | 28 -- .../org/apache/activemq/camel/package.html | 29 -- .../services/org/apache/camel/TypeConverter | 19 -- .../org/apache/camel/component/activemq | 18 -- .../org/apache/camel/component/broker | 18 -- activemq-camel/src/test/data/message1.xml | 22 -- .../apache/activemq/camel/AMQ2240Test.java | 96 ------ .../apache/activemq/camel/AMQ2611Test.java | 88 ----- ...QComponentFactoryUserNamePasswordTest.java | 49 --- ...ActiveMQComponentUserNamePasswordTest.java | 49 --- .../camel/BrokerPreShutdownHookTest.java | 80 ----- ...CamelDestinationExclusiveConsumerTest.java | 47 --- .../camel/CamelEmbeddedBrokerTestSupport.java | 147 --------- .../camel/CamelJmsRequestReplyNobTest.java | 111 ------- .../apache/activemq/camel/CamelJmsTest.java | 105 ------ .../camel/CamelVMTransportRoutingTest.java | 158 --------- .../org/apache/activemq/camel/DlqTest.java | 98 ------ .../org/apache/activemq/camel/JmsBridge.java | 140 -------- .../camel/JmsConsumeSendTransacted.java | 100 ------ .../activemq/camel/JmsJdbcXARollbackTest.java | 185 ----------- .../apache/activemq/camel/JmsJdbcXATest.java | 209 ------------ .../activemq/camel/ObjectMessageTest.java | 87 ----- .../apache/activemq/camel/ObjectPayload.java | 25 -- .../activemq/camel/SetGroupIdProcessor.java | 36 --- .../apache/activemq/camel/SetHeaderTest.java | 65 ---- .../activemq/camel/TransactedConsumeTest.java | 140 -------- .../camelplugin/CamelPluginConfigTest.java | 127 -------- .../component/ActiveMQConfigureTest.java | 98 ------ .../ActiveMQJmsHeaderRouteForceTest.java | 49 --- .../component/ActiveMQJmsHeaderRouteTest.java | 99 ------ .../ActiveMQOriginalDestinationTest.java | 76 ----- ...tiveMQReplyToHeaderUsingConverterTest.java | 112 ------- .../camel/component/ActiveMQRouteTest.java | 86 ----- .../component/AdvisoryConsumerExample.java | 70 ---- .../AutoExposeQueuesInCamelTest.java | 111 ------- .../component/ComplexRequestReplyTest.java | 195 ----------- ...RequestReplyUsingJmsReplyToHeaderTest.java | 118 ------- .../component/JmsSimpleRequestReplyTest.java | 82 ----- .../broker/BrokerComponentXMLConfigTest.java | 207 ------------ .../InvokeJmsMessageListenerTest.java | 61 ---- .../converter/InvokeMessageListenerTest.java | 72 ----- .../src/test/resources/log4j.properties | 35 -- ...tiveMQComponentFactoryUserNamePassword.xml | 58 ---- .../ActiveMQComponentUserNamePassword.xml | 58 ---- ...stinationExclusiveConsumerTest-context.xml | 48 --- .../activemq/camel/SetHeaderTest-context.xml | 53 --- .../camelplugin/camel-routes-activemq.xml | 29 -- .../activemq/camel/camelplugin/routes.xml | 22 -- .../component/BrowseQueuesInUFace-context.xml | 37 --- .../camel/component/broker/broker-camel.xml | 33 -- .../activemq/camel/component/broker/camel.xml | 60 ---- .../org/apache/activemq/camel/dlq.xml | 71 ---- .../activemq/camel/jms-object-message.xml | 116 ------- .../org/apache/activemq/camel/jmsBridge.xml | 85 ----- .../camel/jmsConsumeSendTransacted.xml | 57 ---- .../org/apache/activemq/camel/jmsXajdbc.xml | 111 ------- .../activemq/camel/jmsXajdbcRollback.xml | 116 ------- .../apache/activemq/camel/requestReply.xml | 76 ----- .../org/apache/activemq/camel/spring.xml | 49 --- .../activemq/camel/transactedconsume.xml | 141 -------- .../ActiveMQBrokerNdCamelFeatureTest.java | 2 +- ...iveMQBrokerNdExternalCamelFeatureTest.java | 2 +- .../karaf/itest/activemq-nd-camel.xml | 2 +- .../org/apache/activemq/karaf/itest/camel.xml | 2 +- .../src/main/resources/features.xml | 1 - activemq-osgi/pom.xml | 1 - activemq-spring/pom.xml | 1 - activemq-unit-tests/pom.xml | 18 -- assembly/pom.xml | 4 - assembly/src/main/descriptors/common-bin.xml | 1 - assembly/src/release/examples/conf/camel.xml | 2 +- pom.xml | 6 - 102 files changed, 5 insertions(+), 8147 deletions(-) delete mode 100644 activemq-camel/pom.xml delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnection.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnectionFactory.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelDestination.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueue.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueSender.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelShutdownHook.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopic.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBroker.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBrokerPlugin.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQEndpoint.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/CamelEndpointLoader.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/OriginalDestinationPropagateStrategy.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerComponent.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConfiguration.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConsumer.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerEndpoint.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerJmsMessage.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerProducer.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/component/package.html delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQConverter.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQMessageConverter.java delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/converter/package.html delete mode 100644 activemq-camel/src/main/java/org/apache/activemq/camel/package.html delete mode 100644 activemq-camel/src/main/resources/META-INF/services/org/apache/camel/TypeConverter delete mode 100644 activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/activemq delete mode 100644 activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/broker delete mode 100644 activemq-camel/src/test/data/message1.xml delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2611Test.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/BrokerPreShutdownHookTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/CamelEmbeddedBrokerTestSupport.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsRequestReplyNobTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/CamelVMTransportRoutingTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/DlqTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/JmsBridge.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/JmsConsumeSendTransacted.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXARollbackTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXATest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/camelplugin/CamelPluginConfigTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQConfigureTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteForceTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQJmsHeaderRouteTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQOriginalDestinationTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQReplyToHeaderUsingConverterTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQRouteTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/AdvisoryConsumerExample.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/AutoExposeQueuesInCamelTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/ComplexRequestReplyTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/InvokeRequestReplyUsingJmsReplyToHeaderTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/JmsSimpleRequestReplyTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/component/broker/BrokerComponentXMLConfigTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeJmsMessageListenerTest.java delete mode 100644 activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeMessageListenerTest.java delete mode 100644 activemq-camel/src/test/resources/log4j.properties delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/camel-routes-activemq.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/routes.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/component/BrowseQueuesInUFace-context.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/component/broker/broker-camel.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/component/broker/camel.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/dlq.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/jmsBridge.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/jmsConsumeSendTransacted.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/jmsXajdbc.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/jmsXajdbcRollback.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/requestReply.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/spring.xml delete mode 100644 activemq-camel/src/test/resources/org/apache/activemq/camel/transactedconsume.xml diff --git a/activemq-all/pom.xml b/activemq-all/pom.xml index de8d404c08..963b7b60e9 100644 --- a/activemq-all/pom.xml +++ b/activemq-all/pom.xml @@ -25,10 +25,6 @@ - - ${project.groupId} - activemq-camel - ${project.groupId} activemq-console @@ -92,7 +88,6 @@ ${project.groupId}:activemq-client ${project.groupId}:activemq-openwire-legacy - ${project.groupId}:activemq-camel ${project.groupId}:activemq-jaas ${project.groupId}:activemq-broker ${project.groupId}:activemq-console @@ -211,13 +206,6 @@ sources true - - ${project.groupId} - activemq-camel - ${project.version} - sources - true - ${project.groupId} activemq-jaas diff --git a/activemq-camel/pom.xml b/activemq-camel/pom.xml deleted file mode 100644 index d578d62a12..0000000000 --- a/activemq-camel/pom.xml +++ /dev/null @@ -1,306 +0,0 @@ - - - - - 4.0.0 - - - org.apache.activemq - activemq-parent - 5.17.0-SNAPSHOT - - - activemq-camel - ActiveMQ :: Camel - ActiveMQ component for Camel - bundle - - - - org.apache.camel.spi.ComponentResolver;component=activemq, - org.apache.camel.spi.ComponentResolver;component=broker - - - - - - - - - - org.slf4j - slf4j-api - - - org.apache.camel - camel-jms - - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - - - - - - org.apache.camel - apt - ${camel-version} - provided - - - ${project.groupId} - activemq-spring - - - - - ${project.groupId} - activemq-pool - - - org.apache.geronimo.specs - geronimo-annotation_1.0_spec - true - - - - - ${project.groupId} - activemq-unit-tests - test-jar - test - - - ${project.groupId} - activemq-broker - test-jar - test - - - org.apache.camel - camel-test - test - - - org.apache.camel - camel-test-spring - test - - - org.springframework - spring-test - test - - - junit - junit - test - - - org.hamcrest - hamcrest-all - test - - - org.apache.derby - derby - true - test - - - org.apache.xbean - xbean-spring - true - test - - - org.apache.geronimo.components - geronimo-transaction - true - test - - - org.apache.commons - commons-dbcp2 - true - test - - - org.objectweb.howl - howl - 1.0.1-1 - true - test - - - org.jencks - jencks - 2.2 - true - test - - - ${project.groupId} - activemq-jaas - true - test - - - ${project.groupId} - activemq-ra - true - test - - - org.apache.camel - camel-jdbc - ${camel-version} - true - test - - - org.slf4j - slf4j-log4j12 - test - - - log4j - log4j - true - test - - - javax.xml.bind - jaxb-api - test - - - - - - - org.apache.felix - maven-bundle-plugin - true - true - - - - org.apache.activemq.camel*;version:="${project.version}";-noimport:=true - - - org.springframework.jms*;version="[4,6)", - org.apache.activemq.pool, - org.apache.camel*;version="${camel-version-range}", - * - - - org.apache.camel.spi.ComponentResolver;component=activemq, - org.apache.camel.spi.ComponentResolver;component=broker - - - - - - - maven-surefire-plugin - - 1 - false - false - true - -Xmx512M - - - org.apache.activemq.default.directory.prefix - target/ - - - - target/derby.log - - - - - - - org.apache.camel - camel-package-maven-plugin - ${camel-version} - - - - generate-components-list - - generate-resources - - - - - - - - - activemq.tests-sanity - - - activemq.tests - smoke - - - - - - maven-surefire-plugin - - - **/ActiveMQConfigureTest.* - **/ActiveMQJmsHeaderRouteTest.* - **/CamelJmsTest.* - - - - - - - - activemq.tests-autoTransport - - - activemq.tests - autoTransport - - - - - - maven-surefire-plugin - - - ** - - - - - - - - - diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnection.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnection.java deleted file mode 100644 index 7f39fd0864..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnection.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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.ActiveMQConnection; -import org.apache.activemq.management.JMSStatsImpl; -import org.apache.activemq.transport.Transport; -import org.apache.activemq.util.IdGenerator; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; - -/** - * - */ -public class CamelConnection extends ActiveMQConnection implements CamelContextAware { - - private CamelContext camelContext; - - protected CamelConnection(Transport transport, IdGenerator clientIdGenerator, - IdGenerator connectionIdGenerator, JMSStatsImpl factoryStats) throws Exception { - super(transport, clientIdGenerator, connectionIdGenerator, factoryStats); - } - - public CamelContext getCamelContext() { - return camelContext; - } - - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnectionFactory.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnectionFactory.java deleted file mode 100644 index 0664504a33..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelConnectionFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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.management.JMSStatsImpl; -import org.apache.activemq.spring.ActiveMQConnectionFactory; -import org.apache.activemq.transport.Transport; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; - -/** - * A JMS ConnectionFactory which resolves non-JMS destinations or instances of - * {@link CamelDestination} to use the {@link CamelContext} to perform smart routing etc - * - * - */ -public class CamelConnectionFactory extends ActiveMQConnectionFactory implements CamelContextAware { - private CamelContext camelContext; - - public CamelConnectionFactory() { - } - - public CamelContext getCamelContext() { - return camelContext; - } - - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - // Implementation methods - //----------------------------------------------------------------------- - protected CamelConnection createActiveMQConnection(Transport transport, JMSStatsImpl stats) throws Exception { - CamelConnection connection = new CamelConnection(transport, getClientIdGenerator(), getConnectionIdGenerator(), stats); - CamelContext context = getCamelContext(); - if (context != null) { - connection.setCamelContext(context); - } - return connection; - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelDestination.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelDestination.java deleted file mode 100644 index 76c2633a38..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelDestination.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * 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 javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.QueueReceiver; -import javax.jms.QueueSender; -import javax.jms.TopicPublisher; -import javax.jms.TopicSubscriber; - -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQSession; -import org.apache.activemq.CustomDestination; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.Endpoint; -import org.apache.camel.component.jms.JmsBinding; -import org.apache.camel.component.jms.JmsEndpoint; - -/** - * - */ -public class CamelDestination implements CustomDestination, CamelContextAware { - private String uri; - private Endpoint endpoint; - private CamelContext camelContext; - // add in dummy endpoint pending camel release with - // https://issues.apache.org/activemq/browse/CAMEL-1982 - private JmsBinding binding = new JmsBinding(new JmsEndpoint()); - - public CamelDestination() { - } - - public CamelDestination(String uri) { - this.uri = uri; - } - - public String toString() { - return uri.toString(); - } - - // CustomDestination interface - //----------------------------------------------------------------------- - public MessageConsumer createConsumer(ActiveMQSession session, String messageSelector) { - return createConsumer(session, messageSelector, false); - } - - public MessageConsumer createConsumer(ActiveMQSession session, String messageSelector, boolean noLocal) { - return new CamelMessageConsumer(this, resolveEndpoint(session), session, messageSelector, noLocal); - } - - public TopicSubscriber createSubscriber(ActiveMQSession session, String messageSelector, boolean noLocal) { - return createDurableSubscriber(session, null, messageSelector, noLocal); - } - - public TopicSubscriber createDurableSubscriber(ActiveMQSession session, String name, String messageSelector, boolean noLocal) { - throw new UnsupportedOperationException("This destination is not a Topic: " + this); - } - - public QueueReceiver createReceiver(ActiveMQSession session, String messageSelector) { - throw new UnsupportedOperationException("This destination is not a Queue: " + this); - } - - // Producers - //----------------------------------------------------------------------- - public MessageProducer createProducer(ActiveMQSession session) throws JMSException { - return new CamelMessageProducer(this, resolveEndpoint(session), session); - } - - public TopicPublisher createPublisher(ActiveMQSession session) throws JMSException { - throw new UnsupportedOperationException("This destination is not a Topic: " + this); - } - - public QueueSender createSender(ActiveMQSession session) throws JMSException { - throw new UnsupportedOperationException("This destination is not a Queue: " + this); - } - - // Properties - //----------------------------------------------------------------------- - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public Endpoint getEndpoint() { - return endpoint; - } - - public void setEndpoint(Endpoint endpoint) { - this.endpoint = endpoint; - } - - public CamelContext getCamelContext() { - return camelContext; - } - - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - public JmsBinding getBinding() { - return binding; - } - - public void setBinding(JmsBinding binding) { - this.binding = binding; - } - - // Implementation methods - //----------------------------------------------------------------------- - - /** - * Resolves the Camel Endpoint for this destination - * - * @return - */ - protected Endpoint resolveEndpoint(ActiveMQSession session) { - Endpoint answer = getEndpoint(); - if (answer == null) { - answer = resolveCamelContext(session).getEndpoint(getUri()); - if (answer == null) { - throw new IllegalArgumentException("No endpoint could be found for URI: " + getUri()); - } - } - return answer; - } - - protected CamelContext resolveCamelContext(ActiveMQSession session) { - CamelContext answer = getCamelContext(); - if (answer == null) { - ActiveMQConnection connection = session.getConnection(); - if (connection instanceof CamelConnection) { - CamelConnection camelConnection = (CamelConnection) connection; - answer = camelConnection.getCamelContext(); - } - } - if (answer == null) { - throw new IllegalArgumentException("No CamelContext has been configured"); - } - return answer; - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java deleted file mode 100644 index dbe211e564..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageConsumer.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * 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 javax.jms.IllegalStateException; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; - -import org.apache.activemq.ActiveMQSession; -import org.apache.activemq.util.JMSExceptionSupport; -import org.apache.camel.Consumer; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.PollingConsumer; -import org.apache.camel.Processor; - -/** - * A JMS {@link javax.jms.MessageConsumer} which consumes message exchanges from - * a Camel {@link Endpoint} - * - * - */ -public class CamelMessageConsumer implements MessageConsumer { - private final CamelDestination destination; - private final Endpoint endpoint; - private final ActiveMQSession session; - private final String messageSelector; - private final boolean noLocal; - private MessageListener messageListener; - private Consumer consumer; - private PollingConsumer pollingConsumer; - private boolean closed; - - public CamelMessageConsumer(CamelDestination destination, Endpoint endpoint, ActiveMQSession session, String messageSelector, boolean noLocal) { - this.destination = destination; - this.endpoint = endpoint; - this.session = session; - this.messageSelector = messageSelector; - this.noLocal = noLocal; - } - - public void close() throws JMSException { - if (!closed) { - closed = true; - try { - if (consumer != null) { - consumer.stop(); - } - if (pollingConsumer != null) { - pollingConsumer.stop(); - } - } catch (JMSException e) { - throw e; - } catch (Exception e) { - throw JMSExceptionSupport.create(e); - } - } - } - - public MessageListener getMessageListener() throws JMSException { - return messageListener; - } - - public void setMessageListener(MessageListener messageListener) throws JMSException { - this.messageListener = messageListener; - if (messageListener != null && consumer == null) { - consumer = createConsumer(); - } - } - - public Message receive() throws JMSException { - Exchange exchange = getPollingConsumer().receive(); - return createMessage(exchange); - } - - public Message receive(long timeoutMillis) throws JMSException { - Exchange exchange = getPollingConsumer().receive(timeoutMillis); - return createMessage(exchange); - } - - public Message receiveNoWait() throws JMSException { - Exchange exchange = getPollingConsumer().receiveNoWait(); - return createMessage(exchange); - } - - // Properties - // ----------------------------------------------------------------------- - - public CamelDestination getDestination() { - return destination; - } - - public Endpoint getEndpoint() { - return endpoint; - } - - public String getMessageSelector() { - return messageSelector; - } - - public boolean isNoLocal() { - return noLocal; - } - - public ActiveMQSession getSession() { - return session; - } - - // Implementation methods - // ----------------------------------------------------------------------- - - protected PollingConsumer getPollingConsumer() throws JMSException { - try { - if (pollingConsumer == null) { - pollingConsumer = endpoint.createPollingConsumer(); - pollingConsumer.start(); - } - return pollingConsumer; - } catch (JMSException e) { - throw e; - } catch (Exception e) { - throw JMSExceptionSupport.create(e); - } - } - - protected Message createMessage(Exchange exchange) throws JMSException { - if (exchange != null) { - Message message = destination.getBinding().makeJmsMessage(exchange, session); - return message; - } else { - return null; - } - } - - protected Consumer createConsumer() throws JMSException { - try { - Consumer answer = endpoint.createConsumer(new Processor() { - public void process(Exchange exchange) throws Exception { - Message message = createMessage(exchange); - getMessageListener().onMessage(message); - } - }); - answer.start(); - return answer; - } catch (JMSException e) { - throw e; - } catch (Exception e) { - throw JMSExceptionSupport.create(e); - } - } - - protected void checkClosed() throws javax.jms.IllegalStateException { - if (closed) { - throw new IllegalStateException("The producer is closed"); - } - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java deleted file mode 100644 index 3e54b1f9a9..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelMessageProducer.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * 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 javax.jms.Destination; -import javax.jms.IllegalStateException; -import javax.jms.JMSException; -import javax.jms.Message; - -import org.apache.activemq.ActiveMQMessageProducerSupport; -import org.apache.activemq.ActiveMQSession; -import org.apache.activemq.util.JMSExceptionSupport; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Producer; -import org.apache.camel.component.jms.JmsMessage; -import org.apache.camel.util.ObjectHelper; - -/** - * A JMS {@link javax.jms.MessageProducer} which sends message exchanges to a - * Camel {@link Endpoint} - * - * - */ -public class CamelMessageProducer extends ActiveMQMessageProducerSupport { - - protected Producer producer; - - private final CamelDestination destination; - private final Endpoint endpoint; - private boolean closed; - - public CamelMessageProducer(CamelDestination destination, Endpoint endpoint, ActiveMQSession session) throws JMSException { - super(session); - this.destination = destination; - this.endpoint = endpoint; - try { - this.producer = endpoint.createProducer(); - } catch (JMSException e) { - throw e; - } catch (Exception e) { - throw JMSExceptionSupport.create(e); - } - } - - public CamelDestination getDestination() throws JMSException { - return destination; - } - - public Endpoint getEndpoint() { - return endpoint; - } - - public void close() throws JMSException { - if (!closed) { - closed = true; - try { - producer.stop(); - } catch (JMSException e) { - throw e; - } catch (Exception e) { - throw JMSExceptionSupport.create(e); - } - } - } - - public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException { - CamelDestination camelDestination = null; - if (ObjectHelper.equal(destination, this.destination)) { - camelDestination = this.destination; - } else { - // TODO support any CamelDestination? - throw new IllegalArgumentException("Invalid destination setting: " + destination + " when expected: " + this.destination); - } - try { - Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly); - exchange.setIn(new JmsMessage(message, camelDestination.getBinding())); - producer.process(exchange); - } catch (JMSException e) { - throw e; - } catch (Exception e) { - throw JMSExceptionSupport.create(e); - } - } - - protected void checkClosed() throws IllegalStateException { - if (closed) { - throw new IllegalStateException("The producer is closed"); - } - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueue.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueue.java deleted file mode 100644 index 6fd908a823..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueue.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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 javax.jms.JMSException; -import javax.jms.Queue; -import javax.jms.QueueReceiver; -import javax.jms.QueueSender; - -import org.apache.activemq.ActiveMQSession; - -/** - * A JMS {@link Queue} object which refers to a Camel endpoint - * - * - */ -public class CamelQueue extends CamelDestination implements Queue { - - public CamelQueue(String uri) { - super(uri); - } - - public String getQueueName() throws JMSException { - return getUri(); - } - - public QueueSender createSender(ActiveMQSession session) throws JMSException { - return new CamelQueueSender(this, resolveEndpoint(session), session); - } - public QueueReceiver createReceiver(ActiveMQSession session, String messageSelector) { - return new CamelQueueReceiver(this, resolveEndpoint(session), session, messageSelector); - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java deleted file mode 100644 index 54221d1776..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueReceiver.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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 javax.jms.JMSException; -import javax.jms.Queue; -import javax.jms.QueueReceiver; - -import org.apache.activemq.ActiveMQSession; -import org.apache.camel.Endpoint; - -/** - * A JMS {@link javax.jms.QueueReceiver} which consumes message exchanges from a - * Camel {@link org.apache.camel.Endpoint} - * - * - */ -public class CamelQueueReceiver extends CamelMessageConsumer implements QueueReceiver { - - public CamelQueueReceiver(CamelQueue destination, Endpoint endpoint, ActiveMQSession session, String name) { - super(destination, endpoint, session, null, false); - } - - /** - * Gets the Queue associated with this queue receiver. - * - * @return this receiver's Queue - * @throws JMSException if the JMS provider fails to get the queue for this queue - * receiver due to some internal error. - */ - - public Queue getQueue() throws JMSException { - checkClosed(); - return (Queue) super.getDestination(); - } -} \ No newline at end of file diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueSender.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueSender.java deleted file mode 100644 index 9f961028dc..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelQueueSender.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * 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 javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Queue; -import javax.jms.QueueSender; - -import org.apache.activemq.ActiveMQSession; -import org.apache.camel.Endpoint; - -/** - * A JMS {@link javax.jms.QueueSender} which sends message exchanges to a Camel - * {@link org.apache.camel.Endpoint} - * - * - */ -public class CamelQueueSender extends CamelMessageProducer implements QueueSender { - - public CamelQueueSender(CamelQueue destination, Endpoint endpoint, ActiveMQSession session) throws JMSException { - super(destination, endpoint, session); - } - - /** - * Gets the queue associated with this QueueSender. - * - * @return this sender's queue - * @throws JMSException if the JMS provider fails to get the queue for this - * QueueSender due to some internal error. - */ - - public Queue getQueue() throws JMSException { - return (Queue)super.getDestination(); - } - - /** - * Sends a message to a queue for an unidentified message producer. Uses the - * QueueSender's default delivery mode, priority, and time - * to live.

Typically, a message producer is assigned a queue at - * creation time; however, the JMS API also supports unidentified message - * producers, which require that the queue be supplied every time a message - * is sent. - * - * @param queue the queue to send this message to - * @param message the message to send - * @throws JMSException if the JMS provider fails to send the message due to - * some internal error. - * @see javax.jms.MessageProducer#getDeliveryMode() - * @see javax.jms.MessageProducer#getTimeToLive() - * @see javax.jms.MessageProducer#getPriority() - */ - - public void send(Queue queue, Message message) throws JMSException { - super.send(queue, message); - } - - /** - * Sends a message to a queue for an unidentified message producer, - * specifying delivery mode, priority and time to live.

Typically, - * a message producer is assigned a queue at creation time; however, the JMS - * API also supports unidentified message producers, which require that the - * queue be supplied every time a message is sent. - * - * @param queue the queue to send this message to - * @param message the message to send - * @param deliveryMode the delivery mode to use - * @param priority the priority for this message - * @param timeToLive the message's lifetime (in milliseconds) - * @throws JMSException if the JMS provider fails to send the message due to - * some internal error. - */ - - public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException { - super.send(queue, message, deliveryMode, priority, timeToLive); - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelShutdownHook.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelShutdownHook.java deleted file mode 100644 index 217a1a63c9..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelShutdownHook.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * 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.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * A shutdown hook that can be used to shutdown {@link CamelContext} before the - * ActiveMQ broker is shut down. This is sometimes important as if the broker is - * shutdown before Camel there could be a loss of data due to inflight exchanges - * not yet completed. - *

- * This hook can be added to ActiveMQ configuration ({@code activemq.xml}) as in - * the following example: - *

- * - * <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.camel.CamelShutdownHook" /> - * - */ -public final class CamelShutdownHook implements Runnable, CamelContextAware { - - private static final Logger LOG = LoggerFactory.getLogger(CamelShutdownHook.class); - - private CamelContext camelContext; - - @Autowired - public CamelShutdownHook(final BrokerService brokerService) { - brokerService.addPreShutdownHook(this); - } - - @Override - public CamelContext getCamelContext() { - return camelContext; - } - - @Override - public void run() { - if (camelContext != null) { - try { - camelContext.stop(); - } catch (final Exception e) { - LOG.warn("Unable to stop CamelContext", e); - } - } else { - LOG.warn("Unable to stop CamelContext, no CamelContext was set!"); - } - } - - @Override - public void setCamelContext(final CamelContext camelContext) { - this.camelContext = camelContext; - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopic.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopic.java deleted file mode 100644 index 32b24ee2ef..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopic.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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 javax.jms.JMSException; -import javax.jms.Topic; -import javax.jms.TopicPublisher; -import javax.jms.TopicSubscriber; - -import org.apache.activemq.ActiveMQSession; - -/** - * A JMS {@link javax.jms.Topic} object which refers to a Camel endpoint - * - * - */ -public class CamelTopic extends CamelDestination implements Topic { - - public CamelTopic(String uri) { - super(uri); - } - - public String getTopicName() throws JMSException { - return getUri(); - } - - public TopicPublisher createPublisher(ActiveMQSession session) throws JMSException { - return new CamelTopicPublisher(this, resolveEndpoint(session), session); - } - - public TopicSubscriber createDurableSubscriber(ActiveMQSession session, String name, String messageSelector, boolean noLocal) { - return new CamelTopicSubscriber(this, resolveEndpoint(session), session, name, messageSelector, noLocal); - } - - -} \ No newline at end of file diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java deleted file mode 100644 index 438067ab7c..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicPublisher.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * 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 javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Topic; -import javax.jms.TopicPublisher; - -import org.apache.activemq.ActiveMQSession; -import org.apache.camel.Endpoint; - -/** - * A JMS {@link javax.jms.TopicPublisher} which sends message exchanges to a - * Camel {@link Endpoint} - * - * - */ -public class CamelTopicPublisher extends CamelMessageProducer implements TopicPublisher { - - public CamelTopicPublisher(CamelTopic destination, Endpoint endpoint, ActiveMQSession session) throws JMSException { - super(destination, endpoint, session); - } - - - /** - * Gets the topic associated with this TopicPublisher. - * - * @return this publisher's topic - * @throws JMSException if the JMS provider fails to get the topic for this - * TopicPublisher due to some internal error. - */ - - public Topic getTopic() throws JMSException { - return (Topic) super.getDestination(); - } - - /** - * Publishes a message to the topic. Uses the TopicPublisher's - * default delivery mode, priority, and time to live. - * - * @param message the message to publish - * @throws JMSException if the JMS provider fails to publish the message due to - * some internal error. - * @throws javax.jms.MessageFormatException if an invalid message is specified. - * @throws javax.jms.InvalidDestinationException if a client uses this method with a TopicPublisher - * with an invalid topic. - * @throws java.lang.UnsupportedOperationException - * if a client uses this method with a TopicPublisher - * that did not specify a topic at creation time. - * @see javax.jms.MessageProducer#getDeliveryMode() - * @see javax.jms.MessageProducer#getTimeToLive() - * @see javax.jms.MessageProducer#getPriority() - */ - - public void publish(Message message) throws JMSException { - super.send(message); - } - - /** - * Publishes a message to the topic, specifying delivery mode, priority, - * and time to live. - * - * @param message the message to publish - * @param deliveryMode the delivery mode to use - * @param priority the priority for this message - * @param timeToLive the message's lifetime (in milliseconds) - * @throws JMSException if the JMS provider fails to publish the message due to - * some internal error. - * @throws javax.jms.MessageFormatException if an invalid message is specified. - * @throws javax.jms.InvalidDestinationException if a client uses this method with a TopicPublisher - * with an invalid topic. - * @throws java.lang.UnsupportedOperationException - * if a client uses this method with a TopicPublisher - * that did not specify a topic at creation time. - */ - - public void publish(Message message, int deliveryMode, int priority, - long timeToLive) throws JMSException { - super.send(message, deliveryMode, priority, timeToLive); - } - - /** - * Publishes a message to a topic for an unidentified message producer. - * Uses the TopicPublisher's default delivery mode, - * priority, and time to live. - *

- *

- * Typically, a message producer is assigned a topic at creation time; - * however, the JMS API also supports unidentified message producers, which - * require that the topic be supplied every time a message is published. - * - * @param topic the topic to publish this message to - * @param message the message to publish - * @throws JMSException if the JMS provider fails to publish the message due to - * some internal error. - * @throws javax.jms.MessageFormatException if an invalid message is specified. - * @throws javax.jms.InvalidDestinationException if a client uses this method with an invalid topic. - * @see javax.jms.MessageProducer#getDeliveryMode() - * @see javax.jms.MessageProducer#getTimeToLive() - * @see javax.jms.MessageProducer#getPriority() - */ - - public void publish(Topic topic, Message message) throws JMSException { - super.send(topic, message); - } - - /** - * Publishes a message to a topic for an unidentified message producer, - * specifying delivery mode, priority and time to live. - *

- *

- * Typically, a message producer is assigned a topic at creation time; - * however, the JMS API also supports unidentified message producers, which - * require that the topic be supplied every time a message is published. - * - * @param topic the topic to publish this message to - * @param message the message to publish - * @param deliveryMode the delivery mode to use - * @param priority the priority for this message - * @param timeToLive the message's lifetime (in milliseconds) - * @throws JMSException if the JMS provider fails to publish the message due to - * some internal error. - * @throws javax.jms.MessageFormatException if an invalid message is specified. - * @throws javax.jms.InvalidDestinationException if a client uses this method with an invalid topic. - */ - - public void publish(Topic topic, Message message, int deliveryMode, - int priority, long timeToLive) throws JMSException { - super.send(topic, message, deliveryMode, priority, timeToLive); - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java b/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java deleted file mode 100644 index 8e772ca353..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/CamelTopicSubscriber.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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 javax.jms.JMSException; -import javax.jms.Topic; -import javax.jms.TopicSubscriber; - -import org.apache.activemq.ActiveMQSession; -import org.apache.camel.Endpoint; - -/** - * A JMS {@link javax.jms.TopicSubscriber} which consumes message exchanges from a - * Camel {@link Endpoint} - * - * - */ -public class CamelTopicSubscriber extends CamelMessageConsumer implements TopicSubscriber { - - public CamelTopicSubscriber(CamelTopic destination, Endpoint endpoint, ActiveMQSession session, String name, String messageSelector, boolean noLocal) { - super(destination, endpoint, session, messageSelector, noLocal); - } - - /** - * Gets the Topic associated with this subscriber. - * - * @return this subscriber's Topic - * @throws javax.jms.JMSException if the JMS provider fails to get the topic for this topic - * subscriber due to some internal error. - */ - - public Topic getTopic() throws JMSException { - checkClosed(); - return (Topic) super.getDestination(); - } - - /** - * Gets the NoLocal attribute for this subscriber. The - * default value for this attribute is false. - * - * @return true if locally published messages are being inhibited - * @throws JMSException if the JMS provider fails to get the NoLocal - * attribute for this topic subscriber due to some - * internal error. - */ - - public boolean getNoLocal() throws JMSException { - checkClosed(); - return super.isNoLocal(); - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBroker.java b/activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBroker.java deleted file mode 100644 index ee7890afde..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBroker.java +++ /dev/null @@ -1,294 +0,0 @@ -/** - * 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.camelplugin; - -import org.apache.activemq.broker.Broker; -import org.apache.activemq.broker.BrokerContext; -import org.apache.activemq.broker.BrokerFilter; -import org.apache.activemq.broker.ConnectionContext; -import org.apache.activemq.broker.ConsumerBrokerExchange; -import org.apache.activemq.broker.ProducerBrokerExchange; -import org.apache.activemq.broker.region.Destination; -import org.apache.activemq.broker.region.MessageReference; -import org.apache.activemq.broker.region.Subscription; -import org.apache.activemq.command.ConsumerControl; -import org.apache.activemq.command.Message; -import org.apache.activemq.command.MessageAck; -import org.apache.activemq.command.MessageDispatch; -import org.apache.activemq.command.MessagePull; -import org.apache.activemq.command.Response; -import org.apache.activemq.command.TransactionId; -import org.apache.activemq.spring.Utils; -import org.apache.activemq.usage.Usage; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.RoutesDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.io.Resource; - -import java.io.File; -import java.io.InputStream; -import java.util.List; -import java.util.concurrent.CountDownLatch; - -/** - * A StatisticsBroker You can retrieve a Map Message for a Destination - or - * Broker containing statistics as key-value pairs The message must contain a - * replyTo Destination - else its ignored - * - */ -public class CamelRoutesBroker extends BrokerFilter { - private static Logger LOG = LoggerFactory.getLogger(CamelRoutesBroker.class); - private String routesFile = ""; - private int checkPeriod = 1000; - private Resource theRoutes; - private DefaultCamelContext camelContext; - private long lastRoutesModified = -1; - private CountDownLatch countDownLatch; - - /** - * Overide methods to pause the broker whilst camel routes are loaded - */ - @Override - public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception { - blockWhileLoadingCamelRoutes(); - super.send(producerExchange, message); - } - - @Override - public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception { - blockWhileLoadingCamelRoutes(); - super.acknowledge(consumerExchange, ack); - } - - @Override - public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception { - blockWhileLoadingCamelRoutes(); - return super.messagePull(context, pull); - } - - @Override - public void processConsumerControl(ConsumerBrokerExchange consumerExchange, ConsumerControl control) { - blockWhileLoadingCamelRoutes(); - super.processConsumerControl(consumerExchange, control); - } - - @Override - public void reapplyInterceptor() { - blockWhileLoadingCamelRoutes(); - super.reapplyInterceptor(); - } - - @Override - public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception { - blockWhileLoadingCamelRoutes(); - super.beginTransaction(context, xid); - } - - @Override - public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception { - blockWhileLoadingCamelRoutes(); - return super.prepareTransaction(context, xid); - } - - @Override - public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception { - blockWhileLoadingCamelRoutes(); - super.rollbackTransaction(context, xid); - } - - @Override - public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception { - blockWhileLoadingCamelRoutes(); - super.commitTransaction(context, xid, onePhase); - } - - @Override - public void forgetTransaction(ConnectionContext context, TransactionId transactionId) throws Exception { - blockWhileLoadingCamelRoutes(); - super.forgetTransaction(context, transactionId); - } - - @Override - public void preProcessDispatch(MessageDispatch messageDispatch) { - blockWhileLoadingCamelRoutes(); - super.preProcessDispatch(messageDispatch); - } - - @Override - public void postProcessDispatch(MessageDispatch messageDispatch) { - blockWhileLoadingCamelRoutes(); - super.postProcessDispatch(messageDispatch); - } - - @Override - public boolean sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference, Subscription subscription, Throwable poisonCause) { - blockWhileLoadingCamelRoutes(); - return super.sendToDeadLetterQueue(context, messageReference, subscription, poisonCause); - } - - @Override - public void messageConsumed(ConnectionContext context, MessageReference messageReference) { - blockWhileLoadingCamelRoutes(); - super.messageConsumed(context, messageReference); - } - - @Override - public void messageDelivered(ConnectionContext context, MessageReference messageReference) { - blockWhileLoadingCamelRoutes(); - super.messageDelivered(context, messageReference); - } - - @Override - public void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference) { - blockWhileLoadingCamelRoutes(); - super.messageDiscarded(context, sub, messageReference); - } - - @Override - public void isFull(ConnectionContext context, Destination destination, Usage usage) { - blockWhileLoadingCamelRoutes(); - super.isFull(context, destination, usage); - } - - @Override - public void nowMasterBroker() { - blockWhileLoadingCamelRoutes(); - super.nowMasterBroker(); - } - - /* - * Properties - */ - - public String getRoutesFile() { - return routesFile; - } - - public void setRoutesFile(String routesFile) { - this.routesFile = routesFile; - } - - public int getCheckPeriod() { - return checkPeriod; - } - - public void setCheckPeriod(int checkPeriod) { - this.checkPeriod = checkPeriod; - } - - public CamelRoutesBroker(Broker next) { - super(next); - } - - @Override - public void start() throws Exception { - super.start(); - LOG.info("Starting CamelRoutesBroker"); - - camelContext = new DefaultCamelContext(); - camelContext.setName("EmbeddedCamel-" + getBrokerName()); - camelContext.start(); - - getBrokerService().getScheduler().executePeriodically(new Runnable() { - @Override - public void run() { - try { - loadCamelRoutes(); - } catch (Throwable e) { - LOG.error("Failed to load Camel Routes", e); - } - - } - }, getCheckPeriod()); - } - - - - @Override - public void stop() throws Exception { - CountDownLatch latch = this.countDownLatch; - if (latch != null){ - latch.countDown(); - } - if (camelContext != null){ - camelContext.stop(); - } - super.stop(); - } - - private void loadCamelRoutes() throws Exception{ - if (theRoutes == null) { - String fileToUse = getRoutesFile(); - if (fileToUse == null || fileToUse.trim().isEmpty()) { - BrokerContext brokerContext = getBrokerService().getBrokerContext(); - if (brokerContext != null) { - String uri = brokerContext.getConfigurationUrl(); - Resource resource = Utils.resourceFromString(uri); - if (resource.exists()) { - fileToUse = resource.getFile().getParent(); - fileToUse += File.separator; - fileToUse += "routes.xml"; - } - } - } - if (fileToUse != null && !fileToUse.isEmpty()){ - theRoutes = Utils.resourceFromString(fileToUse); - setRoutesFile(theRoutes.getFile().getAbsolutePath()); - } - } - if (!isStopped() && camelContext != null && theRoutes != null && theRoutes.exists()){ - long lastModified = theRoutes.lastModified(); - if (lastModified != lastRoutesModified){ - CountDownLatch latch = new CountDownLatch(1); - this.countDownLatch = latch; - lastRoutesModified = lastModified; - - List currentRoutes = camelContext.getRouteDefinitions(); - for (RouteDefinition rd:currentRoutes){ - camelContext.stopRoute(rd); - camelContext.removeRouteDefinition(rd); - } - InputStream is = theRoutes.getInputStream(); - RoutesDefinition routesDefinition = camelContext.loadRoutesDefinition(is); - - for (RouteDefinition rd: routesDefinition.getRoutes()){ - camelContext.startRoute(rd); - } - is.close(); - latch.countDown(); - this.countDownLatch=null; - } - - - } - } - - private void blockWhileLoadingCamelRoutes(){ - CountDownLatch latch = this.countDownLatch; - if (latch != null){ - try { - latch.await(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBrokerPlugin.java b/activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBrokerPlugin.java deleted file mode 100644 index 2e9833fdc7..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/camelplugin/CamelRoutesBrokerPlugin.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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.camelplugin; - -import org.apache.activemq.broker.Broker; -import org.apache.activemq.broker.BrokerPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A CamelRoutesBrokerPlugin - * - * load camel routes dynamically from a routes.xml file located in same directory as ActiveMQ.xml - * - * @org.apache.xbean.XBean element="camelRoutesBrokerPlugin" - * - */ -public class CamelRoutesBrokerPlugin implements BrokerPlugin { - private static Logger LOG = LoggerFactory.getLogger(CamelRoutesBrokerPlugin.class); - private String routesFile = ""; - private int checkPeriod =1000; - - public String getRoutesFile() { - return routesFile; - } - - public void setRoutesFile(String routesFile) { - this.routesFile = routesFile; - } - - public int getCheckPeriod() { - return checkPeriod; - } - - public void setCheckPeriod(int checkPeriod) { - this.checkPeriod = checkPeriod; - } - - /** - * @param broker - * @return the plug-in - * @throws Exception - * @see org.apache.activemq.broker.BrokerPlugin#installPlugin(org.apache.activemq.broker.Broker) - */ - public Broker installPlugin(Broker broker) throws Exception { - CamelRoutesBroker answer = new CamelRoutesBroker(broker); - answer.setCheckPeriod(getCheckPeriod()); - answer.setRoutesFile(getRoutesFile()); - LOG.info("Installing CamelRoutesBroker"); - return answer; - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java deleted file mode 100644 index a36e0735b9..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQComponent.java +++ /dev/null @@ -1,249 +0,0 @@ -/** - * 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.component; - -import java.net.URISyntaxException; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; - -import javax.jms.Connection; - -import org.apache.activemq.EnhancedConnection; -import org.apache.activemq.Service; -import org.apache.activemq.advisory.DestinationSource; -import org.apache.camel.CamelContext; -import org.apache.camel.component.jms.JmsComponent; -import org.apache.camel.component.jms.JmsConfiguration; -import org.apache.camel.util.IntrospectionSupport; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.URISupport; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.jms.connection.SingleConnectionFactory; -import org.springframework.jms.core.JmsTemplate; - -/** - * The ActiveMQ Component - */ -public class ActiveMQComponent extends JmsComponent { - private final CopyOnWriteArrayList singleConnectionFactoryList = - new CopyOnWriteArrayList(); - private final CopyOnWriteArrayList pooledConnectionFactoryServiceList = - new CopyOnWriteArrayList(); - private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQComponent.class); - private boolean exposeAllQueues; - private CamelEndpointLoader endpointLoader; - - private EnhancedConnection connection; - DestinationSource source; - - /** - * Creates an ActiveMQ Component - * - * @return the created component - */ - public static ActiveMQComponent activeMQComponent() { - return new ActiveMQComponent(); - } - - /** - * Creates an ActiveMQ Component - * connecting to the given broker URL - * - * @param brokerURL the URL to connect to - * @return the created component - */ - public static ActiveMQComponent activeMQComponent(String brokerURL) { - ActiveMQComponent answer = new ActiveMQComponent(); - if (answer.getConfiguration() instanceof ActiveMQConfiguration) { - ((ActiveMQConfiguration) answer.getConfiguration()) - .setBrokerURL(brokerURL); - } - - return answer; - } - - public ActiveMQComponent() { - } - - public ActiveMQComponent(CamelContext context) { - super(context); - } - - public ActiveMQComponent(ActiveMQConfiguration configuration) { - super(); - setConfiguration(configuration); - } - - /** - * Sets the broker URL to use to connect to ActiveMQ using the - * ActiveMQ URI format - */ - public void setBrokerURL(String brokerURL) { - if (getConfiguration() instanceof ActiveMQConfiguration) { - ((ActiveMQConfiguration)getConfiguration()).setBrokerURL(brokerURL); - } - } - - public void setTrustAllPackages(boolean trustAllPackages) { - if (getConfiguration() instanceof ActiveMQConfiguration) { - ((ActiveMQConfiguration)getConfiguration()).setTrustAllPackages(trustAllPackages); - } - } - - public boolean isExposeAllQueues() { - return exposeAllQueues; - } - - /** - * If enabled this will cause all Queues in the ActiveMQ broker to be eagerly populated into the CamelContext - * so that they can be easily browsed by any Camel tooling. This option is disabled by default. - */ - public void setExposeAllQueues(boolean exposeAllQueues) { - this.exposeAllQueues = exposeAllQueues; - } - - /** - * Enables or disables whether a PooledConnectionFactory will be used so that when - * messages are sent to ActiveMQ from outside of a message consuming thread, pooling will be used rather - * than the default with the Spring {@link JmsTemplate} which will create a new connection, session, producer - * for each message then close them all down again. - *

- * The default value is true. Note that this requires an extra dependency on commons-pool2. - */ - public void setUsePooledConnection(boolean usePooledConnection) { - if (getConfiguration() instanceof ActiveMQConfiguration) { - ((ActiveMQConfiguration)getConfiguration()).setUsePooledConnection(usePooledConnection); - } - } - - /** - * Enables or disables whether a Spring {@link SingleConnectionFactory} will be used so that when - * messages are sent to ActiveMQ from outside of a message consuming thread, pooling will be used rather - * than the default with the Spring {@link JmsTemplate} which will create a new connection, session, producer - * for each message then close them all down again. - *

- * The default value is false and a pooled connection is used by default. - */ - public void setUseSingleConnection(boolean useSingleConnection) { - if (getConfiguration() instanceof ActiveMQConfiguration) { - ((ActiveMQConfiguration)getConfiguration()).setUseSingleConnection(useSingleConnection); - } - } - - protected void addPooledConnectionFactoryService(Service pooledConnectionFactoryService) { - pooledConnectionFactoryServiceList.add(pooledConnectionFactoryService); - } - - protected void addSingleConnectionFactory(SingleConnectionFactory singleConnectionFactory) { - singleConnectionFactoryList.add(singleConnectionFactory); - } - - @Override - @SuppressWarnings("unchecked") - protected String convertPathToActualDestination(String path, Map parameters) { - // support ActiveMQ destination options using the destination. prefix - // http://activemq.apache.org/destination-options.html - Map options = IntrospectionSupport.extractProperties(parameters, "destination."); - - String query; - try { - query = URISupport.createQueryString(options); - } catch (URISyntaxException e) { - throw ObjectHelper.wrapRuntimeCamelException(e); - } - - // if we have destination options then append them to the destination name - if (ObjectHelper.isNotEmpty(query)) { - return path + "?" + query; - } else { - return path; - } - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - - if (isExposeAllQueues()) { - createDestinationSource(); - endpointLoader = new CamelEndpointLoader(getCamelContext(), source); - endpointLoader.afterPropertiesSet(); - } - - // use OriginalDestinationPropagateStrategy by default if no custom stategy has been set - if (getMessageCreatedStrategy() == null) { - setMessageCreatedStrategy(new OriginalDestinationPropagateStrategy()); - } - } - - protected void createDestinationSource() { - try { - if (source == null) { - if (connection == null) { - Connection value = getConfiguration().getConnectionFactory().createConnection(); - if (value instanceof EnhancedConnection) { - connection = (EnhancedConnection) value; - } else { - throw new IllegalArgumentException("Created JMS Connection is not an EnhancedConnection: " + value); - } - connection.start(); - } - source = connection.getDestinationSource(); - } - } catch (Throwable t) { - LOG.info("Can't get destination source, endpoint completer will not work", t); - } - } - - @Override - protected void doStop() throws Exception { - if (source != null) { - source.stop(); - source = null; - } - if (connection != null) { - connection.close(); - connection = null; - } - for (Service s : pooledConnectionFactoryServiceList) { - s.stop(); - } - pooledConnectionFactoryServiceList.clear(); - for (SingleConnectionFactory s : singleConnectionFactoryList) { - s.destroy(); - } - singleConnectionFactoryList.clear(); - super.doStop(); - } - - @Override - public void setConfiguration(JmsConfiguration configuration) { - if (configuration instanceof ActiveMQConfiguration) { - ((ActiveMQConfiguration) configuration).setActiveMQComponent(this); - } - super.setConfiguration(configuration); - } - - @Override - protected JmsConfiguration createConfiguration() { - ActiveMQConfiguration answer = new ActiveMQConfiguration(); - answer.setActiveMQComponent(this); - return answer; - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java deleted file mode 100644 index af040a27e0..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQConfiguration.java +++ /dev/null @@ -1,203 +0,0 @@ -/** - * 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.component; - -import java.lang.reflect.Constructor; -import javax.jms.ConnectionFactory; - -import org.apache.activemq.Service; -import org.apache.activemq.spring.ActiveMQConnectionFactory; -import org.apache.camel.component.jms.JmsConfiguration; -import org.springframework.jms.connection.JmsTransactionManager; -import org.springframework.jms.connection.SingleConnectionFactory; -import org.springframework.jms.core.JmsTemplate; -import org.springframework.transaction.PlatformTransactionManager; - -/** - * - */ -public class ActiveMQConfiguration extends JmsConfiguration { - private ActiveMQComponent activeMQComponent; - private String brokerURL = ActiveMQConnectionFactory.DEFAULT_BROKER_URL; - private boolean useSingleConnection = false; - private boolean usePooledConnection = true; - private boolean trustAllPackages; - - public ActiveMQConfiguration() { - } - - public String getBrokerURL() { - return brokerURL; - } - - /** - * Sets the broker URL to use to connect to ActiveMQ using the - * ActiveMQ URI format - * - * @param brokerURL the URL of the broker. - */ - public void setBrokerURL(String brokerURL) { - this.brokerURL = brokerURL; - } - - public boolean isUseSingleConnection() { - return useSingleConnection; - } - - /** - * @deprecated - use JmsConfiguration#getUsername() - * @see JmsConfiguration#getUsername() - */ - @Deprecated - public String getUserName() { - return getUsername(); - } - - /** - * @deprecated - use JmsConfiguration#setUsername(String) - * @see JmsConfiguration#setUsername(String) - */ - @Deprecated - public void setUserName(String userName) { - setUsername(userName); - } - - /** - * Enables or disables whether a Spring {@link SingleConnectionFactory} will be used so that when - * messages are sent to ActiveMQ from outside of a message consuming thread, pooling will be used rather - * than the default with the Spring {@link JmsTemplate} which will create a new connection, session, producer - * for each message then close them all down again. - *

- * The default value is false and a pooled connection is used by default. - */ - public void setUseSingleConnection(boolean useSingleConnection) { - this.useSingleConnection = useSingleConnection; - } - - public boolean isUsePooledConnection() { - return usePooledConnection; - } - - /** - * Enables or disables whether a PooledConnectionFactory will be used so that when - * messages are sent to ActiveMQ from outside of a message consuming thread, pooling will be used rather - * than the default with the Spring {@link JmsTemplate} which will create a new connection, session, producer - * for each message then close them all down again. - *

- * The default value is true. Note that this requires an extra dependency on commons-pool2. - */ - public void setUsePooledConnection(boolean usePooledConnection) { - this.usePooledConnection = usePooledConnection; - } - - public boolean isTrustAllPackages() { - return trustAllPackages; - } - - /** - * ObjectMessage objects depend on Java serialization of marshal/unmarshal object payload. - * This process is generally considered unsafe as malicious payload can exploit the host system. - * That's why starting with versions 5.12.2 and 5.13.0, ActiveMQ enforces users to explicitly whitelist packages - * that can be exchanged using ObjectMessages. - *
- * This option can be set to true to trust all packages (eg whitelist is *). - *

- * See more details at: http://activemq.apache.org/objectmessage.html - */ - public void setTrustAllPackages(boolean trustAllPackages) { - this.trustAllPackages = trustAllPackages; - } - - /** - * Factory method to create a default transaction manager if one is not specified - */ - @Override - protected PlatformTransactionManager createTransactionManager() { - JmsTransactionManager answer = new JmsTransactionManager(getConnectionFactory()); - answer.afterPropertiesSet(); - return answer; - } - - protected void setActiveMQComponent(ActiveMQComponent activeMQComponent) { - this.activeMQComponent = activeMQComponent; - } - - @Override - protected ConnectionFactory createConnectionFactory() { - ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory(); - answer.setTrustAllPackages(trustAllPackages); - if (getUsername() != null) { - answer.setUserName(getUsername()); - } - if (getPassword() != null) { - answer.setPassword(getPassword()); - } - if (answer.getBeanName() == null) { - answer.setBeanName("Camel"); - } - answer.setBrokerURL(getBrokerURL()); - if (isUseSingleConnection()) { - SingleConnectionFactory scf = new SingleConnectionFactory(answer); - if (activeMQComponent != null) { - activeMQComponent.addSingleConnectionFactory(scf); - } - return scf; - } - else if (isUsePooledConnection()) { - ConnectionFactory pcf = createPooledConnectionFactory(answer); - if (activeMQComponent != null) { - activeMQComponent.addPooledConnectionFactoryService((Service) pcf); - } - return pcf; - } - else { - return answer; - } - } - - protected ConnectionFactory createPooledConnectionFactory(ActiveMQConnectionFactory connectionFactory) { - // lets not use classes directly to avoid a runtime dependency on commons-pool2 - // for folks not using this option - try { - Class type = loadClass("org.apache.activemq.pool.PooledConnectionFactory", getClass().getClassLoader()); - Constructor constructor = type.getConstructor(org.apache.activemq.ActiveMQConnectionFactory.class); - return (ConnectionFactory) constructor.newInstance(connectionFactory); - } - catch (Exception e) { - throw new RuntimeException("Failed to instantiate PooledConnectionFactory: " + e, e); - } - } - - private static Class loadClass(String name, ClassLoader loader) throws ClassNotFoundException { - ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - if (contextClassLoader != null) { - try { - return contextClassLoader.loadClass(name); - } - catch (ClassNotFoundException e) { - try { - return loader.loadClass(name); - } - catch (ClassNotFoundException e1) { - throw e1; - } - } - } else { - return loader.loadClass(name); - } - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQEndpoint.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQEndpoint.java deleted file mode 100644 index b5ab883769..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/ActiveMQEndpoint.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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.component; - -import org.apache.camel.component.jms.JmsConsumer; -import org.apache.camel.component.jms.JmsEndpoint; -import org.apache.camel.spi.UriEndpoint; - -/** - * The activemq component allows messages to be sent to (or consumed from) Apache ActiveMQ. - * - * This component extends the Camel JMS component. - */ -@UriEndpoint(scheme = "activemq", title = "ActiveMQ", syntax = "activemq:destinationType:destinationName", consumerClass = JmsConsumer.class, label = "messaging") -public class ActiveMQEndpoint extends JmsEndpoint { - - // needed for component documentation - -} \ No newline at end of file diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/CamelEndpointLoader.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/CamelEndpointLoader.java deleted file mode 100644 index f67b664a25..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/CamelEndpointLoader.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * - * 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.component; - -import java.util.Set; - -import javax.annotation.PostConstruct; - -import org.apache.activemq.advisory.DestinationEvent; -import org.apache.activemq.advisory.DestinationListener; -import org.apache.activemq.advisory.DestinationSource; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.Endpoint; -import org.apache.camel.component.jms.JmsEndpoint; -import org.apache.camel.component.jms.JmsQueueEndpoint; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A helper bean which populates a {@link CamelContext} with ActiveMQ Queue endpoints - * - * @org.apache.xbean.XBean - */ -public class CamelEndpointLoader implements CamelContextAware { - private static final transient Logger LOG = LoggerFactory.getLogger(CamelEndpointLoader.class); - private CamelContext camelContext; - private ActiveMQComponent component; - DestinationSource source; - - public CamelEndpointLoader() { - } - - public CamelEndpointLoader(CamelContext camelContext, DestinationSource source) { - this.camelContext = camelContext; - this.source = source; - } - - /** - * JSR-250 callback wrapper; converts checked exceptions to runtime exceptions - * - * delegates to afterPropertiesSet, done to prevent backwards incompatible signature change - * - * fix: AMQ-4676 - */ - @PostConstruct - private void postConstruct() { - try { - afterPropertiesSet(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - /** - * - * @throws Exception - * @org.apache.xbean.InitMethod - */ - public void afterPropertiesSet() throws Exception { - if (source != null) { - source.setDestinationListener(new DestinationListener() { - @Override - public void onDestinationEvent(DestinationEvent event) { - try { - ActiveMQDestination destination = event.getDestination(); - if (destination instanceof ActiveMQQueue) { - ActiveMQQueue queue = (ActiveMQQueue) destination; - if (event.isAddOperation()) { - addQueue(queue); - } else { - removeQueue(queue); - } - } else if (destination instanceof ActiveMQTopic) { - ActiveMQTopic topic = (ActiveMQTopic) destination; - if (event.isAddOperation()) { - addTopic(topic); - } else { - removeTopic(topic); - } - } - } catch (Exception e) { - LOG.warn("Caught: " + e, e); - } - } - }); - - Set queues = source.getQueues(); - for (ActiveMQQueue queue : queues) { - addQueue(queue); - } - - Set topics = source.getTopics(); - for (ActiveMQTopic topic : topics) { - addTopic(topic); - } - } - } - - // Properties - //------------------------------------------------------------------------- - @Override - public CamelContext getCamelContext() { - return camelContext; - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - public ActiveMQComponent getComponent() { - if (component == null) { - component = camelContext.getComponent("activemq", ActiveMQComponent.class); - } - return component; - } - - public void setComponent(ActiveMQComponent component) { - this.component = component; - } - - // Implementation methods - //------------------------------------------------------------------------- - - protected void addQueue(ActiveMQQueue queue) throws Exception { - String queueUri = getQueueUri(queue); - ActiveMQComponent jmsComponent = getComponent(); - Endpoint endpoint = new JmsQueueEndpoint(queueUri, jmsComponent, queue.getPhysicalName(), jmsComponent.getConfiguration()); - camelContext.addEndpoint(queueUri, endpoint); - } - - protected String getQueueUri(ActiveMQQueue queue) { - return "activemq:" + queue.getPhysicalName(); - } - - protected void removeQueue(ActiveMQQueue queue) throws Exception { - String queueUri = getQueueUri(queue); - // lur cache of endpoints so they will disappear in time - // this feature needs a new component api - list available endpoints - camelContext.removeEndpoints(queueUri); - } - - protected void addTopic(ActiveMQTopic topic) throws Exception { - String topicUri = getTopicUri(topic); - ActiveMQComponent jmsComponent = getComponent(); - Endpoint endpoint = new JmsEndpoint(topicUri, jmsComponent, topic.getPhysicalName(), true, jmsComponent.getConfiguration()); - camelContext.addEndpoint(topicUri, endpoint); - } - - protected String getTopicUri(ActiveMQTopic topic) { - return "activemq:topic:" + topic.getPhysicalName(); - } - - protected void removeTopic(ActiveMQTopic topic) throws Exception { - String topicUri = getTopicUri(topic); - // lur cache of endpoints so they will disappear in time - // this feature needs a new component api - list available endpoints - camelContext.removeEndpoints(topicUri); - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/OriginalDestinationPropagateStrategy.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/OriginalDestinationPropagateStrategy.java deleted file mode 100644 index 8f4c9fd32d..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/OriginalDestinationPropagateStrategy.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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.component; - -import javax.jms.Message; -import javax.jms.Session; - -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.camel.Exchange; -import org.apache.camel.component.jms.JmsMessage; -import org.apache.camel.component.jms.MessageCreatedStrategy; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A strategy to enrich JMS message with their original destination if the Camel - * route originates from a JMS destination. - */ -public class OriginalDestinationPropagateStrategy implements MessageCreatedStrategy { - - private static final transient Logger LOG = LoggerFactory.getLogger(OriginalDestinationPropagateStrategy.class); - - @Override - public void onMessageCreated(Message message, Session session, Exchange exchange, Throwable cause) { - if (exchange.getIn() instanceof JmsMessage) { - JmsMessage msg = exchange.getIn(JmsMessage.class); - Message jms = msg.getJmsMessage(); - if (jms != null && jms instanceof ActiveMQMessage && message instanceof ActiveMQMessage) { - ActiveMQMessage amq = (ActiveMQMessage) jms; - if (amq.getOriginalDestination() == null) { - ActiveMQDestination from = amq.getDestination(); - if (from != null) { - LOG.trace("Setting OriginalDestination: {} on {}", from, message); - ((ActiveMQMessage) message).setOriginalDestination(from); - } - } - } - } - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerComponent.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerComponent.java deleted file mode 100644 index c3003617d6..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerComponent.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * 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.component.broker; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.activemq.broker.view.MessageBrokerView; -import org.apache.activemq.broker.view.MessageBrokerViewRegistry; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.camel.ComponentConfiguration; -import org.apache.camel.Endpoint; -import org.apache.camel.component.jms.JmsConfiguration; -import org.apache.camel.impl.UriEndpointComponent; -import org.apache.camel.spi.EndpointCompleter; - -import static org.apache.camel.util.ObjectHelper.removeStartingCharacters; - -/** - * The Broker Camel component allows to use Camel - * routing to move messages through the broker. - */ -public class BrokerComponent extends UriEndpointComponent implements EndpointCompleter { - - public BrokerComponent() { - super(BrokerEndpoint.class); - } - - @Override - protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { - BrokerConfiguration brokerConfiguration = new BrokerConfiguration(); - setProperties(brokerConfiguration, parameters); - - byte destinationType = ActiveMQDestination.QUEUE_TYPE; - - if (remaining.startsWith(JmsConfiguration.QUEUE_PREFIX)) { - remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.QUEUE_PREFIX.length()), '/'); - } else if (remaining.startsWith(JmsConfiguration.TOPIC_PREFIX)) { - destinationType = ActiveMQDestination.TOPIC_TYPE; - remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.TOPIC_PREFIX.length()), '/'); - } else if (remaining.startsWith(JmsConfiguration.TEMP_QUEUE_PREFIX)) { - destinationType = ActiveMQDestination.TEMP_QUEUE_TYPE; - remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.TEMP_QUEUE_PREFIX.length()), '/'); - } else if (remaining.startsWith(JmsConfiguration.TEMP_TOPIC_PREFIX)) { - destinationType = ActiveMQDestination.TEMP_TOPIC_TYPE; - remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.TEMP_TOPIC_PREFIX.length()), '/'); - } - - ActiveMQDestination destination = ActiveMQDestination.createDestination(remaining, destinationType); - BrokerEndpoint brokerEndpoint = new BrokerEndpoint(uri, this, remaining, destination, brokerConfiguration); - setProperties(brokerEndpoint, parameters); - return brokerEndpoint; - } - - @Override - public List completeEndpointPath(ComponentConfiguration componentConfiguration, String completionText) { - String brokerName = String.valueOf(componentConfiguration.getParameter("brokerName")); - MessageBrokerView messageBrokerView = MessageBrokerViewRegistry.getInstance().lookup(brokerName); - if (messageBrokerView != null) { - String destinationName = completionText; - Set set = messageBrokerView.getQueues(); - if (completionText.startsWith("topic:")) { - set = messageBrokerView.getTopics(); - destinationName = completionText.substring(6); - } else if (completionText.startsWith("queue:")) { - destinationName = completionText.substring(6); - } - ArrayList answer = new ArrayList(); - for (ActiveMQDestination destination : set) { - if (destination.getPhysicalName().startsWith(destinationName)) { - answer.add(destination.getPhysicalName()); - } - } - return answer; - - } - return null; - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConfiguration.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConfiguration.java deleted file mode 100644 index f522f9b4df..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConfiguration.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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.component.broker; - -import org.apache.camel.spi.UriParam; -import org.apache.camel.spi.UriParams; - -@UriParams -public class BrokerConfiguration { - - @UriParam - private String brokerName = ""; - - public String getBrokerName() { - return brokerName; - } - - /** - * Name of the broker - */ - public void setBrokerName(String brokerName) { - this.brokerName = brokerName; - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConsumer.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConsumer.java deleted file mode 100644 index 1dc52ae46a..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerConsumer.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * 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.component.broker; - -import org.apache.activemq.broker.ProducerBrokerExchange; -import org.apache.activemq.broker.inteceptor.MessageInterceptor; -import org.apache.activemq.command.Message; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Processor; -import org.apache.camel.component.jms.JmsBinding; -import org.apache.camel.impl.DefaultConsumer; - -public class BrokerConsumer extends DefaultConsumer implements MessageInterceptor { - private final JmsBinding jmsBinding = new JmsBinding(); - - public BrokerConsumer(Endpoint endpoint, Processor processor) { - super(endpoint, processor); - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - ((BrokerEndpoint) getEndpoint()).addMessageInterceptor(this); - } - - @Override - protected void doStop() throws Exception { - ((BrokerEndpoint) getEndpoint()).removeMessageInterceptor(this); - super.doStop(); - } - - @Override - public void intercept(ProducerBrokerExchange producerExchange, Message message) { - Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOnly); - - exchange.setIn(new BrokerJmsMessage((javax.jms.Message) message, jmsBinding)); - exchange.setProperty(Exchange.BINDING, jmsBinding); - exchange.setProperty(BrokerEndpoint.PRODUCER_BROKER_EXCHANGE, producerExchange); - try { - getProcessor().process(exchange); - } catch (Exception e) { - exchange.setException(e); - } - - if (exchange.getException() != null) { - getExceptionHandler().handleException("Error processing intercepted message: " + message, exchange, exchange.getException()); - } - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerEndpoint.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerEndpoint.java deleted file mode 100644 index 5479022891..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerEndpoint.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * 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.component.broker; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.activemq.broker.ProducerBrokerExchange; -import org.apache.activemq.broker.inteceptor.MessageInterceptor; -import org.apache.activemq.broker.inteceptor.MessageInterceptorRegistry; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.Message; -import org.apache.camel.Consumer; -import org.apache.camel.MultipleConsumersSupport; -import org.apache.camel.Processor; -import org.apache.camel.Producer; -import org.apache.camel.Service; -import org.apache.camel.api.management.ManagedResource; -import org.apache.camel.impl.DefaultEndpoint; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.UriEndpoint; -import org.apache.camel.spi.UriParam; -import org.apache.camel.spi.UriPath; -import org.apache.camel.util.UnsafeUriCharactersEncoder; - -@ManagedResource(description = "Managed Camel Broker Endpoint") -@UriEndpoint(scheme = "broker", syntax = "broker:destination", consumerClass = BrokerConsumer.class, title = "Broker", label = "messaging") -public class BrokerEndpoint extends DefaultEndpoint implements MultipleConsumersSupport, Service { - - static final String PRODUCER_BROKER_EXCHANGE = "producerBrokerExchange"; - - private MessageInterceptorRegistry messageInterceptorRegistry; - private List messageInterceptorList = new CopyOnWriteArrayList(); - - @UriPath(name = "destination") @Metadata(required = "true") - private String destinationName; - private final ActiveMQDestination destination; - @UriParam - private final BrokerConfiguration configuration; - - public BrokerEndpoint(String uri, BrokerComponent component, String destinationName, ActiveMQDestination destination, BrokerConfiguration configuration) { - super(UnsafeUriCharactersEncoder.encode(uri), component); - this.destinationName = destinationName; - this.destination = destination; - this.configuration = configuration; - } - - @Override - public Producer createProducer() throws Exception { - BrokerProducer producer = new BrokerProducer(this); - return producer; - } - - @Override - public Consumer createConsumer(Processor processor) throws Exception { - BrokerConsumer consumer = new BrokerConsumer(this, processor); - configureConsumer(consumer); - return consumer; - } - - @Override - public boolean isSingleton() { - return false; - } - - @Override - public boolean isMultipleConsumersSupported() { - return true; - } - - public ActiveMQDestination getDestination() { - return destination; - } - - /** - * The name of the JMS destination - */ - public String getDestinationName() { - return destinationName; - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - messageInterceptorRegistry = MessageInterceptorRegistry.getInstance().get(configuration.getBrokerName()); - for (MessageInterceptor messageInterceptor : messageInterceptorList) { - addMessageInterceptor(messageInterceptor); - } - messageInterceptorList.clear(); - } - - @Override - protected void doStop() throws Exception { - super.doStop(); - } - - protected void addMessageInterceptor(MessageInterceptor messageInterceptor) { - if (isStarted()) { - messageInterceptorRegistry.addMessageInterceptor(destination, messageInterceptor); - } else { - messageInterceptorList.add(messageInterceptor); - } - } - - protected void removeMessageInterceptor(MessageInterceptor messageInterceptor) { - messageInterceptorRegistry.removeMessageInterceptor(destination, messageInterceptor); - } - - protected void inject(ProducerBrokerExchange producerBrokerExchange, Message message) throws Exception { - ProducerBrokerExchange pbe = producerBrokerExchange; - if (message != null) { - message.setDestination(destination); - if (producerBrokerExchange != null && producerBrokerExchange.getRegionDestination() != null){ - if (!producerBrokerExchange.getRegionDestination().getActiveMQDestination().equals(destination)){ - //The message broker will create a new ProducerBrokerExchange with the - //correct region broker set - pbe = null; - } - } - - messageInterceptorRegistry.injectMessage(pbe, message); - } - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerJmsMessage.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerJmsMessage.java deleted file mode 100644 index f77e97b2b2..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerJmsMessage.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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.component.broker; - -import javax.jms.Message; - -import org.apache.camel.component.jms.JmsBinding; -import org.apache.camel.component.jms.JmsMessage; -import org.apache.camel.component.jms.JmsMessageHelper; -import org.apache.camel.util.ObjectHelper; - -public class BrokerJmsMessage extends JmsMessage { - - public BrokerJmsMessage(Message jmsMessage, JmsBinding binding) { - super(jmsMessage, binding); - } - - @Override - public String toString() { - if (getJmsMessage() != null) { - return "BrokerJmsMessage[JMSMessageID: " + JmsMessageHelper.getJMSMessageID(getJmsMessage()); - } else { - return "BrokerJmsMessage@" + ObjectHelper.getIdentityHashCode(this); - } - } - - @Override - public void copyFrom(org.apache.camel.Message that) { - super.copyFrom(that); - if (that instanceof JmsMessage && getJmsMessage() == null) { - setJmsMessage(((JmsMessage) that).getJmsMessage()); - } - } - - @Override - public BrokerJmsMessage newInstance() { - return new BrokerJmsMessage(null, getBinding()); - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerProducer.java b/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerProducer.java deleted file mode 100644 index 82adad4691..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/broker/BrokerProducer.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * 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.component.broker; - -import org.apache.activemq.broker.ProducerBrokerExchange; -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.camel.AsyncCallback; -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.component.jms.JmsMessage; -import org.apache.camel.impl.DefaultAsyncProducer; - -import javax.jms.JMSException; -import java.util.Map; - -public class BrokerProducer extends DefaultAsyncProducer { - private final BrokerEndpoint brokerEndpoint; - - public BrokerProducer(BrokerEndpoint endpoint) { - super(endpoint); - brokerEndpoint = endpoint; - } - - @Override - public boolean process(Exchange exchange, AsyncCallback callback) { - try { - //In the middle of the broker - InOut doesn't make any sense - //so we do in only - return processInOnly(exchange, callback); - } catch (Throwable e) { - // must catch exception to ensure callback is invoked as expected - // to let Camel error handling deal with this - exchange.setException(e); - callback.done(true); - return true; - } - } - - protected boolean processInOnly(final Exchange exchange, final AsyncCallback callback) { - try { - ActiveMQMessage message = getMessage(exchange); - - if (message != null) { - message.setDestination(brokerEndpoint.getDestination()); - //if the ProducerBrokerExchange is null the broker will create it - ProducerBrokerExchange producerBrokerExchange = (ProducerBrokerExchange) exchange.getProperty(BrokerEndpoint.PRODUCER_BROKER_EXCHANGE); - - brokerEndpoint.inject(producerBrokerExchange, message); - } - } catch (Exception e) { - exchange.setException(e); - } - callback.done(true); - return true; - } - - private ActiveMQMessage getMessage(Exchange exchange) throws IllegalStateException, JMSException { - Message camelMessage = getMessageFromExchange(exchange); - checkOriginalMessage(camelMessage); - ActiveMQMessage result = (ActiveMQMessage) ((JmsMessage) camelMessage).getJmsMessage(); - applyNewHeaders(result, camelMessage.getHeaders()); - return result; - } - - private Message getMessageFromExchange(Exchange exchange) { - if (exchange.hasOut()) { - return exchange.getOut(); - } - - return exchange.getIn(); - } - - private void checkOriginalMessage(Message camelMessage) throws IllegalStateException { - /** - * We purposely don't want to support injecting messages half-way through - * broker processing - use the activemq camel component for that - but - * we will support changing message headers and destinations. - */ - - if (!(camelMessage instanceof JmsMessage)) { - throw new IllegalStateException("Not the original message from the broker " + camelMessage); - } - - javax.jms.Message message = ((JmsMessage) camelMessage).getJmsMessage(); - - if (!(message instanceof ActiveMQMessage)) { - throw new IllegalStateException("Not the original message from the broker " + message); - } - } - - private void applyNewHeaders(ActiveMQMessage message, Map headers) throws JMSException { - for (Map.Entry entry : headers.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - if(value == null) { - continue; - } - message.setObjectProperty(key, value.toString(), false); - } - } -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/component/package.html b/activemq-camel/src/main/java/org/apache/activemq/camel/component/package.html deleted file mode 100644 index 8dbba189ec..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/component/package.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -Defines the ActiveMQ Component for -Camel to provide great -Enterprise Integration Patterns -integration for ActiveMQ users. - - - - diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQConverter.java b/activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQConverter.java deleted file mode 100644 index 4c568cfa4e..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQConverter.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * 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.converter; - -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.camel.Converter; - -/** - * - */ -@Converter -public class ActiveMQConverter { - /** - * Converts a URL in ActiveMQ syntax to a destination such as to support - * "queue://foo.bar" or 'topic://bar.whatnot". Things default to queues if no scheme. - * - * This allows ActiveMQ destinations to be passed around as Strings and converted back again. - * - * @param name is the name of the queue or the full URI using prefixes queue:// or topic:// - * @return the ActiveMQ destination - */ - @Converter - public static ActiveMQDestination toDestination(String name) { - return ActiveMQDestination.createDestination(name, ActiveMQDestination.QUEUE_TYPE); - } - -} diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQMessageConverter.java b/activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQMessageConverter.java deleted file mode 100644 index 4dec6b364a..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/converter/ActiveMQMessageConverter.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * - * 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.converter; - -import java.io.Serializable; - -import javax.jms.JMSException; -import javax.jms.MessageListener; -import javax.jms.Message; - -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.activemq.command.ActiveMQObjectMessage; -import org.apache.activemq.command.ActiveMQTextMessage; -import org.apache.camel.Converter; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.component.jms.JmsBinding; -import org.apache.camel.component.jms.JmsEndpoint; - -/** - * - */ -@Converter -public class ActiveMQMessageConverter { - private JmsBinding binding = new JmsBinding(); - - /** - * Converts the inbound message exchange to an ActiveMQ JMS message - * - * @return the ActiveMQ message - */ - @Converter - public ActiveMQMessage toMessage(Exchange exchange) throws JMSException { - ActiveMQMessage message = createActiveMQMessage(exchange); - getBinding().appendJmsProperties(message, exchange); - return message; - } - - /** - * Allows a JMS {@link MessageListener} to be converted to a Camel {@link Processor} - * so that we can provide better - * Bean Integration so that we can use any JMS MessageListener in - * in Camel as a bean - * @param listener the JMS message listener - * @return a newly created Camel Processor which when invoked will invoke - * {@link MessageListener#onMessage(Message)} - */ - @Converter - public Processor toProcessor(final MessageListener listener) { - return new Processor() { - public void process(Exchange exchange) throws Exception { - Message message = toMessage(exchange); - listener.onMessage(message); - } - - @Override - public String toString() { - return "Processor of MessageListener: " + listener; - } - }; - } - - private static ActiveMQMessage createActiveMQMessage(Exchange exchange) throws JMSException { - Object body = exchange.getIn().getBody(); - if (body instanceof String) { - ActiveMQTextMessage answer = new ActiveMQTextMessage(); - answer.setText((String) body); - return answer; - } else if (body instanceof Serializable) { - ActiveMQObjectMessage answer = new ActiveMQObjectMessage(); - answer.setObject((Serializable) body); - return answer; - } else { - return new ActiveMQMessage(); - } - - } - - // Properties - //------------------------------------------------------------------------- - public JmsBinding getBinding() { - return binding; - } - - public void setBinding(JmsBinding binding) { - this.binding = binding; - } -} \ No newline at end of file diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/converter/package.html b/activemq-camel/src/main/java/org/apache/activemq/camel/converter/package.html deleted file mode 100644 index 54661c4dfe..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/converter/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -Defines the Type Converters for working -with JMS and ActiveMQ with Camel -Enterprise Integration Patterns - - - - diff --git a/activemq-camel/src/main/java/org/apache/activemq/camel/package.html b/activemq-camel/src/main/java/org/apache/activemq/camel/package.html deleted file mode 100644 index c6b8cd2629..0000000000 --- a/activemq-camel/src/main/java/org/apache/activemq/camel/package.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -Defines a JMS client which is capable of sending and receiving messages to -Apache Camel -endpoints to provide -Enterprise Integration Patterns -integration in any JMS client application. - - - diff --git a/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/TypeConverter b/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/TypeConverter deleted file mode 100644 index b3817f26e6..0000000000 --- a/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/TypeConverter +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. -# - -org.apache.activemq.camel.converter.ActiveMQConverter -org.apache.activemq.camel.converter.ActiveMQMessageConverter \ No newline at end of file diff --git a/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/activemq b/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/activemq deleted file mode 100644 index 7df5d454bd..0000000000 --- a/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/activemq +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# - -class=org.apache.activemq.camel.component.ActiveMQComponent diff --git a/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/broker b/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/broker deleted file mode 100644 index 186f4ab63b..0000000000 --- a/activemq-camel/src/main/resources/META-INF/services/org/apache/camel/component/broker +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# - -class=org.apache.activemq.camel.component.broker.BrokerComponent diff --git a/activemq-camel/src/test/data/message1.xml b/activemq-camel/src/test/data/message1.xml deleted file mode 100644 index d6a4645639..0000000000 --- a/activemq-camel/src/test/data/message1.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - James - Strachan - London - \ No newline at end of file diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java b/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java deleted file mode 100644 index f2f799e47a..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2240Test.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * 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 static org.junit.Assert.fail; - -import org.apache.activemq.camel.AMQ2611Test.Consumer; -import org.apache.activemq.camel.component.ActiveMQComponent; -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.junit.After; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AMQ2240Test { - - private static final Logger LOG = LoggerFactory.getLogger(AMQ2240Test.class); - - private CamelContext camelContext = null; - - @After - public void destroyCamelContext() throws Exception { - if (camelContext != null) { - camelContext.stop(); - camelContext = null; - } - } - - @Test - public void testBadVMTransportOptionsJMSPrefix() throws Exception { - - try{ - final String vmUri = "vm://localhost?" + - "jms.redeliveryPolicy.maximumRedeliveries=0&" + - "jms.redeliveryPolicy.initialRedeliveryDelay=500&" + - "jms.useAsyncSend=false&jms.sendTimeout=ABC&" + - "jms.maxXXXXReconnectAttempts=1&jms.timeout=3000"; - - LOG.info("creating context with bad URI: " + vmUri); - ActiveMQComponent amq = ActiveMQComponent.activeMQComponent(vmUri); - - amq.getConfiguration().getConnectionFactory(); - - fail("Should have received an exception from the bad URI."); - } catch(Exception e) { - // Expected - } - } - - @Test - public void testBadVMTransportOptionsBrokerPrefix() throws Exception { - try { - - final String vmUri = "vm://localhost?" + - "broker.XXX=foo&broker.persistent=XXX&broker.useJmx=false"; - - LOG.info("creating context with bad URI: " + vmUri); - ActiveMQComponent amq = ActiveMQComponent.activeMQComponent(vmUri); - - camelContext = new DefaultCamelContext(); - camelContext.addComponent("activemq", amq); - final String queueEndpointName = "activemq:queuetest.Queue"; - camelContext.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from(queueEndpointName).bean(Consumer.class, "consume"); - } - }); - - camelContext.start(); - final ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); - producerTemplate.sendBody(queueEndpointName, "message"); - - fail("Should have received an exception from the bad URI."); - } catch(Exception e) { - // Expected - } - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2611Test.java b/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2611Test.java deleted file mode 100644 index cfb3abb8e2..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/AMQ2611Test.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * 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 junit.framework.TestCase; - -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.camel.component.ActiveMQComponent; -import org.apache.camel.Body; -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AMQ2611Test extends TestCase { - - private static final String BROKER_URL = "tcp://localhost:61616"; - private static final String QUEUE_NAME = "test.queue"; - private static final Logger log = LoggerFactory.getLogger(AMQ2611Test.class); - private BrokerService brokerService = null; - private CamelContext camelContext = null; - - private void createBroker() throws Exception { - brokerService = new BrokerService(); - brokerService.addConnector(BROKER_URL); - brokerService.start(); - } - - public static class Consumer { - public void consume(@Body String message) { - log.info("consume message = " + message); - } - } - - private void createCamelContext() throws Exception { - log.info("creating context and sending message"); - camelContext = new DefaultCamelContext(); - camelContext.addComponent("activemq", ActiveMQComponent.activeMQComponent(BROKER_URL)); - final String queueEndpointName = "activemq:queue" + QUEUE_NAME; - camelContext.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from(queueEndpointName).bean(Consumer.class, "consume"); - } - }); - camelContext.start(); - final ProducerTemplate producerTemplate = camelContext.createProducerTemplate(); - producerTemplate.sendBody(queueEndpointName, "message"); - } - - private void destroyCamelContext() throws Exception { - log.info("destroying context"); - camelContext.stop(); - camelContext = null; - } - - public void testConnections() { - try { - createBroker(); - int i = 0; - while (i++ < 5) { - createCamelContext(); - Thread.sleep(1000); - destroyCamelContext(); - Thread.sleep(1000); - assertEquals(0, brokerService.getConnectorByName(BROKER_URL).getConnections().size()); - } - } catch (Exception e) { - log.warn("run", e); - } - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java deleted file mode 100644 index ffad7a5535..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePasswordTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * 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.camel.component.ActiveMQComponent; -import org.apache.activemq.camel.component.ActiveMQConfiguration; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.junit.Test; -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class ActiveMQComponentFactoryUserNamePasswordTest extends CamelSpringTestSupport { - - @Override - protected AbstractApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml"); - } - - @Test - public void testActiveMQ() throws Exception { - ActiveMQComponent comp = context.getComponent("activemq", ActiveMQComponent.class); - assertNotNull(comp); - - ActiveMQConfiguration config = (ActiveMQConfiguration) comp.getConfiguration(); - assertNotNull(config); - assertEquals("admin2", config.getUserName()); - assertEquals("secret2", config.getPassword()); - - getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); - - template.sendBody("activemq:queue:bar", "Hello World"); - - assertMockEndpointsSatisfied(); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java deleted file mode 100644 index 3d8048616e..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/ActiveMQComponentUserNamePasswordTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * 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.camel.component.ActiveMQComponent; -import org.apache.activemq.camel.component.ActiveMQConfiguration; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.junit.Test; -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class ActiveMQComponentUserNamePasswordTest extends CamelSpringTestSupport { - - @Override - protected AbstractApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml"); - } - - @Test - public void testActiveMQ() throws Exception { - ActiveMQComponent comp = context.getComponent("activemq", ActiveMQComponent.class); - assertNotNull(comp); - - ActiveMQConfiguration config = (ActiveMQConfiguration) comp.getConfiguration(); - assertNotNull(config); - assertEquals("admin", config.getUserName()); - assertEquals("secret", config.getPassword()); - - getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); - - template.sendBody("activemq:queue:foo", "Hello World"); - - assertMockEndpointsSatisfied(); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/BrokerPreShutdownHookTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/BrokerPreShutdownHookTest.java deleted file mode 100644 index 4b6122df93..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/BrokerPreShutdownHookTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * 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.camel.component.ActiveMQComponent; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -public class BrokerPreShutdownHookTest { - - static class TestProcessor implements Processor { - - boolean messageReceived; - - @Override - public void process(final Exchange exchange) throws Exception { - messageReceived = true; - } - } - - @Test - public void testShouldCleanlyShutdownCamelBeforeStoppingBroker() throws Exception { - final BrokerService broker = new BrokerService(); - broker.setBrokerName("testBroker"); - broker.setUseJmx(true); - broker.setPersistent(false); - broker.addConnector("vm://testBroker"); - - final DefaultCamelContext camel = new DefaultCamelContext(); - camel.setName("test-camel"); - - final CamelShutdownHook hook = new CamelShutdownHook(broker); - hook.setCamelContext(camel); - - broker.start(); - - camel.addComponent("testq", ActiveMQComponent.activeMQComponent("vm://testBroker?create=false")); - - final TestProcessor processor = new TestProcessor(); - camel.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("testq:test.in").delay(200).process(processor); - } - }); - camel.start(); - - final ProducerTemplate producer = camel.createProducerTemplate(); - producer.sendBody("testq:test.in", "Hi!"); - producer.stop(); - - broker.stop(); - - assertTrue("Message should be received", processor.messageReceived); - assertTrue("Camel context should be stopped", camel.isStopped()); - assertTrue("Broker should be stopped", broker.isStopped()); - - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java deleted file mode 100644 index 32d52ba39a..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - * 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.camel.CamelContext; -import org.apache.camel.EndpointInject; -import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class CamelDestinationExclusiveConsumerTest { - - @Autowired - protected CamelContext camelContext; - - @EndpointInject(uri = "mock:results") - protected MockEndpoint expectedEndpoint; - - @Test - public void testMocksAreValid() throws Exception { - expectedEndpoint.expectedMessageCount(1); - MockEndpoint.assertIsSatisfied(camelContext); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelEmbeddedBrokerTestSupport.java b/activemq-camel/src/test/java/org/apache/activemq/camel/CamelEmbeddedBrokerTestSupport.java deleted file mode 100644 index 0ac8421213..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelEmbeddedBrokerTestSupport.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * - * 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 java.util.Hashtable; - -import javax.naming.Context; - -import org.apache.activemq.EmbeddedBrokerTestSupport; -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.util.jndi.JndiContext; - -/** - * A helper class for test cases which use an embedded broker and use Camel to - * do the routing - * - */ -public abstract class CamelEmbeddedBrokerTestSupport extends EmbeddedBrokerTestSupport { - protected CamelContext camelContext; - protected ProducerTemplate template; - - @Override - protected void setUp() throws Exception { - bindAddress = "tcp://localhost:61616"; - super.setUp(); - camelContext = createCamelContext(); - addCamelRoutes(camelContext); - assertValidContext(camelContext); - camelContext.start(); - template = camelContext.createProducerTemplate(); - template.start(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - - if (template != null) { - template.stop(); - } - if (camelContext != null) { - camelContext.stop(); - } - } - - protected CamelContext createCamelContext() throws Exception { - return new DefaultCamelContext(createJndiContext()); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected Context createJndiContext() throws Exception { - return new JndiContext(new Hashtable()); - } - - protected void addCamelRoutes(CamelContext camelContext) throws Exception { - } - - /** - * Resolves a mandatory endpoint for the given URI or an exception is thrown - * - * @param uri - * the Camel URI to use to create or resolve an - * endpoint - * @return the endpoint - */ - protected Endpoint resolveMandatoryEndpoint(String uri) { - return resolveMandatoryEndpoint(camelContext, uri); - } - - /** - * Resolves a mandatory endpoint for the given URI and expected type or an - * exception is thrown - * - * @param uri - * the Camel URI to use to create or resolve an - * endpoint - * @return the endpoint - */ - protected T resolveMandatoryEndpoint(String uri, Class endpointType) { - return resolveMandatoryEndpoint(camelContext, uri, endpointType); - } - - /** - * Resolves an endpoint and asserts that it is found - */ - protected Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) { - Endpoint endpoint = context.getEndpoint(uri); - - assertNotNull("No endpoint found for URI: " + uri, endpoint); - - return endpoint; - } - - /** - * Resolves an endpoint and asserts that it is found - */ - protected T resolveMandatoryEndpoint(CamelContext context, String uri, Class endpointType) { - T endpoint = context.getEndpoint(uri, endpointType); - - assertNotNull("No endpoint found for URI: " + uri, endpoint); - - return endpoint; - } - - /** - * Resolves the mandatory Mock endpoint using a URI of the form - * mock:someName - * - * @param uri - * the URI which typically starts with "mock:" and has some name - * @return the mandatory mock endpoint or an exception is thrown if it could - * not be resolved - */ - protected MockEndpoint getMockEndpoint(String uri) { - return resolveMandatoryEndpoint(uri, MockEndpoint.class); - } - - /** - * Asserts that all the expectations of the Mock endpoints are valid - */ - protected void assertMockEndpointsSatisifed() throws InterruptedException { - MockEndpoint.assertIsSatisfied(camelContext); - } - - protected void assertValidContext(CamelContext context) { - assertNotNull("No context found!", context); - } -} 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 deleted file mode 100644 index 63e2c45c52..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsRequestReplyNobTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * 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.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"); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsTest.java deleted file mode 100644 index 99f70c100c..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelJmsTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * 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 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.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * - */ -public class CamelJmsTest extends CamelSpringTestSupport { - - private static final Logger LOG = LoggerFactory.getLogger(CamelJmsTest.class); - - protected String expectedBody = "world!"; - - @Test - public void testSendingViaJmsIsReceivedByCamel() throws Exception { - MockEndpoint result = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); - result.expectedBodiesReceived(expectedBody); - result.message(0).header("foo").isEqualTo("bar"); - - // lets create a message - Destination destination = getMandatoryBean(Destination.class, "sendTo"); - ConnectionFactory factory = getMandatoryBean(ConnectionFactory.class, "connectionFactory"); - - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(destination); - - // now lets send a message - ObjectMessage message = session.createObjectMessage(expectedBody); - message.setStringProperty("foo", "bar"); - producer.send(message); - - result.assertIsSatisfied(); - - LOG.info("Received message: " + result.getReceivedExchanges()); - } - - @Test - public void testConsumingViaJMSReceivesMessageFromCamel() throws Exception { - // lets create a message - Destination destination = getMandatoryBean(Destination.class, "consumeFrom"); - ConnectionFactory factory = getMandatoryBean(ConnectionFactory.class, "connectionFactory"); - ProducerTemplate template = getMandatoryBean(ProducerTemplate.class, "camelTemplate"); - assertNotNull("template is valid", template); - - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - LOG.info("Consuming from: " + destination); - MessageConsumer consumer = session.createConsumer(destination); - - // now lets send a message - template.sendBody("seda:consumer", expectedBody); - - Message message = consumer.receive(5000); - assertNotNull("Should have received a message from destination: " + destination, message); - - TextMessage textMessage = assertIsInstanceOf(TextMessage.class, message); - assertEquals("Message body", expectedBody, textMessage.getText()); - - LOG.info("Received message: " + message); - } - - protected int getExpectedRouteCount() { - return 0; - } - - protected ClassPathXmlApplicationContext createApplicationContext() { - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/spring.xml"); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelVMTransportRoutingTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/CamelVMTransportRoutingTest.java deleted file mode 100644 index 565739f7b8..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/CamelVMTransportRoutingTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * - * 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 javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - -import junit.framework.TestCase; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.TransportConnector; -import org.apache.activemq.camel.component.ActiveMQComponent; -import org.apache.activemq.util.ThreadTracker; -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.junit.Assert; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -// see: https://issues.apache.org/activemq/browse/AMQ-2966 -public class CamelVMTransportRoutingTest extends TestCase { - - private static final Logger log = LoggerFactory.getLogger(CamelVMTransportRoutingTest.class); - - private BrokerService broker = null; - private TransportConnector connector = null; - private CamelContext camelContext = null; - - private Connection senderConnection; - private Connection receiverConnection1; - private Connection receiverConnection2; - - private final String MSG_STRING = "MESSAGE-TEXT"; - private final String SENDER_TOPIC = "A"; - private final String RECEIVER_TOPIC = "B"; - - @SuppressWarnings("unused") - public void testSendReceiveWithCamelRouteIntercepting() throws Exception { - - final int MSG_COUNT = 1000; - - Session sendSession = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Session receiverSession1 = receiverConnection1.createSession(false, Session.AUTO_ACKNOWLEDGE); - Session receiverSession2 = receiverConnection2.createSession(false, Session.AUTO_ACKNOWLEDGE); - - Destination sendTo = sendSession.createTopic(SENDER_TOPIC); - Destination receiveFrom = receiverSession1.createTopic(RECEIVER_TOPIC); - - TextMessage message = sendSession.createTextMessage(MSG_STRING); - - MessageConsumer receiver1 = receiverSession1.createConsumer(receiveFrom); - MessageConsumer receiver2 = receiverSession2.createConsumer(receiveFrom); - - MessageProducer sender = sendSession.createProducer(sendTo); - for( int i = 0; i < MSG_COUNT; ++i ) { - sender.send(message); - } - - for( int i = 0; i < MSG_COUNT; ++i ) { - - log.debug("Attempting Received for Message #" + i); - TextMessage received1 = (TextMessage) receiver1.receive(5000); - Assert.assertNotNull(received1); - Assert.assertEquals(MSG_STRING, received1.getText()); - } - } - - protected BrokerService createBroker() throws Exception { - - BrokerService service = new BrokerService(); - service.setPersistent(false); - service.setUseJmx(false); - connector = service.addConnector("tcp://localhost:0"); - - return service; - } - - @Override - public void setUp() throws Exception { - - broker = createBroker(); - broker.start(); - broker.waitUntilStarted(); - - Thread.sleep(1000); - - createCamelContext(); - - ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory(connector.getConnectUri()); - senderConnection = connFactory.createConnection(); - receiverConnection1 = connFactory.createConnection(); - receiverConnection2 = connFactory.createConnection(); - - receiverConnection1.start(); - receiverConnection2.start(); - } - - @Override - public void tearDown() throws Exception { - - if( senderConnection != null ) { - senderConnection.close(); - } - - if( receiverConnection1 != null ) { - receiverConnection1.close(); - } - - if( receiverConnection2 != null ) { - receiverConnection2.close(); - } - - camelContext.stop(); - broker.stop(); - - ThreadTracker.result(); - } - - private void createCamelContext() throws Exception { - - final String fromEndpoint = "activemq:topic:" + SENDER_TOPIC; - final String toEndpoint = "activemq:topic:" + RECEIVER_TOPIC; - - log.info("creating context and sending message"); - camelContext = new DefaultCamelContext(); - camelContext.addComponent("activemq", - ActiveMQComponent.activeMQComponent("vm://localhost?create=false&waitForStart=10000")); - camelContext.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from(fromEndpoint).to(toEndpoint); - } - }); - camelContext.start(); - } - -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/DlqTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/DlqTest.java deleted file mode 100644 index 15ab50ea01..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/DlqTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * 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 javax.jms.Connection; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.util.Wait; - -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; - -public class DlqTest extends CamelSpringTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(DlqTest.class); - BrokerService broker = null; - int messageCount; - - @Test - public void testSendToDlq() throws Exception { - sendJMSMessageToKickOffRoute(); - - LOG.info("Wait for dlq message..."); - - assertTrue(Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return broker.getAdminView().getTotalEnqueueCount() == 2; - } - })); - } - - private void sendJMSMessageToKickOffRoute() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://testDlq"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(new ActiveMQQueue("fidEtpOrders")); - TextMessage message = session.createTextMessage("Some Text, messageCount:" + messageCount++); - message.setJMSCorrelationID("pleaseCorrelate"); - producer.send(message); - connection.close(); - } - - private BrokerService createBroker(boolean deleteAllMessages) throws Exception { - BrokerService brokerService = new BrokerService(); - brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages); - brokerService.setBrokerName("testDlq"); - brokerService.setAdvisorySupport(false); - brokerService.setDataDirectory("target/data"); - return brokerService; - } - - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - - deleteDirectory("target/data"); - - // make broker available to recovery processing on app context start - try { - broker = createBroker(true); - broker.start(); - } catch (Exception e) { - throw new RuntimeException("Failed to start broker", e); - } - - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/dlq.xml"); - } - - public static class CanError { - public String enrich(String body) throws Exception { - LOG.info("Got body: " + body); - throw new RuntimeException("won't enrich today!"); - } - } -} \ No newline at end of file diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsBridge.java b/activemq-camel/src/test/java/org/apache/activemq/camel/JmsBridge.java deleted file mode 100644 index 3a1af5153e..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsBridge.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * 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.ActiveMQConnectionFactory; -import org.apache.activemq.broker.*; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.command.ConnectionInfo; -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.*; -import javax.jms.Connection; -import java.util.concurrent.atomic.AtomicInteger; - -public class JmsBridge extends CamelSpringTestSupport { - - private static final Logger LOG = LoggerFactory.getLogger(JmsBridge.class); - - BrokerService brokerSub = null; - BrokerService brokerPub = null; - - int messageCount; - final int backLog = 50; - final int errorLimit = 10; - AtomicInteger sendCount = new AtomicInteger(); - AtomicInteger connectionCount = new AtomicInteger(); - - - @Test - public void testBridgeWorks() throws Exception { - sendJMSMessageToKickOffRoute(); - - consumeMessages(); - - LOG.info("ConnectionCount: " + connectionCount.get()); - assertEquals("x connections", 5 + errorLimit, connectionCount.get()); - } - - private void consumeMessages() throws Exception { - - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://sub"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer consumer = session.createConsumer(new ActiveMQQueue("to")); - - int messagesToConsume = messageCount; - while (messagesToConsume > 0) { - Message message = consumer.receive(5000); - if (message != null) { - messagesToConsume--; - } - } - } - - private void sendJMSMessageToKickOffRoute() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://pub"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(new ActiveMQQueue("from")); - - for (int i = 0; i < backLog; i++) { - TextMessage message = session.createTextMessage("Some Text, messageCount:" + messageCount++); - message.setIntProperty("seq", messageCount); - producer.send(message); - } - connection.close(); - } - - private BrokerService createBroker(String name, int port, boolean deleteAllMessages) throws Exception { - BrokerService brokerService = new BrokerService(); - brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages); - brokerService.setBrokerName(name); - brokerService.setAdvisorySupport(false); - brokerService.setUseJmx(false); - brokerService.setDataDirectory("target/data"); - if (port > 0) { - brokerService.addConnector("tcp://0.0.0.0:" + port); - } - return brokerService; - } - - @SuppressWarnings("unchecked") - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - - try { - brokerSub = createBroker("sub", 61617, true); - brokerSub.setPlugins(new BrokerPlugin[]{new BrokerPluginSupport() { - @Override - public void send(ProducerBrokerExchange producerExchange, org.apache.activemq.command.Message messageSend) throws Exception { - if (sendCount.incrementAndGet() <= errorLimit) { - throw new RuntimeException("You need to try send " + errorLimit + " times!"); - } - super.send(producerExchange, messageSend); - } - - @Override - public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception { - if (((TransportConnector) context.getConnector()).getConnectUri().getScheme().equals("tcp") && connectionCount.incrementAndGet() <= errorLimit) { - throw new SecurityException("You need to try connect " + errorLimit + " times!"); - } - super.addConnection(context, info); - } - }}); - brokerSub.start(); - - brokerPub = createBroker("pub", 61616, true); - brokerPub.start(); - - - } catch (Exception e) { - throw new RuntimeException("Failed to start broker", e); - } - - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/jmsBridge.xml"); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsConsumeSendTransacted.java b/activemq-camel/src/test/java/org/apache/activemq/camel/JmsConsumeSendTransacted.java deleted file mode 100644 index 346b7de495..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsConsumeSendTransacted.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * 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 javax.jms.Connection; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.junit.Test; -import org.springframework.context.support.AbstractXmlApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class JmsConsumeSendTransacted extends CamelSpringTestSupport { - BrokerService broker = null; - int messageCount; - - - @Test - public void testTransactedRoute() throws Exception { - sendJMSMessageToKickOffRoute(); - - // camel route will use a single transaction for send and and ack - consumeMessages(); - } - - private void consumeMessages() throws Exception { - - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://testTran"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer consumer = session.createConsumer(new ActiveMQQueue("to")); - - int messagesToConsume = messageCount; - while (messagesToConsume > 0) { - Message message = consumer.receive(5000); - if (message != null) { - messagesToConsume--; - } - } - } - - private void sendJMSMessageToKickOffRoute() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://testTran"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(new ActiveMQQueue("from")); - TextMessage message = session.createTextMessage("Some Text, messageCount:" + messageCount++); - message.setIntProperty("seq", messageCount); - producer.send(message); - connection.close(); - } - - private BrokerService createBroker(boolean deleteAllMessages) throws Exception { - BrokerService brokerService = new BrokerService(); - brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages); - brokerService.setBrokerName("testTran"); - brokerService.setAdvisorySupport(false); - brokerService.setUseJmx(false); - brokerService.setDataDirectory("target/data"); - brokerService.addConnector("tcp://0.0.0.0:61616"); - return brokerService; - } - - @SuppressWarnings("unchecked") - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - try { - broker = createBroker(true); - broker.start(); - } catch (Exception e) { - throw new RuntimeException("Failed to start broker", e); - } - - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/jmsConsumeSendTransacted.xml"); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXARollbackTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXARollbackTest.java deleted file mode 100644 index c54c8f50e4..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXARollbackTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * 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 java.sql.ResultSet; -import java.sql.SQLException; -import javax.jms.Connection; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.sql.DataSource; -import javax.transaction.TransactionManager; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.util.Wait; -import org.apache.camel.Exchange; -import org.apache.camel.component.jms.JmsMessage; -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 org.springframework.transaction.jta.JtaTransactionManager; - -/** - * shows rollback and redelivery dlq respected with external tm - */ -public class JmsJdbcXARollbackTest extends CamelSpringTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(JmsJdbcXARollbackTest.class); - BrokerService broker = null; - int messageCount; - - public java.sql.Connection initDb() throws Exception { - String createStatement = - "CREATE TABLE SCP_INPUT_MESSAGES (" + - "id int NOT NULL GENERATED ALWAYS AS IDENTITY, " + - "messageId varchar(96) NOT NULL, " + - "messageCorrelationId varchar(96) NOT NULL, " + - "messageContent varchar(2048) NOT NULL, " + - "PRIMARY KEY (id) )"; - - java.sql.Connection conn = getJDBCConnection(); - try { - conn.createStatement().execute(createStatement); - } catch (SQLException alreadyExists) { - log.info("ex on create tables", alreadyExists); - } - - try { - conn.createStatement().execute("DELETE FROM SCP_INPUT_MESSAGES"); - } catch (SQLException ex) { - log.info("ex on create delete all", ex); - } - - return conn; - } - - private java.sql.Connection getJDBCConnection() throws Exception { - DataSource dataSource = getMandatoryBean(DataSource.class, "managedDataSourceWithRecovery"); - return dataSource.getConnection(); - } - - private int dumpDb(java.sql.Connection jdbcConn) throws Exception { - int count = 0; - ResultSet resultSet = jdbcConn.createStatement().executeQuery("SELECT * FROM SCP_INPUT_MESSAGES"); - while (resultSet.next()) { - count++; - log.info("message - seq:" + resultSet.getInt(1) - + ", id: " + resultSet.getString(2) - + ", corr: " + resultSet.getString(3) - + ", content: " + resultSet.getString(4)); - } - return count; - } - - @Test - public void testConsumeRollback() throws Exception { - java.sql.Connection jdbcConn = initDb(); - - initTMRef(); - sendJMSMessageToKickOffRoute(); - - // should go to dlq eventually - Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return consumedFrom(SharedDeadLetterStrategy.DEFAULT_DEAD_LETTER_QUEUE_NAME); - } - }); - assertEquals("message in db, commit to db worked", 0, dumpDb(jdbcConn)); - assertFalse("Nothing to to out q", consumedFrom("scp_transacted_out")); - - } - - private boolean consumedFrom(String qName) throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://testXA"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer consumer = session.createConsumer(new ActiveMQQueue(qName)); - Message message = consumer.receive(500); - LOG.info("Got from queue:{} {}", qName, message); - connection.close(); - return message != null; - } - - static TransactionManager[] transactionManager = new TransactionManager[1]; - private void initTMRef() { - transactionManager[0] = getMandatoryBean(JtaTransactionManager.class, "jtaTransactionManager").getTransactionManager(); - - } - - private void sendJMSMessageToKickOffRoute() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://testXA"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(new ActiveMQQueue("scp_transacted")); - TextMessage message = session.createTextMessage("Some Text, messageCount:" + messageCount++); - message.setJMSCorrelationID("pleaseCorrelate"); - producer.send(message); - connection.close(); - } - - private BrokerService createBroker(boolean deleteAllMessages) throws Exception { - BrokerService brokerService = new BrokerService(); - brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages); - brokerService.setBrokerName("testXA"); - brokerService.setAdvisorySupport(false); - brokerService.setUseJmx(false); - brokerService.setDataDirectory("target/data"); - brokerService.addConnector("tcp://0.0.0.0:61616"); - return brokerService; - } - - @SuppressWarnings("unchecked") - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - - deleteDirectory("target/data/howl"); - - // make broker available to recovery processing on app context start - try { - broker = createBroker(true); - broker.start(); - } catch (Exception e) { - throw new RuntimeException("Failed to start broker", e); - } - - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/jmsXajdbcRollback.xml"); - } - - public static class MarkRollbackOnly { - public String enrich(Exchange exchange) throws Exception { - LOG.info("Got exchange: " + exchange); - LOG.info("Got message: " + ((JmsMessage)exchange.getIn()).getJmsMessage()); - - LOG.info("Current tx: " + transactionManager[0].getTransaction()); - LOG.info("Marking rollback only..."); - transactionManager[0].getTransaction().setRollbackOnly(); - return "Some Text"; - } - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXATest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXATest.java deleted file mode 100644 index b96ceec1eb..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/JmsJdbcXATest.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * 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 java.sql.ResultSet; -import java.sql.SQLException; -import java.util.concurrent.Executors; - -import javax.jms.Connection; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - -import javax.sql.DataSource; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerPlugin; -import org.apache.activemq.broker.BrokerPluginSupport; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.ConnectionContext; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.command.TransactionId; -import org.apache.activemq.util.Wait; -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; - -/** - * shows broker 'once only delivery' and recovery with XA - */ -public class JmsJdbcXATest extends CamelSpringTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(JmsJdbcXATest.class); - BrokerService broker = null; - int messageCount; - - public java.sql.Connection initDb() throws Exception { - String createStatement = - "CREATE TABLE SCP_INPUT_MESSAGES (" + - "id int NOT NULL GENERATED ALWAYS AS IDENTITY, " + - "messageId varchar(96) NOT NULL, " + - "messageCorrelationId varchar(96) NOT NULL, " + - "messageContent varchar(2048) NOT NULL, " + - "PRIMARY KEY (id) )"; - - java.sql.Connection conn = getJDBCConnection(); - try { - conn.createStatement().execute(createStatement); - } catch (SQLException alreadyExists) { - log.info("ex on create tables", alreadyExists); - } - - try { - conn.createStatement().execute("DELETE FROM SCP_INPUT_MESSAGES"); - } catch (SQLException ex) { - log.info("ex on create delete all", ex); - } - - return conn; - } - - private java.sql.Connection getJDBCConnection() throws Exception { - DataSource dataSource = getMandatoryBean(DataSource.class, "managedDataSourceWithRecovery"); - return dataSource.getConnection(); - } - - private int dumpDb(java.sql.Connection jdbcConn) throws Exception { - int count = 0; - ResultSet resultSet = jdbcConn.createStatement().executeQuery("SELECT * FROM SCP_INPUT_MESSAGES"); - while (resultSet.next()) { - count++; - log.info("message - seq:" + resultSet.getInt(1) - + ", id: " + resultSet.getString(2) - + ", corr: " + resultSet.getString(3) - + ", content: " + resultSet.getString(4)); - } - return count; - } - - @Test - public void testRecoveryCommit() throws Exception { - java.sql.Connection jdbcConn = initDb(); - - sendJMSMessageToKickOffRoute(); - LOG.info("waiting for route to kick in, it will kill the broker on first 2pc commit"); - // will be stopped by the plugin on first 2pc commit - broker.waitUntilStopped(); - assertEquals("message in db, commit to db worked", 1, dumpDb(jdbcConn)); - - LOG.info("Broker stopped, restarting..."); - broker = createBroker(false); - broker.start(); - broker.waitUntilStarted(); - assertEquals("pending transactions", 1, broker.getBroker().getPreparedTransactions(null).length); - - // TM stays actively committing first message ack which won't get redelivered - xa once only delivery - LOG.info("waiting for recovery to complete"); - assertTrue("recovery complete in time", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return broker.getBroker().getPreparedTransactions(null).length == 0; - } - })); - // verify recovery complete - assertEquals("recovery complete", 0, broker.getBroker().getPreparedTransactions(null).length); - - final java.sql.Connection freshConnection = getJDBCConnection(); - assertTrue("did not get replay", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return 1 == dumpDb(freshConnection); - } - })); - assertEquals("still one message in db", 1, dumpDb(freshConnection)); - - // let once complete ok - sendJMSMessageToKickOffRoute(); - - assertTrue("got second message", Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return 2 == dumpDb(freshConnection); - } - })); - assertEquals("two messages in db", 2, dumpDb(freshConnection)); - } - - private void sendJMSMessageToKickOffRoute() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://testXA"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(new ActiveMQQueue("scp_transacted")); - TextMessage message = session.createTextMessage("Some Text, messageCount:" + messageCount++); - message.setJMSCorrelationID("pleaseCorrelate"); - producer.send(message); - connection.close(); - } - - private BrokerService createBroker(boolean deleteAllMessages) throws Exception { - BrokerService brokerService = new BrokerService(); - brokerService.setDeleteAllMessagesOnStartup(deleteAllMessages); - brokerService.setBrokerName("testXA"); - brokerService.setAdvisorySupport(false); - brokerService.setUseJmx(false); - brokerService.setDataDirectory("target/data"); - brokerService.addConnector("tcp://0.0.0.0:61616"); - return brokerService; - } - - @SuppressWarnings("unchecked") - @Override - protected AbstractXmlApplicationContext createApplicationContext() { - - deleteDirectory("target/data/howl"); - - // make broker available to recovery processing on app context start - try { - broker = createBroker(true); - broker.setPlugins(new BrokerPlugin[]{ - new BrokerPluginSupport() { - @Override - public void commitTransaction(ConnectionContext context, - TransactionId xid, boolean onePhase) throws Exception { - if (onePhase) { - super.commitTransaction(context, xid, onePhase); - } else { - // die before doing the commit - // so commit will hang as if reply is lost - context.setDontSendReponse(true); - Executors.newSingleThreadExecutor().execute(new Runnable() { - @Override - public void run() { - LOG.info("Stopping broker post commit..."); - try { - broker.stop(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - } - } - }); - broker.start(); - } catch (Exception e) { - throw new RuntimeException("Failed to start broker", e); - } - - return new ClassPathXmlApplicationContext("org/apache/activemq/camel/jmsXajdbc.xml"); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java deleted file mode 100644 index 8cb5e0f3dd..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * 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.ActiveMQConnectionFactory; -import org.apache.camel.Exchange; -import org.apache.camel.component.jms.JmsBinding; -import org.apache.camel.component.jms.JmsMessage; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.spring.CamelSpringTestSupport; -import org.apache.camel.util.ExchangeHelper; -import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; -import org.junit.Test; -import org.springframework.context.support.AbstractApplicationContext; - -import javax.jms.*; -import java.util.concurrent.TimeUnit; - -public class ObjectMessageTest extends CamelSpringTestSupport { - - @Test - public void testUntrusted() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost"); - Connection conn = factory.createConnection(); - conn.start(); - Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = sess.createProducer(sess.createTopic("foo")); - ObjectMessage msg = sess.createObjectMessage(); - ObjectPayload payload = new ObjectPayload(); - payload.payload = "test"; - msg.setObject(payload); - producer.send(msg); - - Thread.sleep(1000); - - MockEndpoint resultActiveMQ = resolveMandatoryEndpoint("mock:result-activemq", MockEndpoint.class); - resultActiveMQ.expectedMessageCount(1); - resultActiveMQ.assertIsSatisfied(); - assertCorrectObjectReceived(resultActiveMQ); - - MockEndpoint resultTrusted = resolveMandatoryEndpoint("mock:result-trusted", MockEndpoint.class); - resultTrusted.expectedMessageCount(1); - resultTrusted.assertIsSatisfied(); - assertCorrectObjectReceived(resultTrusted); - - MockEndpoint resultCamel = resolveMandatoryEndpoint("mock:result-camel", MockEndpoint.class); - resultCamel.expectedMessageCount(1); - resultCamel.assertIsNotSatisfied(); - - MockEndpoint resultEmpty = resolveMandatoryEndpoint("mock:result-empty", MockEndpoint.class); - resultEmpty.expectedMessageCount(1); - resultEmpty.assertIsNotSatisfied(); - - } - - protected void assertCorrectObjectReceived(MockEndpoint result) { - Exchange exchange = result.getReceivedExchanges().get(0); - // This should be a JMS Exchange - assertNotNull(ExchangeHelper.getBinding(exchange, JmsBinding.class)); - JmsMessage in = (JmsMessage) exchange.getIn(); - assertNotNull(in); - assertIsInstanceOf(ObjectMessage.class, in.getJmsMessage()); - - ObjectPayload received = exchange.getIn().getBody(ObjectPayload.class); - assertEquals("test", received.payload); - } - - @Override - protected AbstractApplicationContext createApplicationContext() { - AbstractApplicationContext context = new ClassPathXmlApplicationContext("org/apache/activemq/camel/jms-object-message.xml"); - return context; - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java deleted file mode 100644 index 301d03cb6d..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectPayload.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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 java.io.Serializable; - -public class ObjectPayload implements Serializable { - private static final long serialVersionUID = 121277L; - - public String payload; -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java b/activemq-camel/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java deleted file mode 100644 index 384a4a90c7..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/SetGroupIdProcessor.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - * 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.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.Message; - -/** - * - */ -public class SetGroupIdProcessor implements Processor { - public void process(Exchange exchange) throws Exception { - // lets copy the IN to the OUT message - Message out = exchange.getOut(); - out.copyFrom(exchange.getIn()); - - // now lets set a header - out.setHeader("JMSXGroupID", "ABC"); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java deleted file mode 100644 index 113e046aac..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/SetHeaderTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * 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 java.util.List; - -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.EndpointInject; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.util.ObjectHelper; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * - */ - -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -public class SetHeaderTest { - private static final transient Logger LOG = LoggerFactory.getLogger(SetHeaderTest.class); - - @Autowired - protected CamelContext camelContext; - - @EndpointInject(uri = "mock:results") - protected MockEndpoint expectedEndpoint; - - @Test - public void testMocksAreValid() throws Exception { - // lets add more expectations - expectedEndpoint.expectedMessageCount(1); - expectedEndpoint.message(0).header("JMSXGroupID").isEqualTo("ABC"); - - MockEndpoint.assertIsSatisfied(camelContext); - - // lets dump the received messages - List list = expectedEndpoint.getReceivedExchanges(); - for (Exchange exchange : list) { - Object body = exchange.getIn().getBody(); - LOG.debug("Received: body: " + body + " of type: " + ObjectHelper.className(body) + " on: " + exchange); - } - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java deleted file mode 100644 index 7448d89f8b..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/TransactedConsumeTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * 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 java.util.concurrent.atomic.AtomicLong; -import javax.jms.Connection; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.broker.region.policy.PolicyEntry; -import org.apache.activemq.broker.region.policy.PolicyMap; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.command.ActiveMQTextMessage; -import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter; -import org.apache.activemq.util.Wait; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.component.jms.JmsMessage; -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; - -public class TransactedConsumeTest extends CamelSpringTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(TransactedConsumeTest.class); - BrokerService broker = null; - int messageCount = 100000; - - @Test - public void testConsume() throws Exception { - - LOG.info("Wait for dequeue message..."); - - assertTrue(Wait.waitFor(new Wait.Condition() { - @Override - public boolean isSatisified() throws Exception { - return broker.getAdminView().getTotalDequeueCount() >= messageCount; - } - }, 20 * 60 * 1000)); - long duration = System.currentTimeMillis() - firstConsumed.get(); - LOG.info("Done message consumption in " + duration + "millis"); - } - - private void sendJMSMessageToKickOffRoute() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://test"); - factory.setWatchTopicAdvisories(false); - Connection connection = factory.createConnection(); - connection.start(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(new ActiveMQQueue("scp_transacted")); - for (int i=0; i"; - protected ActiveMQQueue replyQueue = new ActiveMQQueue("test.reply.queue"); - protected String correlationID = "ABC-123"; - protected String messageType = getClass().getName(); - - @Test - public void testForwardingAMessageAcrossJMSKeepingCustomJMSHeaders() throws Exception { - MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); - - resultEndpoint.expectedBodiesReceived(expectedBody); - AssertionClause firstMessageExpectations = resultEndpoint.message(0); - firstMessageExpectations.header("cheese").isEqualTo(123); - firstMessageExpectations.header("JMSReplyTo").isEqualTo(replyQueue); - firstMessageExpectations.header("JMSCorrelationID").isEqualTo(correlationID); - firstMessageExpectations.header("JMSType").isEqualTo(messageType); - - template.sendBodyAndHeader("activemq:test.a", expectedBody, "cheese", 123); - - resultEndpoint.assertIsSatisfied(); - - List list = resultEndpoint.getReceivedExchanges(); - Exchange exchange = list.get(0); - Object replyTo = exchange.getIn().getHeader("JMSReplyTo"); - LOG.info("Reply to is: " + replyTo); - Destination destination = assertIsInstanceOf(Destination.class, replyTo); - assertEquals("ReplyTo", replyQueue.toString(), destination.toString()); - } - - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - camelContext.setTracing(true); - - // START SNIPPET: example - camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false")); - // END SNIPPET: example - - return camelContext; - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("activemq:test.a").process(new Processor() { - public void process(Exchange exchange) throws Exception { - // lets set the custom JMS headers using the Camel API - exchange.getIn().setHeader("JMSReplyTo", replyQueue); - exchange.getIn().setHeader("JMSCorrelationID", correlationID); - exchange.getIn().setHeader("JMSType", messageType); - } - }).to("activemq:test.b?preserveMessageQos=true"); - - from("activemq:test.b").to("mock:result"); - - } - }; - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQOriginalDestinationTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQOriginalDestinationTest.java deleted file mode 100644 index 5e2bea120c..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQOriginalDestinationTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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.component; - -import javax.jms.Message; - -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jms.JmsMessage; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; - -import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent; - -public class ActiveMQOriginalDestinationTest extends CamelTestSupport { - - @Test - public void testActiveMQOriginalDestination() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMessageCount(1); - - template.sendBody("activemq:queue:foo", "Hello World"); - - assertMockEndpointsSatisfied(); - - // consume from bar - Exchange out = consumer.receive("activemq:queue:bar", 5000); - assertNotNull(out); - - // and we should have foo as the original destination - JmsMessage msg = out.getIn(JmsMessage.class); - Message jms = msg.getJmsMessage(); - ActiveMQMessage amq = assertIsInstanceOf(ActiveMQMessage.class, jms); - ActiveMQDestination original = amq.getOriginalDestination(); - assertNotNull(original); - assertEquals("foo", original.getPhysicalName()); - assertEquals("Queue", original.getDestinationTypeAsString()); - } - - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false")); - return camelContext; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("activemq:queue:foo") - .to("activemq:queue:bar") - .to("mock:result"); - } - }; - } - -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQReplyToHeaderUsingConverterTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQReplyToHeaderUsingConverterTest.java deleted file mode 100644 index 23f561b89f..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQReplyToHeaderUsingConverterTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 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.component; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.jms.Destination; - -import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent; -import org.apache.activemq.camel.converter.ActiveMQConverter; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.AssertionClause; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - */ -public class ActiveMQReplyToHeaderUsingConverterTest extends CamelTestSupport { - private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQReplyToHeaderUsingConverterTest.class); - protected Object expectedBody = ""; - protected String replyQueueName = "queue://test.my.reply.queue"; - protected String correlationID = "ABC-123"; - protected String groupID = "GROUP-XYZ"; - protected String messageType = getClass().getName(); - protected boolean useReplyToHeader = false; - - @Test - public void testSendingAMessageFromCamelSetsCustomJmsHeaders() throws Exception { - MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class); - - resultEndpoint.expectedBodiesReceived(expectedBody); - AssertionClause firstMessage = resultEndpoint.message(0); - firstMessage.header("cheese").isEqualTo(123); - firstMessage.header("JMSCorrelationID").isEqualTo(correlationID); - if (useReplyToHeader) { - firstMessage.header("JMSReplyTo").isEqualTo(ActiveMQConverter.toDestination(replyQueueName)); - } - firstMessage.header("JMSType").isEqualTo(messageType); - firstMessage.header("JMSXGroupID").isEqualTo(groupID); - - Map headers = new HashMap(); - headers.put("cheese", 123); - if (useReplyToHeader) { - headers.put("JMSReplyTo", replyQueueName); - } - headers.put("JMSCorrelationID", correlationID); - headers.put("JMSType", messageType); - headers.put("JMSXGroupID", groupID); - template.sendBodyAndHeaders("activemq:test.a", expectedBody, headers); - - resultEndpoint.assertIsSatisfied(); - - List list = resultEndpoint.getReceivedExchanges(); - Exchange exchange = list.get(0); - Message in = exchange.getIn(); - Object replyTo = in.getHeader("JMSReplyTo"); - LOG.info("Reply to is: " + replyTo); - if (useReplyToHeader) { - Destination destination = assertIsInstanceOf(Destination.class, replyTo); - assertEquals("ReplyTo", replyQueueName, destination.toString()); - } - - assertMessageHeader(in, "cheese", 123); - assertMessageHeader(in, "JMSCorrelationID", correlationID); - assertMessageHeader(in, "JMSType", messageType); - assertMessageHeader(in, "JMSXGroupID", groupID); - } - - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - // START SNIPPET: example - camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false")); - // END SNIPPET: example - - return camelContext; - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("activemq:test.a").to("activemq:test.b?preserveMessageQos=true"); - - from("activemq:test.b").to("mock:result"); - } - }; - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQRouteTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQRouteTest.java deleted file mode 100644 index 73c693c969..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQRouteTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * 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.component; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; - -import org.apache.camel.component.jms.JmsEndpoint; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Before; -import org.junit.Test; -import org.springframework.jms.connection.JmsTransactionManager; -import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent; - -/** - * - */ -public class ActiveMQRouteTest extends CamelTestSupport { - private static final String EXPECTED_BODY = "Hello there!"; - protected MockEndpoint resultEndpoint; - protected String startEndpointUri = "activemq:queue:test.a"; - - @Test - public void testJmsRouteWithTextMessage() throws Exception { - resultEndpoint.expectedBodiesReceived(EXPECTED_BODY); - resultEndpoint.message(0).header("cheese").isEqualTo(123); - - sendExchange(EXPECTED_BODY); - - resultEndpoint.assertIsSatisfied(); - } - - protected void sendExchange(final Object expectedBody) { - template.sendBodyAndHeader(startEndpointUri, expectedBody, "cheese", 123); - } - - @Before - public void setUp() throws Exception { - super.setUp(); - - resultEndpoint = (MockEndpoint) context.getEndpoint("mock:result"); - } - - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - // START SNIPPET: example - camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false")); - // END SNIPPET: example - - return camelContext; - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from(startEndpointUri).to("activemq:queue:test.b"); - from("activemq:queue:test.b").to("mock:result"); - - JmsEndpoint endpoint1 = (JmsEndpoint) endpoint("activemq:topic:quote.IONA"); - endpoint1.getConfiguration().setTransactionManager(new JmsTransactionManager()); - endpoint1.getConfiguration().setTransacted(true); - from(endpoint1).to("mock:transactedClient"); - - JmsEndpoint endpoint2 = (JmsEndpoint) endpoint("activemq:topic:quote.IONA"); - endpoint2.getConfiguration().setTransacted(false); - from(endpoint2).to("mock:nonTrasnactedClient"); - } - }; - } -} \ No newline at end of file diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/AdvisoryConsumerExample.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/AdvisoryConsumerExample.java deleted file mode 100644 index 00debc9fd6..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/AdvisoryConsumerExample.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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.component; - - -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.activemq.command.DataStructure; -import org.apache.activemq.command.DestinationInfo; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.Message; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jms.JmsMessage; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; - -/** - * - */ -public class AdvisoryConsumerExample extends CamelTestSupport { - - @Test - public void testWorks() throws Exception { - // lets create a new queue - template.sendBody("activemq:NewQueue." + System.currentTimeMillis(), "world!"); - - Thread.sleep(10000); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - // lets force the creation of a queue up front - from("activemq:InitialQueue").to("log:Messages"); - - from("activemq:topic:ActiveMQ.Advisory.Queue?cacheLevelName=CACHE_CONSUMER").process(new Processor() { - public void process(Exchange exchange) throws Exception { - Message in = exchange.getIn(); - if (in instanceof JmsMessage) { - JmsMessage jmsMessage = (JmsMessage) in; - javax.jms.Message value = jmsMessage.getJmsMessage(); - if (value instanceof ActiveMQMessage) { - ActiveMQMessage activeMQMessage = (ActiveMQMessage) value; - DataStructure structure = activeMQMessage.getDataStructure(); - if (structure instanceof DestinationInfo) { - DestinationInfo destinationInfo = (DestinationInfo) structure; - System.out.println("Received: " + destinationInfo); - } - } - } - } - }); - } - }; - } -} \ No newline at end of file diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/AutoExposeQueuesInCamelTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/AutoExposeQueuesInCamelTest.java deleted file mode 100644 index bb1016e6b4..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/AutoExposeQueuesInCamelTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * 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.component; - -import org.apache.activemq.EmbeddedBrokerTestSupport; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.spi.BrowsableEndpoint; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -/** - * Shows that we can see the queues inside ActiveMQ via Camel - * by enabling the {@link ActiveMQComponent#setExposeAllQueues(boolean)} flag - * - * - */ -public class AutoExposeQueuesInCamelTest extends EmbeddedBrokerTestSupport { - private static final transient Logger LOG = LoggerFactory.getLogger(AutoExposeQueuesInCamelTest.class); - - protected ActiveMQQueue sampleQueue = new ActiveMQQueue("foo.bar"); - protected ActiveMQTopic sampleTopic = new ActiveMQTopic("cheese"); - - protected CamelContext camelContext = new DefaultCamelContext(); - ActiveMQComponent component; - - public void testWorks() throws Exception { - Thread.sleep(2000); - LOG.debug("Looking for endpoints..."); - broker.getAdminView().addQueue("runtime"); - - Thread.sleep(1000); - // Changed from using CamelContextHelper.getSingletonEndpoints here because JMS Endpoints in Camel - // are always non-singleton - List endpoints = getEndpoints(camelContext, BrowsableEndpoint.class); - for (BrowsableEndpoint endpoint : endpoints) { - LOG.debug("Endpoint: " + endpoint); - } - assertEquals("Should have found an endpoint: "+ endpoints, 2, endpoints.size()); - } - - public List getEndpoints(CamelContext camelContext, Class type) { - List answer = new ArrayList(); - Collection endpoints = camelContext.getEndpoints(); - for (Endpoint endpoint : endpoints) { - if (type.isInstance(endpoint)) { - T value = type.cast(endpoint); - answer.add(value); - } - } - return answer; - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - - // lets configure the ActiveMQ component for Camel - component = new ActiveMQComponent(); - component.setBrokerURL(bindAddress); - component.setExposeAllQueues(true); - - camelContext.addComponent("activemq", component); - camelContext.start(); - } - - @Override - protected void tearDown() throws Exception { - camelContext.stop(); - super.tearDown(); - } - - - @Override - protected BrokerService createBroker() throws Exception { - BrokerService broker = super.createBroker(); - broker.setDestinations(new ActiveMQDestination[]{ - sampleQueue, - sampleTopic - }); - return broker; - } - -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ComplexRequestReplyTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/ComplexRequestReplyTest.java deleted file mode 100644 index ab96ec1b68..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/ComplexRequestReplyTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * 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.component; - -import static org.junit.Assert.assertNotNull; - -import java.util.concurrent.TimeUnit; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.pool.PooledConnectionFactory; -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ComplexRequestReplyTest { - - private static final Logger LOG = LoggerFactory.getLogger(ComplexRequestReplyTest.class); - - private BrokerService brokerA = null; - private BrokerService brokerB = null; - private CamelContext senderContext = null; - private CamelContext brokerAContext = null; - private CamelContext brokerBContext = null; - - private final String fromEndpoint = "direct:test"; - private final String toEndpoint = "activemq:queue:send"; - private final String brokerEndpoint = "activemq:send"; - - private String brokerAUri; - private String brokerBUri; - - private String connectionUri; - - @Before - public void setUp() throws Exception { - - createBrokerA(); - brokerAUri = brokerA.getTransportConnectors().get(0).getPublishableConnectString(); - createBrokerB(); - brokerBUri = brokerB.getTransportConnectors().get(0).getPublishableConnectString(); - - connectionUri = "failover:(" + brokerAUri + "," + brokerBUri + ")?randomize=false"; - senderContext = createSenderContext(); - } - - @After - public void tearDown() throws Exception { - try { - shutdownBrokerA(); - } catch (Exception ex) {} - - try { - shutdownBrokerB(); - } catch (Exception e) {} - } - - @Test - public void testSendThenFailoverThenSend() throws Exception { - - ProducerTemplate requester = senderContext.createProducerTemplate(); - LOG.info("*** Sending Request 1"); - String response = (String) requester.requestBody(fromEndpoint, "This is a request"); - assertNotNull(response != null); - LOG.info("Got response: " + response); - - /** - * You actually don't need to restart the broker, just wait long enough and the next - * next send will take out a closed connection and reconnect, and if you happen to hit - * the broker you weren't on last time, then you will see the failure. - */ - - TimeUnit.SECONDS.sleep(20); - - /** - * I restart the broker after the wait that exceeds the idle timeout value of the - * PooledConnectionFactory to show that it doesn't matter now as the older connection - * has already been closed. - */ - LOG.info("Restarting Broker A now."); - shutdownBrokerA(); - createBrokerA(); - - LOG.info("*** Sending Request 2"); - response = (String) requester.requestBody(fromEndpoint, "This is a request"); - assertNotNull(response != null); - LOG.info("Got response: " + response); - } - - private CamelContext createSenderContext() throws Exception { - - ActiveMQConnectionFactory amqFactory = new ActiveMQConnectionFactory(connectionUri); - amqFactory.setWatchTopicAdvisories(false); - - PooledConnectionFactory pooled = new PooledConnectionFactory(amqFactory); - pooled.setMaxConnections(1); - pooled.setMaximumActiveSessionPerConnection(500); - // If this is not zero the connection could get closed and the request - // reply can fail. - pooled.setIdleTimeout(0); - - CamelContext camelContext = new DefaultCamelContext(); - ActiveMQComponent amqComponent = new ActiveMQComponent(); - amqComponent.setConnectionFactory(pooled); - camelContext.addComponent("activemq", amqComponent); - camelContext.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from(fromEndpoint).inOut(toEndpoint); - } - }); - camelContext.start(); - - return camelContext; - } - - private void createBrokerA() throws Exception { - brokerA = createBroker("brokerA"); - brokerAContext = createBrokerCamelContext("brokerA"); - brokerA.start(); - brokerA.waitUntilStarted(); - } - - private void shutdownBrokerA() throws Exception { - try { - brokerAContext.stop(); - } catch (Exception e) { - brokerA.stop(); - brokerA.waitUntilStopped(); - brokerA = null; - } - } - - private void createBrokerB() throws Exception { - brokerB = createBroker("brokerB"); - brokerBContext = createBrokerCamelContext("brokerB"); - brokerB.start(); - brokerB.waitUntilStarted(); - } - - private void shutdownBrokerB() throws Exception { - try { - brokerBContext.stop(); - } finally { - brokerB.stop(); - brokerB.waitUntilStopped(); - brokerB = null; - } - } - - private BrokerService createBroker(String name) throws Exception { - BrokerService service = new BrokerService(); - service.setPersistent(false); - service.setUseJmx(false); - service.setBrokerName(name); - service.addConnector("tcp://localhost:0"); - - return service; - } - - private CamelContext createBrokerCamelContext(String brokerName) throws Exception { - - CamelContext camelContext = new DefaultCamelContext(); - camelContext.addComponent("activemq", - ActiveMQComponent.activeMQComponent("vm://"+brokerName+"?create=false&waitForStart=10000")); - camelContext.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from(brokerEndpoint).setBody().simple("Returning ${body}").log("***Reply sent to ${header.JMSReplyTo} CoorId = ${header.JMSCorrelationID}"); - } - }); - camelContext.start(); - return camelContext; - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/InvokeRequestReplyUsingJmsReplyToHeaderTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/InvokeRequestReplyUsingJmsReplyToHeaderTest.java deleted file mode 100644 index 663cec8b43..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/InvokeRequestReplyUsingJmsReplyToHeaderTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * 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.component; - -import java.util.HashMap; -import java.util.Map; -import javax.jms.Destination; - -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.Headers; -import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent; -import static org.hamcrest.Matchers.hasEntry; -import static org.hamcrest.Matchers.hasKey; - -/** - * - */ -public class InvokeRequestReplyUsingJmsReplyToHeaderTest extends CamelTestSupport { - private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQReplyToHeaderUsingConverterTest.class); - protected String replyQueueName = "queue://test.reply"; - protected Object correlationID = "ABC-123"; - protected Object groupID = "GROUP-XYZ"; - private MyServer myBean = new MyServer(); - - @Test - public void testPerformRequestReplyOverJms() throws Exception { - Map headers = new HashMap(); - headers.put("cheese", 123); - headers.put("JMSReplyTo", replyQueueName); - headers.put("JMSCorrelationID", correlationID); - headers.put("JMSXGroupID", groupID); - - Exchange reply = template.request("activemq:test.server?replyTo=queue:test.reply", new Processor() { - public void process(Exchange exchange) { - exchange.getIn().setBody("James"); - Map headers = new HashMap(); - headers.put("cheese", 123); - headers.put("JMSReplyTo", replyQueueName); - headers.put("JMSCorrelationID", correlationID); - headers.put("JMSXGroupID", groupID); - exchange.getIn().setHeaders(headers); - } - }); - - Message in = reply.getIn(); - Object replyTo = in.getHeader("JMSReplyTo"); - LOG.info("Reply to is: " + replyTo); - LOG.info("Received headers: " + in.getHeaders()); - LOG.info("Received body: " + in.getBody()); - - assertMessageHeader(in, "JMSCorrelationID", correlationID); - - Map receivedHeaders = myBean.getHeaders(); - assertThat(receivedHeaders, hasKey("JMSReplyTo")); - assertThat(receivedHeaders, hasEntry("JMSXGroupID", groupID)); - assertThat(receivedHeaders, hasEntry("JMSCorrelationID", correlationID)); - - replyTo = receivedHeaders.get("JMSReplyTo"); - LOG.info("Reply to is: " + replyTo); - Destination destination = assertIsInstanceOf(Destination.class, replyTo); - assertEquals("ReplyTo", replyQueueName, destination.toString()); - } - - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - // START SNIPPET: example - camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false")); - // END SNIPPET: example - - return camelContext; - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("activemq:test.server").bean(myBean); - } - }; - } - - protected static class MyServer { - private Map headers; - - public String process(@Headers Map headers, String body) { - this.headers = headers; - LOG.info("process() invoked with headers: " + headers); - return "Hello " + body; - } - - public Map getHeaders() { - return headers; - } - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/JmsSimpleRequestReplyTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/JmsSimpleRequestReplyTest.java deleted file mode 100644 index 099448ce05..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/JmsSimpleRequestReplyTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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.component; - -import javax.jms.ConnectionFactory; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.pool.PooledConnectionFactory; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; -import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge; - -/** - * A simple request / reply test - */ -public class JmsSimpleRequestReplyTest extends CamelTestSupport { - - protected String componentName = "activemq"; - - @Test - public void testRequestReply() throws Exception { - MockEndpoint result = getMockEndpoint("mock:result"); - result.expectedMessageCount(1); - - template.requestBody("activemq:queue:hello", "Hello World"); - - result.assertIsSatisfied(); - } - - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - - ConnectionFactory connectionFactory = createConnectionFactory(null); - camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory)); - - return camelContext; - } - - public static ConnectionFactory createConnectionFactory(String options) { - String url = "vm://test-broker?broker.persistent=false&broker.useJmx=false"; - if (options != null) { - url = url + "&" + options; - } - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url); - // use a pooled connection factory - PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory); - pooled.setMaxConnections(8); - return pooled; - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("activemq:queue:hello").process(new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.getIn().setBody("Bye World"); - assertNotNull(exchange.getIn().getHeader("JMSReplyTo")); - } - }).to("mock:result"); - } - }; - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/component/broker/BrokerComponentXMLConfigTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/component/broker/BrokerComponentXMLConfigTest.java deleted file mode 100644 index 2773baac22..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/component/broker/BrokerComponentXMLConfigTest.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * 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.component.broker; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerRegistry; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQMessage; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.activemq.xbean.BrokerFactoryBean; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; - -import javax.jms.*; -import java.util.Enumeration; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class BrokerComponentXMLConfigTest { - - protected static final String CONF_ROOT = "src/test/resources/org/apache/activemq/camel/component/broker/"; - protected static final String TOPIC_NAME = "test.broker.component.topic"; - protected static final String QUEUE_NAME = "test.broker.component.queue"; - protected static final String ROUTE_QUEUE_NAME = "test.broker.component.route"; - protected static final String DIVERTED_QUEUE_NAME = "test.broker.component.ProcessLater"; - protected static final int DIVERT_COUNT = 100; - - protected BrokerService brokerService; - protected ActiveMQConnectionFactory factory; - protected Connection producerConnection; - protected Connection consumerConnection; - protected Session consumerSession; - protected Session producerSession; - - protected int messageCount = 1000; - protected int timeOutInSeconds = 10; - - @Before - public void setUp() throws Exception { - brokerService = createBroker(new FileSystemResource(CONF_ROOT + "broker-camel.xml")); - - factory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI()); - consumerConnection = factory.createConnection(); - consumerConnection.start(); - producerConnection = factory.createConnection(); - producerConnection.start(); - consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); - } - - protected BrokerService createBroker(String resource) throws Exception { - return createBroker(new ClassPathResource(resource)); - } - - protected BrokerService createBroker(Resource resource) throws Exception { - BrokerFactoryBean factory = new BrokerFactoryBean(resource); - factory.afterPropertiesSet(); - - BrokerService broker = factory.getBroker(); - - assertTrue("Should have a broker!", broker != null); - - // Broker is already started by default when using the XML file - // broker.start(); - - return broker; - } - - @After - public void tearDown() throws Exception { - if (producerConnection != null) { - producerConnection.close(); - } - if (consumerConnection != null) { - consumerConnection.close(); - } - if (brokerService != null) { - brokerService.stop(); - } - } - - @Test - public void testReRouteAll() throws Exception { - final ActiveMQQueue queue = new ActiveMQQueue(QUEUE_NAME); - - Topic topic = consumerSession.createTopic(TOPIC_NAME); - - final CountDownLatch latch = new CountDownLatch(messageCount); - MessageConsumer consumer = consumerSession.createConsumer(queue); - consumer.setMessageListener(new MessageListener() { - @Override - public void onMessage(javax.jms.Message message) { - try { - assertEquals(9, message.getJMSPriority()); - latch.countDown(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - }); - MessageProducer producer = producerSession.createProducer(topic); - - for (int i = 0; i < messageCount; i++) { - javax.jms.Message message = producerSession.createTextMessage("test: " + i); - producer.send(message); - } - - latch.await(timeOutInSeconds, TimeUnit.SECONDS); - assertEquals(0, latch.getCount()); - } - - @Test - public void testRouteWithDestinationLimit() throws Exception { - final ActiveMQQueue routeQueue = new ActiveMQQueue(ROUTE_QUEUE_NAME); - - final CountDownLatch routeLatch = new CountDownLatch(DIVERT_COUNT); - MessageConsumer messageConsumer = consumerSession.createConsumer(routeQueue); - messageConsumer.setMessageListener(new MessageListener() { - @Override - public void onMessage(javax.jms.Message message) { - try { - routeLatch.countDown(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - }); - - final CountDownLatch divertLatch = new CountDownLatch(messageCount - DIVERT_COUNT); - MessageConsumer divertConsumer = consumerSession.createConsumer(new ActiveMQQueue(DIVERTED_QUEUE_NAME)); - divertConsumer.setMessageListener(new MessageListener() { - @Override - public void onMessage(javax.jms.Message message) { - try { - divertLatch.countDown(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - }); - - MessageProducer producer = producerSession.createProducer(routeQueue); - - for (int i = 0; i < messageCount; i++) { - javax.jms.Message message = producerSession.createTextMessage("test: " + i); - producer.send(message); - } - - routeLatch.await(timeOutInSeconds, TimeUnit.SECONDS); - divertLatch.await(timeOutInSeconds, TimeUnit.SECONDS); - assertEquals(0, routeLatch.getCount()); - assertEquals(0, divertLatch.getCount()); - } - - @Test - public void testPreserveOriginalHeaders() throws Exception { - final ActiveMQQueue queue = new ActiveMQQueue(QUEUE_NAME); - - Topic topic = consumerSession.createTopic(TOPIC_NAME); - - final CountDownLatch latch = new CountDownLatch(messageCount); - MessageConsumer consumer = consumerSession.createConsumer(queue); - consumer.setMessageListener(new MessageListener() { - @Override - public void onMessage(javax.jms.Message message) { - try { - assertEquals("321", message.getStringProperty("JMSXGroupID")); - assertEquals("custom", message.getStringProperty("CustomHeader")); - latch.countDown(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - }); - MessageProducer producer = producerSession.createProducer(topic); - - for (int i = 0; i < messageCount; i++) { - javax.jms.Message message = producerSession.createTextMessage("test: " + i); - message.setStringProperty("JMSXGroupID", "123"); - producer.send(message); - } - - latch.await(timeOutInSeconds, TimeUnit.SECONDS); - assertEquals(0, latch.getCount()); - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeJmsMessageListenerTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeJmsMessageListenerTest.java deleted file mode 100644 index 05cede4492..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeJmsMessageListenerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * 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.converter; - -import javax.jms.MessageListener; -import javax.jms.Message; -import javax.jms.TextMessage; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; - -/** - * - */ -public class InvokeJmsMessageListenerTest extends CamelTestSupport { - protected MyMessageListener messageListener = new MyMessageListener(); - private String expectedBody = "world!"; - - @Test - public void testCamelInvokesMessageListener() throws Exception { - template.sendBody("direct:start", expectedBody); - - Message message = messageListener.message; - assertNotNull("Should have invoked the message listener!", message); - TextMessage textMessage = assertIsInstanceOf(TextMessage.class, message); - assertEquals("body", expectedBody, textMessage.getText()); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("direct:start").bean(messageListener); - } - }; - } - - protected static class MyMessageListener implements MessageListener { - public Message message; - - public void onMessage(Message message) { - this.message = message; - } - } -} diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeMessageListenerTest.java b/activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeMessageListenerTest.java deleted file mode 100644 index 085f1c8c33..0000000000 --- a/activemq-camel/src/test/java/org/apache/activemq/camel/converter/InvokeMessageListenerTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.converter; - -import java.util.List; - -import javax.jms.Message; -import javax.jms.TextMessage; - -import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent; -import org.apache.activemq.spring.ConsumerBean; -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; - -/** - * - */ -public class InvokeMessageListenerTest extends CamelTestSupport { - protected MockEndpoint resultEndpoint; - protected String startEndpointUri = "activemq:queue:test.a"; - protected ConsumerBean listener = new ConsumerBean(); - - @Test - public void testSendTextMessage() throws Exception { - String expectedBody = "Hello there!"; - - template.sendBodyAndHeader(startEndpointUri, expectedBody, "cheese", 123); - - listener.assertMessagesArrived(1); - - List list = listener.flushMessages(); - assertTrue("Should have received some messages!", !list.isEmpty()); - Message message = list.get(0); - - log.debug("Received: " + message); - - TextMessage textMessage = assertIsInstanceOf(TextMessage.class, message); - assertEquals("Text mesage body: " + textMessage, expectedBody, textMessage.getText()); - } - - protected CamelContext createCamelContext() throws Exception { - CamelContext camelContext = super.createCamelContext(); - camelContext.addComponent("activemq", - activeMQComponent("vm://localhost?broker.persistent=false")); - return camelContext; - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from(startEndpointUri).bean(listener); - } - }; - } -} \ No newline at end of file diff --git a/activemq-camel/src/test/resources/log4j.properties b/activemq-camel/src/test/resources/log4j.properties deleted file mode 100644 index bb20bc5e65..0000000000 --- a/activemq-camel/src/test/resources/log4j.properties +++ /dev/null @@ -1,35 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -#log4j.logger.org.apache.activemq=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml deleted file mode 100644 index 3262c6fea7..0000000000 --- a/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentFactoryUserNamePassword.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml deleted file mode 100644 index 8103481ed6..0000000000 --- a/activemq-camel/src/test/resources/org/apache/activemq/camel/ActiveMQComponentUserNamePassword.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml deleted file mode 100644 index c420957003..0000000000 --- a/activemq-camel/src/test/resources/org/apache/activemq/camel/CamelDestinationExclusiveConsumerTest-context.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml deleted file mode 100644 index 9dd6bf654b..0000000000 --- a/activemq-camel/src/test/resources/org/apache/activemq/camel/SetHeaderTest-context.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/camel-routes-activemq.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/camel-routes-activemq.xml deleted file mode 100644 index a6be02b0c8..0000000000 --- a/activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/camel-routes-activemq.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/routes.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/routes.xml deleted file mode 100644 index d44ae06711..0000000000 --- a/activemq-camel/src/test/resources/org/apache/activemq/camel/camelplugin/routes.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/component/BrowseQueuesInUFace-context.xml b/activemq-camel/src/test/resources/org/apache/activemq/camel/component/BrowseQueuesInUFace-context.xml deleted file mode 100644 index d4068ee348..0000000000 --- a/activemq-camel/src/test/resources/org/apache/activemq/camel/component/BrowseQueuesInUFace-context.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -