You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/03/13 19:06:06 UTC
[2/5] camel git commit: CAMEL-10918 create sjms2 component to add
support for JMS 2.0
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/main/java/org/apache/camel/component/sjms2/jms/Jms2ObjectFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/main/java/org/apache/camel/component/sjms2/jms/Jms2ObjectFactory.java b/components/camel-sjms2/src/main/java/org/apache/camel/component/sjms2/jms/Jms2ObjectFactory.java
new file mode 100644
index 0000000..b17cb0a
--- /dev/null
+++ b/components/camel-sjms2/src/main/java/org/apache/camel/component/sjms2/jms/Jms2ObjectFactory.java
@@ -0,0 +1,182 @@
+/**
+ * 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.camel.component.sjms2.jms;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.sjms.jms.JmsObjectFactory;
+import org.apache.camel.component.sjms2.Sjms2Endpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * JMS 2.0 object factory
+ */
+public class Jms2ObjectFactory implements JmsObjectFactory {
+
+ @Override
+ public MessageConsumer createMessageConsumer(Session session, Endpoint endpoint)
+ throws Exception {
+ Sjms2Endpoint sjms2Endpoint = (Sjms2Endpoint) endpoint;
+ Destination destination = sjms2Endpoint.getDestinationCreationStrategy().createDestination(session, sjms2Endpoint.getDestinationName(), sjms2Endpoint.isTopic());
+ return createMessageConsumer(session,
+ destination,
+ sjms2Endpoint.getMessageSelector(),
+ sjms2Endpoint.isTopic(),
+ sjms2Endpoint.getSubscriptionId(),
+ sjms2Endpoint.isDurable(),
+ sjms2Endpoint.isShared());
+ }
+
+ @Override
+ public MessageConsumer createMessageConsumer(Session session, Destination destination,
+ String messageSelector, boolean topic, String subscriptionId, boolean durable,
+ boolean shared) throws Exception {
+ // noLocal is default false according to JMS spec
+ return createMessageConsumer(session,
+ destination,
+ messageSelector,
+ topic,
+ subscriptionId,
+ durable,
+ shared,
+ false);
+ }
+
+ @Override
+ public MessageConsumer createMessageConsumer(Session session, Destination destination,
+ String messageSelector, boolean topic, String subscriptionId, boolean durable,
+ boolean shared, boolean noLocal) throws Exception {
+
+ if (topic) {
+ return createTopicMessageConsumer(session,
+ destination,
+ messageSelector,
+ subscriptionId,
+ durable,
+ shared,
+ noLocal);
+ } else {
+ return createQueueMessageConsumer(session, destination, messageSelector);
+ }
+ }
+
+ private MessageConsumer createQueueMessageConsumer(Session session, Destination destination,
+ String messageSelector) throws JMSException {
+ if (ObjectHelper.isNotEmpty(messageSelector)) {
+ return session.createConsumer(destination, messageSelector);
+ } else {
+ return session.createConsumer(destination);
+ }
+ }
+
+ private MessageConsumer createTopicMessageConsumer(Session session, Destination destination,
+ String messageSelector, String subscriptionId, boolean durable, boolean shared,
+ boolean noLocal) throws JMSException {
+ if (ObjectHelper.isNotEmpty(subscriptionId)) {
+ return createSubscriptionTopicConsumer(session,
+ destination,
+ messageSelector,
+ subscriptionId,
+ durable,
+ shared,
+ noLocal);
+ } else {
+ return createSubscriptionlessTopicConsumer(session,
+ destination,
+ messageSelector,
+ noLocal);
+ }
+ }
+
+ private MessageConsumer createSubscriptionTopicConsumer(Session session,
+ Destination destination, String messageSelector, String subscriptionId, boolean durable,
+ boolean shared, boolean noLocal) throws JMSException {
+ if (shared) {
+ if (durable) {
+ if (ObjectHelper.isNotEmpty(messageSelector)) {
+ return session.createSharedDurableConsumer((Topic) destination,
+ subscriptionId,
+ messageSelector);
+ } else {
+ return session.createSharedDurableConsumer((Topic) destination, subscriptionId);
+ }
+ } else {
+ if (ObjectHelper.isNotEmpty(messageSelector)) {
+ return session.createSharedConsumer((Topic) destination,
+ subscriptionId,
+ messageSelector);
+ } else {
+ return session.createSharedConsumer((Topic) destination, subscriptionId);
+ }
+ }
+ } else {
+ if (durable) {
+ if (ObjectHelper.isNotEmpty(messageSelector)) {
+ return session.createDurableSubscriber((Topic) destination,
+ subscriptionId,
+ messageSelector,
+ noLocal);
+ } else {
+ return session.createDurableSubscriber((Topic) destination, subscriptionId);
+ }
+ } else {
+ return createSubscriptionlessTopicConsumer(session,
+ destination,
+ messageSelector,
+ noLocal);
+ }
+ }
+ }
+
+ private MessageConsumer createSubscriptionlessTopicConsumer(Session session,
+ Destination destination, String messageSelector, boolean noLocal) throws JMSException {
+ if (ObjectHelper.isNotEmpty(messageSelector)) {
+ return session.createConsumer(destination, messageSelector, noLocal);
+ } else {
+ return session.createConsumer(destination);
+ }
+ }
+
+ @Override
+ public MessageProducer createMessageProducer(Session session, Endpoint endpoint)
+ throws Exception {
+ Sjms2Endpoint sjms2Endpoint = (Sjms2Endpoint)endpoint;
+ Destination destination = sjms2Endpoint.getDestinationCreationStrategy().createDestination(session, sjms2Endpoint.getDestinationName(), sjms2Endpoint.isTopic());
+
+ return createMessageProducer(session, destination, sjms2Endpoint.isPersistent(), sjms2Endpoint.getTtl());
+ }
+
+ @Override
+ public MessageProducer createMessageProducer(Session session, Destination destination,
+ boolean persistent, long ttl) throws Exception {
+ MessageProducer messageProducer = session.createProducer(destination);
+ messageProducer.setDeliveryMode(persistent
+ ? DeliveryMode.PERSISTENT
+ : DeliveryMode.NON_PERSISTENT);
+ if (ttl > 0) {
+ messageProducer.setTimeToLive(ttl);
+ }
+ return messageProducer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/main/resources/META-INF/LICENSE.txt b/components/camel-sjms2/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-sjms2/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/main/resources/META-INF/NOTICE.txt b/components/camel-sjms2/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-sjms2/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/main/resources/META-INF/services/org/apache/camel/component/sjms2
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/main/resources/META-INF/services/org/apache/camel/component/sjms2 b/components/camel-sjms2/src/main/resources/META-INF/services/org/apache/camel/component/sjms2
new file mode 100644
index 0000000..71559ca
--- /dev/null
+++ b/components/camel-sjms2/src/main/resources/META-INF/services/org/apache/camel/component/sjms2
@@ -0,0 +1,18 @@
+#
+# 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.camel.component.sjms2.Sjms2Component
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java
new file mode 100644
index 0000000..5133bf4
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/SimpleJms2ComponentTest.java
@@ -0,0 +1,43 @@
+/**
+ * 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.camel.component.sjms2;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class SimpleJms2ComponentTest extends CamelTestSupport {
+
+ @Test
+ public void testHelloWorld() throws Exception {
+ Sjms2Component component = context.getComponent("sjms2", Sjms2Component.class);
+ assertNotNull(component);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ Sjms2Component component = new Sjms2Component();
+ component.setConnectionFactory(connectionFactory);
+ getContext().addComponent("sjms2", component);
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
new file mode 100644
index 0000000..bb262eb
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2ComponentRestartTest.java
@@ -0,0 +1,112 @@
+/**
+ * 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.camel.component.sjms2;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class Sjms2ComponentRestartTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("activemqCF", connectionFactory);
+ return jndi;
+ }
+
+ @Test
+ public void testRestartWithStopStart() throws Exception {
+ Sjms2Component sjms2Component = new Sjms2Component();
+ sjms2Component.setConnectionFactory((ConnectionFactory) context.getRegistry().lookupByName("activemqCF"));
+ context.addComponent("sjms2", sjms2Component);
+
+ RouteBuilder routeBuilder = new RouteBuilder(context) {
+ @Override
+ public void configure() throws Exception {
+ from("sjms2:queue:test").to("mock:test");
+ }
+ };
+ context.addRoutes(routeBuilder);
+
+ context.start();
+
+ getMockEndpoint("mock:test").expectedMessageCount(1);
+ template.sendBody("sjms2:queue:test", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ // restart
+ context.stop();
+
+ // must add our custom component back again
+ context.addComponent("sjms2", sjms2Component);
+
+ context.start();
+
+ getMockEndpoint("mock:test").expectedMessageCount(1);
+
+ // and re-create template
+ template = context.createProducerTemplate();
+ template.sendBody("sjms2:queue:test", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ context.stop();
+ }
+
+ @Test
+ public void testRestartWithSuspendResume() throws Exception {
+ Sjms2Component sjms2Component = new Sjms2Component();
+ sjms2Component.setConnectionFactory((ConnectionFactory) context.getRegistry().lookupByName("activemqCF"));
+ context.addComponent("sjms2", sjms2Component);
+
+ RouteBuilder routeBuilder = new RouteBuilder(context) {
+ @Override
+ public void configure() throws Exception {
+ from("sjms2:queue:test").to("mock:test");
+ }
+ };
+ context.addRoutes(routeBuilder);
+
+ context.start();
+
+ getMockEndpoint("mock:test").expectedMessageCount(1);
+ template.sendBody("sjms2:queue:test", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ // restart
+ context.suspend();
+ context.resume();
+
+ getMockEndpoint("mock:test").expectedMessageCount(1);
+
+ template.sendBody("sjms2:queue:test", "Hello World");
+ assertMockEndpointsSatisfied();
+
+ context.stop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointConnectionSettingsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointConnectionSettingsTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointConnectionSettingsTest.java
new file mode 100644
index 0000000..710caa0
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointConnectionSettingsTest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.camel.component.sjms2;
+
+import java.util.Random;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.sjms.jms.ConnectionFactoryResource;
+import org.apache.camel.component.sjms.jms.ConnectionResource;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.SimpleRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class Sjms2EndpointConnectionSettingsTest extends CamelTestSupport {
+ private final ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ private final ConnectionResource connectionResource = new ConnectionFactoryResource(2, connectionFactory);
+
+ @Test
+ public void testConnectionFactory() {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?connectionFactory=activemq");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint) endpoint;
+ assertEquals(connectionFactory, qe.getConnectionFactory());
+ }
+
+ @Test
+ public void testConnectionResource() {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?connectionResource=connresource");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint) endpoint;
+ assertEquals(connectionResource, qe.getConnectionResource());
+ }
+
+ @Test
+ public void testConnectionCount() {
+ Random random = new Random();
+ int poolSize = random.nextInt(100);
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?connectionCount=" + poolSize);
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint) endpoint;
+ assertEquals(poolSize, qe.getConnectionCount());
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ SimpleRegistry registry = new SimpleRegistry();
+ registry.put("activemq", connectionFactory);
+ registry.put("connresource", connectionResource);
+ return new DefaultCamelContext(registry);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java
new file mode 100644
index 0000000..f5db900
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointNameOverrideTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.camel.component.sjms2;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class Sjms2EndpointNameOverrideTest extends CamelTestSupport {
+
+ private static final String BEAN_NAME = "not-sjms";
+
+ @Override
+ protected boolean useJmx() {
+ return true;
+ }
+
+ @Test
+ public void testDefaults() throws Exception {
+ Endpoint endpoint = context.getEndpoint(BEAN_NAME + ":test");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint sjms = (Sjms2Endpoint)endpoint;
+ assertEquals(sjms.getEndpointUri(), BEAN_NAME + "://test");
+ assertEquals(sjms.createExchange().getPattern(), ExchangePattern.InOnly);
+ }
+
+ @Test
+ public void testQueueEndpoint() throws Exception {
+ Endpoint sjms = context.getEndpoint(BEAN_NAME + ":queue:test");
+ assertNotNull(sjms);
+ assertTrue(sjms instanceof Sjms2Endpoint);
+ assertEquals(sjms.getEndpointUri(), BEAN_NAME + "://queue:test");
+ }
+
+ @Test
+ public void testTopicEndpoint() throws Exception {
+ Endpoint sjms = context.getEndpoint(BEAN_NAME + ":topic:test");
+ assertNotNull(sjms);
+ assertTrue(sjms instanceof Sjms2Endpoint);
+ assertEquals(sjms.getEndpointUri(), BEAN_NAME + "://topic:test");
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ Sjms2Component component = new Sjms2Component();
+ component.setConnectionCount(1);
+ component.setConnectionFactory(connectionFactory);
+ camelContext.addComponent(BEAN_NAME, component);
+
+ return camelContext;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java
new file mode 100644
index 0000000..a6eb69e
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/Sjms2EndpointTest.java
@@ -0,0 +1,200 @@
+/**
+ * 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.camel.component.sjms2;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class Sjms2EndpointTest extends CamelTestSupport {
+
+ @Override
+ protected boolean useJmx() {
+ return true;
+ }
+
+ @Test
+ public void testDefaults() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:test");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint sjms = (Sjms2Endpoint)endpoint;
+ assertEquals(sjms.getEndpointUri(), "sjms2://test");
+ assertEquals(sjms.createExchange().getPattern(), ExchangePattern.InOnly);
+ }
+
+ @Test
+ public void testQueueEndpoint() throws Exception {
+ Endpoint sjms = context.getEndpoint("sjms2:queue:test");
+ assertNotNull(sjms);
+ assertEquals(sjms.getEndpointUri(), "sjms2://queue:test");
+ assertTrue(sjms instanceof Sjms2Endpoint);
+ }
+
+ @Test
+ public void testJndiStyleEndpointName() throws Exception {
+ Sjms2Endpoint sjms = context.getEndpoint("sjms2:/jms/test/hov.t1.dev:topic", Sjms2Endpoint.class);
+ assertNotNull(sjms);
+ assertFalse(sjms.isTopic());
+ assertEquals("/jms/test/hov.t1.dev:topic", sjms.getDestinationName());
+ }
+
+ @Test
+ public void testSetTransacted() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?transacted=true");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertTrue(qe.isTransacted());
+ }
+
+ @Test
+ public void testAsyncProducer() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?synchronous=true");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertTrue(qe.isSynchronous());
+ }
+
+ @Test
+ public void testNamedReplyTo() throws Exception {
+ String namedReplyTo = "reply.to.queue";
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?namedReplyTo=" + namedReplyTo);
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertEquals(qe.getNamedReplyTo(), namedReplyTo);
+ assertEquals(qe.createExchange().getPattern(), ExchangePattern.InOut);
+ }
+
+ @Test
+ public void testDefaultExchangePattern() throws Exception {
+ try {
+ Sjms2Endpoint sjms = (Sjms2Endpoint)context.getEndpoint("sjms2:queue:test");
+ assertNotNull(sjms);
+ assertEquals(ExchangePattern.InOnly, sjms.getExchangePattern());
+ // assertTrue(sjms.createExchange().getPattern().equals(ExchangePattern.InOnly));
+ } catch (Exception e) {
+ fail("Exception thrown: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Test
+ public void testInOnlyExchangePattern() throws Exception {
+ try {
+ Endpoint sjms = context.getEndpoint("sjms2:queue:test?exchangePattern=" + ExchangePattern.InOnly);
+ assertNotNull(sjms);
+ assertTrue(sjms.createExchange().getPattern().equals(ExchangePattern.InOnly));
+ } catch (Exception e) {
+ fail("Exception thrown: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Test
+ public void testInOutExchangePattern() throws Exception {
+ try {
+ Endpoint sjms = context.getEndpoint("sjms2:queue:test?exchangePattern=" + ExchangePattern.InOut);
+ assertNotNull(sjms);
+ assertTrue(sjms.createExchange().getPattern().equals(ExchangePattern.InOut));
+ } catch (Exception e) {
+ fail("Exception thrown: " + e.getLocalizedMessage());
+ }
+ }
+
+ @Test(expected = ResolveEndpointFailedException.class)
+ public void testUnsupportedMessageExchangePattern() throws Exception {
+ context.getEndpoint("sjms2:queue:test2?messageExchangePattern=" + ExchangePattern.OutOnly);
+ }
+
+ @Test
+ public void testNamedReplyToAndMEPMatch() throws Exception {
+ String namedReplyTo = "reply.to.queue";
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?namedReplyTo=" + namedReplyTo + "&exchangePattern=" + ExchangePattern.InOut);
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertEquals(qe.getNamedReplyTo(), namedReplyTo);
+ assertEquals(qe.createExchange().getPattern(), ExchangePattern.InOut);
+ }
+
+ @Test(expected = Exception.class)
+ public void testNamedReplyToAndMEPMismatch() throws Exception {
+ context.getEndpoint("sjms2:queue:test?namedReplyTo=reply.to.queue&exchangePattern=" + ExchangePattern.InOnly);
+ }
+
+ @Test
+ public void testDestinationName() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?synchronous=true");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertTrue(qe.isSynchronous());
+ }
+
+ @Test
+ public void testTransactedBatchCountDefault() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?transacted=true");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertTrue(qe.getTransactionBatchCount() == -1);
+ }
+
+ @Test
+ public void testTransactedBatchCountModified() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?transacted=true&transactionBatchCount=10");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertTrue(qe.getTransactionBatchCount() == 10);
+ }
+
+ @Test
+ public void testTransactedBatchTimeoutDefault() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?transacted=true");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertTrue(qe.getTransactionBatchTimeout() == 5000);
+ }
+
+ @Test
+ public void testTransactedBatchTimeoutModified() throws Exception {
+ Endpoint endpoint = context.getEndpoint("sjms2:queue:test?transacted=true&transactionBatchTimeout=3000");
+ assertNotNull(endpoint);
+ assertTrue(endpoint instanceof Sjms2Endpoint);
+ Sjms2Endpoint qe = (Sjms2Endpoint)endpoint;
+ assertTrue(qe.getTransactionBatchTimeout() == 3000);
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
+ Sjms2Component component = new Sjms2Component();
+ component.setConnectionCount(3);
+ component.setConnectionFactory(connectionFactory);
+ camelContext.addComponent("sjms2", component);
+
+ return camelContext;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicDurableConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicDurableConsumerTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicDurableConsumerTest.java
new file mode 100644
index 0000000..5dd249a
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicDurableConsumerTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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.camel.component.sjms2.consumer;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms.jms.ConnectionFactoryResource;
+import org.apache.camel.component.sjms2.Sjms2Component;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class InOnlyTopicDurableConsumerTest extends CamelTestSupport {
+
+ private static final String CONNECTION_ID = "test-connection-1";
+ private static final String BROKER_URI = "vm://durable.broker?broker.persistent=false&broker.useJmx=false";
+
+ @Override
+ protected boolean useJmx() {
+ return false;
+ }
+
+ @Test
+ public void testDurableTopic() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceived("Hello World");
+
+ MockEndpoint mock2 = getMockEndpoint("mock:result2");
+ mock2.expectedBodiesReceived("Hello World");
+
+ // wait a bit and send the message
+ Thread.sleep(1000);
+
+ template.sendBody("sjms2:topic:foo", "Hello World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+
+ /*
+ * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
+ *
+ * @return
+ * @throws Exception
+ */
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
+ ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
+ connectionResource.setConnectionFactory(connectionFactory);
+ connectionResource.setClientId(CONNECTION_ID);
+ CamelContext camelContext = super.createCamelContext();
+ Sjms2Component component = new Sjms2Component();
+ component.setConnectionResource(connectionResource);
+ component.setConnectionCount(1);
+ camelContext.addComponent("sjms2", component);
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("sjms2:topic:foo?durableSubscriptionId=bar1")
+ .to("mock:result");
+
+ from("sjms2:topic:foo?durableSubscriptionId=bar2")
+ .to("mock:result2");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicSharedConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicSharedConsumerTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicSharedConsumerTest.java
new file mode 100644
index 0000000..e20f0b1
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/consumer/InOnlyTopicSharedConsumerTest.java
@@ -0,0 +1,73 @@
+/**
+ * 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.camel.component.sjms2.consumer;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms2.support.Jms2TestSupport;
+import org.junit.Test;
+
+public class InOnlyTopicSharedConsumerTest extends Jms2TestSupport {
+
+ private static final String TEST_DESTINATION_NAME = "sjms2:topic:in.only.topic.consumer.test";
+
+ @Override
+ protected boolean useJmx() {
+ return false;
+ }
+
+ @Test
+ public void testSynchronous() throws Exception {
+ final String expectedBody = "Hello World";
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived("Hello World");
+
+ MockEndpoint mock2 = getMockEndpoint("mock:result2");
+ mock2.expectedMessageCount(1);
+ mock2.expectedBodiesReceived("Hello World");
+
+ template.sendBody("direct:start", expectedBody);
+
+ mock.assertIsSatisfied();
+ mock2.assertIsSatisfied();
+ }
+
+ /**
+ * @see org.apache.camel.test.junit4.CamelTestSupport#createRouteBuilder()
+ *
+ * @return
+ * @throws Exception
+ */
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to(TEST_DESTINATION_NAME);
+ from(TEST_DESTINATION_NAME)
+ .to("log:test.log.1?showBody=true", "mock:result");
+
+ from(TEST_DESTINATION_NAME + "?subscriptionId=sharedTest&shared=true")
+ .to("log:test.log.1?showBody=true", "mock:result2");
+
+ from(TEST_DESTINATION_NAME + "?subscriptionId=sharedTest&shared=true")
+ .to("log:test.log.1?showBody=true", "mock:result2");
+ }
+ };
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyQueueProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyQueueProducerTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyQueueProducerTest.java
new file mode 100644
index 0000000..0991234
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyQueueProducerTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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.camel.component.sjms2.producer;
+
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms2.support.Jms2TestSupport;
+import org.junit.Test;
+
+public class InOnlyQueueProducerTest extends Jms2TestSupport {
+
+ private static final String TEST_DESTINATION_NAME = "sync.queue.producer.test";
+
+ public InOnlyQueueProducerTest() {
+ }
+
+ @Override
+ protected boolean useJmx() {
+ return false;
+ }
+
+ @Test
+ public void testInOnlyQueueProducer() throws Exception {
+ MessageConsumer mc = createQueueConsumer(TEST_DESTINATION_NAME);
+ assertNotNull(mc);
+ final String expectedBody = "Hello World!";
+ MockEndpoint mock = getMockEndpoint("mock:result");
+
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived(expectedBody);
+
+ template.sendBody("direct:start", expectedBody);
+ Message message = mc.receive(5000);
+ assertNotNull(message);
+ assertTrue(message instanceof TextMessage);
+
+ TextMessage tm = (TextMessage) message;
+ String text = tm.getText();
+ assertNotNull(text);
+
+ template.sendBody("direct:finish", text);
+
+ mock.assertIsSatisfied();
+ mc.close();
+
+ }
+
+ /**
+ * @see org.apache.camel.test.junit4.CamelTestSupport#createRouteBuilder()
+ *
+ * @return
+ * @throws Exception
+ */
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("sjms2:queue:" + TEST_DESTINATION_NAME);
+
+ from("direct:finish")
+ .to("log:test.log.1?showBody=true", "mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyTopicProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyTopicProducerTest.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyTopicProducerTest.java
new file mode 100644
index 0000000..c7d75b7
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/producer/InOnlyTopicProducerTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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.camel.component.sjms2.producer;
+
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.sjms2.support.Jms2TestSupport;
+import org.junit.Test;
+
+public class InOnlyTopicProducerTest extends Jms2TestSupport {
+
+ private static final String TEST_DESTINATION_NAME = "test.foo.topic";
+
+ public InOnlyTopicProducerTest() {
+ }
+
+ @Override
+ protected boolean useJmx() {
+ return false;
+ }
+
+ @Test
+ public void testInOnlyTopicProducerProducer() throws Exception {
+ MessageConsumer mc = createTopicConsumer(TEST_DESTINATION_NAME, null);
+ assertNotNull(mc);
+ final String expectedBody = "Hello World!";
+ MockEndpoint mock = getMockEndpoint("mock:result");
+
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived(expectedBody);
+
+ template.sendBody("direct:start", expectedBody);
+ Message message = mc.receive(5000);
+ assertNotNull(message);
+ assertTrue(message instanceof TextMessage);
+
+ TextMessage tm = (TextMessage) message;
+ String text = tm.getText();
+ assertNotNull(text);
+
+ template.sendBody("direct:finish", text);
+
+ mock.assertIsSatisfied();
+ mc.close();
+
+ }
+
+ /**
+ * @see org.apache.camel.test.junit4.CamelTestSupport#createRouteBuilder()
+ *
+ * @return
+ * @throws Exception
+ */
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("sjms2:topic:" + TEST_DESTINATION_NAME);
+
+ from("direct:finish")
+ .to("log:test.log.1?showBody=true", "mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java
new file mode 100644
index 0000000..7b44884
--- /dev/null
+++ b/components/camel-sjms2/src/test/java/org/apache/camel/component/sjms2/support/Jms2TestSupport.java
@@ -0,0 +1,186 @@
+/**
+ * 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.camel.component.sjms2.support;
+
+import java.util.Arrays;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
+import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
+import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
+import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration;
+import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.sjms.jms.DefaultDestinationCreationStrategy;
+import org.apache.camel.component.sjms.jms.DestinationCreationStrategy;
+import org.apache.camel.component.sjms2.Sjms2Component;
+import org.apache.camel.component.sjms2.jms.Jms2ObjectFactory;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+/**
+ * A support class that builds up and tears down an ActiveMQ Artemis instance to be used
+ * for unit testing.
+ */
+public class Jms2TestSupport extends CamelTestSupport {
+
+ @Produce
+ protected ProducerTemplate template;
+ protected String brokerUri;
+ protected int port;
+ private EmbeddedJMS broker;
+ private Connection connection;
+ private Session session;
+ private DestinationCreationStrategy destinationCreationStrategy = new DefaultDestinationCreationStrategy();
+
+ /**
+ * Set up the Broker
+ *
+ * @see CamelTestSupport#doPreSetup()
+ *
+ * @throws Exception
+ */
+ @Override
+ protected void doPreSetup() throws Exception {
+ broker = new EmbeddedJMS();
+ deleteDirectory("target/data");
+ port = AvailablePortFinder.getNextAvailable(33333);
+ brokerUri = "tcp://localhost:" + port;
+ configureBroker(this.broker);
+ startBroker();
+ }
+
+ protected void configureBroker(EmbeddedJMS broker) throws Exception {
+ Configuration configuration = new ConfigurationImpl()
+ .setPersistenceEnabled(false)
+ .setJournalDirectory("target/data/journal")
+ .setSecurityEnabled(false)
+ .addAcceptorConfiguration("connector", brokerUri + "?protocols=CORE,AMQP,HORNETQ,OPENWIRE")
+ .addAcceptorConfiguration("vm", "vm://broker")
+ .addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName()));
+
+ JMSConfiguration jmsConfig = new JMSConfigurationImpl();
+
+ ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(
+ Arrays.asList("connector")).setBindings("cf");
+ jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
+
+ JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName("queue1").setDurable(false).setBindings("queue/queue1");
+ jmsConfig.getQueueConfigurations().add(queueConfig);
+
+ broker.setConfiguration(configuration).setJmsConfiguration(jmsConfig);
+ }
+
+ private void startBroker() throws Exception {
+ broker.start();
+ log.info("Started Embedded JMS Server");
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ DefaultCamelContext dcc = (DefaultCamelContext)context;
+ while (!dcc.isStopped()) {
+ log.info("Waiting on the Camel Context to stop");
+ }
+ log.info("Closing JMS Session");
+ if (getSession() != null) {
+ getSession().close();
+ setSession(null);
+ }
+ log.info("Closing JMS Connection");
+ if (connection != null) {
+ connection.stop();
+ connection = null;
+ }
+ log.info("Stopping the ActiveMQ Broker");
+ if (broker != null) {
+ broker.stop();
+ broker = null;
+ }
+ }
+
+ /*
+ * @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
+ * @return
+ * @throws Exception
+ */
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+ ConnectionFactory connectionFactory = getConnectionFactory();
+ connection = connectionFactory.createConnection();
+ connection.start();
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Sjms2Component component = new Sjms2Component();
+ component.setConnectionCount(1);
+ component.setConnectionFactory(connectionFactory);
+ camelContext.addComponent("sjms2", component);
+ return camelContext;
+ }
+
+ protected ConnectionFactory getConnectionFactory() throws Exception {
+ final String protocol = System.getProperty("protocol", "CORE").toUpperCase();
+
+ //Currently AMQP and HORENTQ don't operate in exactly the same way on artemis as OPENWIRE
+ //and CORE so its not possible to write protocol agnostic tests but in the future releases
+ //of artemis we may be able test against them in an agnostic way.
+ switch (protocol) {
+ case "OPENWIRE":
+ return new ActiveMQConnectionFactory(brokerUri);
+ default:
+ return ActiveMQJMSClient.createConnectionFactory(brokerUri, "test");
+ }
+ }
+
+ public QueueQueryResult getQueueQueryResult(String queueQuery) throws Exception {
+ return broker.getActiveMQServer().queueQuery(new SimpleString(queueQuery));
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ public MessageConsumer createQueueConsumer(String destination) throws Exception {
+ return new Jms2ObjectFactory().createMessageConsumer(session, destinationCreationStrategy.createDestination(session, destination, false), null, false, null, false, false);
+ }
+
+ public MessageConsumer createTopicConsumer(String destination, String messageSelector) throws Exception {
+ return new Jms2ObjectFactory().createMessageConsumer(session, destinationCreationStrategy.createDestination(session, destination, true), messageSelector, true, null, false, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/camel-sjms2/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-sjms2/src/test/resources/log4j2.properties b/components/camel-sjms2/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..4303f50
--- /dev/null
+++ b/components/camel-sjms2/src/test/resources/log4j2.properties
@@ -0,0 +1,36 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-sjms2-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+logger.activemq.name = org.apache.activemq
+logger.activemq.level = warn
+logger.camel.name = org.apache.camel
+logger.camel.level = info
+logger.sjms2.name = org.apache.camel.component.sjms2
+logger.sjms2.level = info
+logger.converter.name = org.apache.camel.converter
+logger.converter.level = info
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index d1bb229..541a57b 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -242,6 +242,7 @@
<module>camel-snakeyaml</module>
<module>camel-snmp</module>
<module>camel-sjms</module>
+ <module>camel-sjms2</module>
<module>camel-slack</module>
<module>camel-soap</module>
<module>camel-solr</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/components/readme.adoc
----------------------------------------------------------------------
diff --git a/components/readme.adoc b/components/readme.adoc
index 940d5e5..165402e 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -2,7 +2,7 @@ Components
^^^^^^^^^^
// components: START
-Number of Components: 222 in 176 JAR artifacts (13 deprecated)
+Number of Components: 223 in 177 JAR artifacts (13 deprecated)
[width="100%",cols="4,1,5",options="header"]
|=======================================================================
@@ -554,6 +554,9 @@ Number of Components: 222 in 176 JAR artifacts (13 deprecated)
| link:camel-sjms/src/main/docs/sjms-batch-component.adoc[Simple JMS Batch] (camel-sjms) +
`sjms-batch:destinationName` | 2.16 | The sjms-batch component is a specialized for highly performant transactional batch consumption from a JMS queue.
+| link:camel-sjms2/src/main/docs/sjms2-component.adoc[Simple JMS2] (camel-sjms2) +
+`sjms2:destinationType:destinationName` | 2.19 | The sjms2 component (simple jms) allows messages to be sent to (or consumed from) a JMS Queue or Topic.
+
| link:camel-sip/src/main/docs/sip-component.adoc[SIP] (camel-sip) +
`sip:uri` | 2.5 | To send and receive messages using the SIP protocol (used in telco and mobile).
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index e8bd83b..d37fbf8 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -287,6 +287,7 @@
* [SFTP](sftp-component.adoc)
* [Simple JMS](sjms-component.adoc)
* [Simple JMS Batch](sjms-batch-component.adoc)
+ * [Simple JMS2](sjms2-component.adoc)
* [SIP](sip-component.adoc)
* [Slack](slack-component.adoc)
* [SMPP](smpp-component.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index f5b8ce0..20e1e2f 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -221,6 +221,7 @@
<geronimo-jcdi-1.0-spec-version>1.0</geronimo-jcdi-1.0-spec-version>
<geronimo-jcdi-1.1-spec-version>1.0</geronimo-jcdi-1.1-spec-version>
<geronimo-jms-spec-version>1.1.1</geronimo-jms-spec-version>
+ <geronimo-jms2-spec-version>1.0-alpha-2</geronimo-jms2-spec-version>
<geronimo-jpa2-spec-version>1.1</geronimo-jpa2-spec-version>
<geronimo-jsp-spec-version>1.1</geronimo-jsp-spec-version>
<geronimo-json-spec-version>1.0-alpha-1</geronimo-json-spec-version>
@@ -1751,6 +1752,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-sjms2</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-slack</artifactId>
<version>${project.version}</version>
</dependency>
@@ -3709,6 +3715,11 @@
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_2.0_spec</artifactId>
+ <version>${geronimo-jms2-spec-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>${geronimo-jpa2-spec-version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index cb52f64..4caccfc 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -1635,6 +1635,15 @@
<bundle dependency='true'>mvn:commons-pool/commons-pool/${commons-pool-version}</bundle>
<bundle>mvn:org.apache.camel/camel-sjms/${project.version}</bundle>
</feature>
+ <feature name='camel-sjms2' version='${project.version}' resolver='(obr)' start-level='50'>
+ <feature version='${project.version}'>camel-core</feature>
+ <!-- JTA is not currently supported by SJMS but is a required dependency of the Geronimo JMS Bundle -->
+ <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/${geronimo-jta-spec-version}</bundle>
+ <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-jms_2.0_spec/${geronimo-jms2-spec-version}</bundle>
+ <bundle dependency='true'>mvn:commons-pool/commons-pool/${commons-pool-version}</bundle>
+ <bundle dependency='true'>mvn:org.apache.camel/camel-sjms/${project.version}</bundle>
+ <bundle>mvn:org.apache.camel/camel-sjms2/${project.version}</bundle>
+ </feature>
<feature name='camel-slack' version='${project.version}' resolver='(obr)' start-level='50'>
<feature version='${project.version}'>camel-core</feature>
<bundle dependency='true'>mvn:com.googlecode.json-simple/json-simple/${json-simple-version}</bundle>
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/platforms/spring-boot/components-starter/camel-sjms2-starter/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-sjms2-starter/pom.xml b/platforms/spring-boot/components-starter/camel-sjms2-starter/pom.xml
new file mode 100644
index 0000000..43e95e5
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-sjms2-starter/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components-starter</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>camel-sjms2-starter</artifactId>
+ <packaging>jar</packaging>
+ <name>Spring-Boot Starter :: Camel :: Simple JMS2</name>
+ <description>Spring-Boot Starter for A pure Java JMS 2.0 Camel Component</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-sjms2</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--START OF GENERATED CODE-->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_2.0_spec</artifactId>
+ </dependency>
+ <!--END OF GENERATED CODE-->
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/014ab4cc/platforms/spring-boot/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java
new file mode 100644
index 0000000..4be32a4
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java
@@ -0,0 +1,110 @@
+/**
+ * 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.camel.component.sjms2.springboot;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.sjms2.Sjms2Component;
+import org.apache.camel.util.IntrospectionSupport;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionMessage;
+import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Configuration
+@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@Conditional(Sjms2ComponentAutoConfiguration.Condition.class)
+@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@EnableConfigurationProperties(Sjms2ComponentConfiguration.class)
+public class Sjms2ComponentAutoConfiguration {
+
+ @Lazy
+ @Bean(name = "sjms2-component")
+ @ConditionalOnClass(CamelContext.class)
+ @ConditionalOnMissingBean(Sjms2Component.class)
+ public Sjms2Component configureSjms2Component(CamelContext camelContext,
+ Sjms2ComponentConfiguration configuration) throws Exception {
+ Sjms2Component component = new Sjms2Component();
+ component.setCamelContext(camelContext);
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(configuration, parameters, null,
+ false);
+ for (Map.Entry<String, Object> entry : parameters.entrySet()) {
+ Object value = entry.getValue();
+ Class<?> paramClass = value.getClass();
+ if (paramClass.getName().endsWith("NestedConfiguration")) {
+ Class nestedClass = null;
+ try {
+ nestedClass = (Class) paramClass.getDeclaredField(
+ "CAMEL_NESTED_CLASS").get(null);
+ HashMap<String, Object> nestedParameters = new HashMap<>();
+ IntrospectionSupport.getProperties(value, nestedParameters,
+ null, false);
+ Object nestedProperty = nestedClass.newInstance();
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), nestedProperty,
+ nestedParameters);
+ entry.setValue(nestedProperty);
+ } catch (NoSuchFieldException e) {
+ }
+ }
+ }
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), component, parameters);
+ return component;
+ }
+
+ public static class Condition extends SpringBootCondition {
+ @Override
+ public ConditionOutcome getMatchOutcome(
+ ConditionContext conditionContext,
+ AnnotatedTypeMetadata annotatedTypeMetadata) {
+ boolean groupEnabled = isEnabled(conditionContext,
+ "camel.component.", true);
+ ConditionMessage.Builder message = ConditionMessage
+ .forCondition("camel.component.sjms2");
+ if (isEnabled(conditionContext, "camel.component.sjms2.",
+ groupEnabled)) {
+ return ConditionOutcome.match(message.because("enabled"));
+ }
+ return ConditionOutcome.noMatch(message.because("not enabled"));
+ }
+
+ private boolean isEnabled(
+ org.springframework.context.annotation.ConditionContext context,
+ java.lang.String prefix, boolean defaultValue) {
+ RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
+ context.getEnvironment(), prefix);
+ return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ }
+ }
+}
\ No newline at end of file