Repository: camel
Updated Branches:
  refs/heads/master 12636f69f -> 23a1ddd01


CAMEL-11573: Enable MultipleConsumersSupport for Jt400Endpoint. Thanks to Rafat 
Gata for the patch.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/23a1ddd0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/23a1ddd0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/23a1ddd0

Branch: refs/heads/master
Commit: 23a1ddd01badd19b000f1ec3b4745dd3c59be885
Parents: 12636f6
Author: Claus Ibsen <davscl...@apache.org>
Authored: Mon Jul 24 13:04:39 2017 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Jul 24 13:04:39 2017 +0200

----------------------------------------------------------------------
 .../camel/component/jt400/Jt400Endpoint.java    |  8 ++-
 .../jt400/Jt400MultipleConsumersRouteTest.java  | 66 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/23a1ddd0/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
 
b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
index 074140b..a17eda8 100644
--- 
a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
+++ 
b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400Endpoint.java
@@ -24,6 +24,7 @@ import com.ibm.as400.access.AS400;
 import com.ibm.as400.access.AS400ConnectionPool;
 import org.apache.camel.CamelException;
 import org.apache.camel.Consumer;
+import org.apache.camel.MultipleConsumersSupport;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.ScheduledPollEndpoint;
@@ -36,7 +37,7 @@ import org.apache.camel.util.URISupport;
  * The jt400 component allows you to exchanges messages with an AS/400 system 
using data queues or program call.
  */
 @UriEndpoint(firstVersion = "1.5.0", scheme = "jt400", title = "JT400", syntax 
= "jt400:userID:password/systemName/objectPath.type", consumerClass = 
Jt400DataQueueConsumer.class, label = "messaging")
-public class Jt400Endpoint extends ScheduledPollEndpoint {
+public class Jt400Endpoint extends ScheduledPollEndpoint implements 
MultipleConsumersSupport {
 
     public static final String KEY = "KEY";
     public static final String SENDER_INFORMATION = "SENDER_INFORMATION";
@@ -260,4 +261,9 @@ public class Jt400Endpoint extends ScheduledPollEndpoint {
         configuration.setReadTimeout(readTimeout);
     }
 
+    @Override
+    public boolean isMultipleConsumersSupported() {
+        return true;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/23a1ddd0/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400MultipleConsumersRouteTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400MultipleConsumersRouteTest.java
 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400MultipleConsumersRouteTest.java
new file mode 100644
index 0000000..d2ca430
--- /dev/null
+++ 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400MultipleConsumersRouteTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.jt400;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * Test case for routes that contain <code>jt400:</code> endpoints This test
+ * case does nothing by default -- you can use it to test integration when 
there
+ * is a real AS/400 system available by filling in correct values for
+ * {@link #USER}, {@link #PASSWORD}, {@link #SYSTEM}, {@link #LIBRARY} and
+ * {@link #QUEUE}
+ */
+public class Jt400MultipleConsumersRouteTest extends CamelTestSupport {
+
+    // fill in correct values for all constants to test with a real AS/400
+    // system
+    private static final String USER = "username";
+    private static final String PASSWORD = "password";
+    private static final String SYSTEM = null;
+    private static final String LIBRARY = "library";
+    private static final String QUEUE = "queue";
+
+    @Test
+    public void testBasicTest() throws Exception {
+        if (SYSTEM != null) {
+            MockEndpoint endpoint = getMockEndpoint("mock:a");
+            endpoint.expectedBodiesReceived("Test message");
+            sendBody("direct:a", "Test message");
+            endpoint.assertIsSatisfied();
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                if (SYSTEM != null) {
+                    String uri = 
String.format("jt400://%s:%s@%s/QSYS.LIB/%s.LIB/%s.DTAQ", USER, PASSWORD,
+                            SYSTEM, LIBRARY, QUEUE);
+                    from("direct:a").to(uri);
+                    from(uri).from(uri).to("mock:a");
+                }
+            }
+        };
+    }
+}

Reply via email to