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 2014/09/27 14:16:28 UTC
[1/8] git commit: CAMEL-7855: Fixed resuming JMS consumer to work if
the route has never been initialized before.
Repository: camel
Updated Branches:
refs/heads/camel-2.12.x c288a7d19 -> f5ae2b708
refs/heads/camel-2.13.x b840c4dd2 -> 5c331211e
refs/heads/camel-2.14.x 728a4c5e3 -> 47725f76e
refs/heads/master ecaafc411 -> c57aec585
CAMEL-7855: Fixed resuming JMS consumer to work if the route has never been initialized before.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/06633194
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/06633194
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/06633194
Branch: refs/heads/master
Commit: 066331947f4618132251a668129be6231a686b32
Parents: ecaafc4
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 27 13:55:53 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 27 13:55:53 2014 +0200
----------------------------------------------------------------------
.../apache/camel/component/jms/JmsConsumer.java | 9 +-
.../jms/issues/JmsLifecycleIssueTest.java | 93 ++++++++++++++++++++
2 files changed, 100 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/06633194/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
index 87f39fa..5d66555 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
@@ -230,8 +230,13 @@ public class JmsConsumer extends DefaultConsumer implements SuspendableService {
@Override
protected void doResume() throws Exception {
- if (listenerContainer != null) {
- startListenerContainer();
+ // we may not have been started before, and now the end user calls resume, so lets handle that and start it first
+ if (!initialized) {
+ doStart();
+ } else {
+ if (listenerContainer != null) {
+ startListenerContainer();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/06633194/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
new file mode 100644
index 0000000..32fb137
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.jms.issues;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.CamelJmsTestHelper;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.ServiceStatus.Started;
+import static org.apache.camel.ServiceStatus.Stopped;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+public class JmsLifecycleIssueTest extends CamelTestSupport {
+
+ public static final String ROUTE_ID = "simpleRoute";
+ public static final String ENDPOINT_URI = "activemq:processOrder";
+
+ @Test
+ public void routeThatIsStoppedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ @Test
+ public void routeThatIsStoppedSuspendedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.suspendRoute(ROUTE_ID);
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ private void assertThatRouteIs(ServiceStatus expectedStatus) {
+ assertEquals(expectedStatus, context.getRouteStatus(ROUTE_ID));
+ }
+
+ private void assertRouteWorks() throws Exception {
+ assertThatRouteIs(Started);
+
+ getMockEndpoint("mock:result").expectedBodiesReceived("anything");
+
+ template.sendBody(ENDPOINT_URI, "anything");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+ ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+ camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from(ENDPOINT_URI).routeId(ROUTE_ID).autoStartup(false)
+ .to("log:input")
+ .to("mock:result");
+ }
+ });
+ }
+ };
+ }
+}
[5/8] git commit: CAMEL-7871 configure ERROR_CORRECTION only if
barcode format is QR code
Posted by da...@apache.org.
CAMEL-7871 configure ERROR_CORRECTION only if barcode format is QR code
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/47725f76
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/47725f76
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/47725f76
Branch: refs/heads/camel-2.14.x
Commit: 47725f76e5e6d6ba6eb25dd52b1a45b59615bd70
Parents: fa62b65
Author: Seiji Sogabe <s....@gmail.com>
Authored: Sun Sep 28 05:36:48 2014 +0900
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 27 14:15:38 2014 +0200
----------------------------------------------------------------------
.../dataformat/barcode/BarcodeDataFormat.java | 14 +++++++-----
.../barcode/BarcodeDataFormatCamelTest.java | 23 ++++++++++++++++++++
.../barcode/barcodeDataformatSpring.xml | 9 +++++++-
3 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/47725f76/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
index 7639eaf..1dd5f9b 100644
--- a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
@@ -191,11 +191,15 @@ public class BarcodeDataFormat implements DataFormat {
this.readerHintMap.clear();
// writer hints
- this.writerHintMap
- .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
-
- if (this.params.getFormat().toString()
- .equals(BarcodeFormat.DATA_MATRIX.toString())) {
+ String format = this.params.getFormat().toString();
+
+ // only for QR code. AZTEC uses zxing's default error correction 33%.
+ if (format.equals(BarcodeFormat.QR_CODE.toString())) {
+ this.writerHintMap
+ .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+ }
+
+ if (format.equals(BarcodeFormat.DATA_MATRIX.toString())) {
this.writerHintMap
.put(EncodeHintType.DATA_MATRIX_SHAPE
, SymbolShapeHint.FORCE_SQUARE);
http://git-wip-us.apache.org/repos/asf/camel/blob/47725f76/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
index b5a5d6b..308cf2d 100644
--- a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
@@ -120,6 +120,23 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
this.checkImage(image, "JPEG", BarcodeFormat.PDF_417);
}
+ /**
+ * tests barcode (AZTEC).
+ *
+ * @throws Exception
+ * @see CAMEL-7681
+ */
+ @Test
+ public void testAZTECWidthModifiedSizeAndImageType() throws Exception {
+ out.expectedBodiesReceived(MSG);
+ image.expectedMessageCount(1);
+
+ template.sendBody("direct:code5", MSG);
+
+ assertMockEndpointsSatisfied(60, TimeUnit.SECONDS);
+ this.checkImage(image, 200, 200, "PNG", BarcodeFormat.AZTEC);
+ }
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@@ -154,6 +171,12 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
.marshal(code4)
.to(FILE_ENDPOINT);
+ // AZTEC with modified size and PNG type
+ DataFormat code5 = new BarcodeDataFormat(200, 200, BarcodeImageType.PNG, BarcodeFormat.AZTEC);
+
+ from("direct:code5")
+ .marshal(code5)
+ .to(FILE_ENDPOINT);
// generic file read --->
//
http://git-wip-us.apache.org/repos/asf/camel/blob/47725f76/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml b/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
index 1c12d9b..2e80909 100644
--- a/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
+++ b/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
@@ -31,6 +31,7 @@
<barcode id="code2" width="200" height="200" />
<barcode id="code3" imageType="JPG" />
<barcode id="code4" width="200" height="200" imageType="JPG" barcodeFormat="PDF_417"/>
+ <barcode id="code5" width="200" height="200" imageType="PNG" barcodeFormat="AZTEC"/>
</dataFormats>
@@ -57,7 +58,13 @@
<marshal ref="code4"/>
<to uri="file:target/out"/>
</route>
-
+
+ <route>
+ <from uri="direct:code5"/>
+ <marshal ref="code5"/>
+ <to uri="file:target/out"/>
+ </route>
+
<route>
<from uri="file:target/out?noop=true"/>
<multicast>
[2/8] git commit: apt tooling should support java source 7 onwards.
As java6 is dropped.
Posted by da...@apache.org.
apt tooling should support java source 7 onwards. As java6 is dropped.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f543a113
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f543a113
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f543a113
Branch: refs/heads/master
Commit: f543a1131e4e52e25f635adcff0860c99cf91e28
Parents: 0663319
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 27 13:57:22 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 27 13:57:22 2014 +0200
----------------------------------------------------------------------
.../org/apache/camel/tools/apt/EndpointAnnotationProcessor.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f543a113/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index ed4952c..501527b 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -59,9 +59,8 @@ import static org.apache.camel.tools.apt.util.Strings.canonicalClassName;
/**
* Processes all Camel endpoints
*/
-//@SupportedOptions({"foo"})
@SupportedAnnotationTypes({"org.apache.camel.spi.*"})
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
+@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class EndpointAnnotationProcessor extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
@@ -284,7 +283,6 @@ public class EndpointAnnotationProcessor extends AbstractProcessor {
try {
resource = filer.getResource(StandardLocation.CLASS_OUTPUT, packageName, fileName);
} catch (Throwable e) {
- //resource = filer.createResource(StandardLocation.CLASS_OUTPUT, "org.apache.camel", "CamelAPT2.txt", rootElements.toArray(new Element[rootElements.size()]));
resource = filer.createResource(StandardLocation.CLASS_OUTPUT, packageName, fileName, new Element[0]);
}
URI uri = resource.toUri();
[3/8] git commit: Merge branch 'CAMEL-7871' of
https://github.com/ssogabe/camel
Posted by da...@apache.org.
Merge branch 'CAMEL-7871' of https://github.com/ssogabe/camel
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c57aec58
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c57aec58
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c57aec58
Branch: refs/heads/master
Commit: c57aec585bbe5019d8536234b629664a1c40ce7f
Parents: f543a11 29d87ac
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 27 13:57:57 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 27 13:57:57 2014 +0200
----------------------------------------------------------------------
.../dataformat/barcode/BarcodeDataFormat.java | 14 +++++++-----
.../barcode/BarcodeDataFormatCamelTest.java | 23 ++++++++++++++++++++
.../barcode/barcodeDataformatSpring.xml | 9 +++++++-
3 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
[8/8] git commit: CAMEL-7871 configure ERROR_CORRECTION only if
barcode format is QR code
Posted by da...@apache.org.
CAMEL-7871 configure ERROR_CORRECTION only if barcode format is QR code
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/29d87acb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/29d87acb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/29d87acb
Branch: refs/heads/master
Commit: 29d87acb693e2545bb9ec0791880b5a5a168880d
Parents: ecaafc4
Author: Seiji Sogabe <s....@gmail.com>
Authored: Sun Sep 28 05:36:48 2014 +0900
Committer: Seiji Sogabe <s....@gmail.com>
Committed: Sun Sep 28 05:38:38 2014 +0900
----------------------------------------------------------------------
.../dataformat/barcode/BarcodeDataFormat.java | 14 +++++++-----
.../barcode/BarcodeDataFormatCamelTest.java | 23 ++++++++++++++++++++
.../barcode/barcodeDataformatSpring.xml | 9 +++++++-
3 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/29d87acb/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
index 7639eaf..1dd5f9b 100644
--- a/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
+++ b/components/camel-barcode/src/main/java/org/apache/camel/dataformat/barcode/BarcodeDataFormat.java
@@ -191,11 +191,15 @@ public class BarcodeDataFormat implements DataFormat {
this.readerHintMap.clear();
// writer hints
- this.writerHintMap
- .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
-
- if (this.params.getFormat().toString()
- .equals(BarcodeFormat.DATA_MATRIX.toString())) {
+ String format = this.params.getFormat().toString();
+
+ // only for QR code. AZTEC uses zxing's default error correction 33%.
+ if (format.equals(BarcodeFormat.QR_CODE.toString())) {
+ this.writerHintMap
+ .put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+ }
+
+ if (format.equals(BarcodeFormat.DATA_MATRIX.toString())) {
this.writerHintMap
.put(EncodeHintType.DATA_MATRIX_SHAPE
, SymbolShapeHint.FORCE_SQUARE);
http://git-wip-us.apache.org/repos/asf/camel/blob/29d87acb/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
index b5a5d6b..308cf2d 100644
--- a/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
+++ b/components/camel-barcode/src/test/java/org/apache/camel/dataformat/barcode/BarcodeDataFormatCamelTest.java
@@ -120,6 +120,23 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
this.checkImage(image, "JPEG", BarcodeFormat.PDF_417);
}
+ /**
+ * tests barcode (AZTEC).
+ *
+ * @throws Exception
+ * @see CAMEL-7681
+ */
+ @Test
+ public void testAZTECWidthModifiedSizeAndImageType() throws Exception {
+ out.expectedBodiesReceived(MSG);
+ image.expectedMessageCount(1);
+
+ template.sendBody("direct:code5", MSG);
+
+ assertMockEndpointsSatisfied(60, TimeUnit.SECONDS);
+ this.checkImage(image, 200, 200, "PNG", BarcodeFormat.AZTEC);
+ }
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@@ -154,6 +171,12 @@ public class BarcodeDataFormatCamelTest extends BarcodeTestBase {
.marshal(code4)
.to(FILE_ENDPOINT);
+ // AZTEC with modified size and PNG type
+ DataFormat code5 = new BarcodeDataFormat(200, 200, BarcodeImageType.PNG, BarcodeFormat.AZTEC);
+
+ from("direct:code5")
+ .marshal(code5)
+ .to(FILE_ENDPOINT);
// generic file read --->
//
http://git-wip-us.apache.org/repos/asf/camel/blob/29d87acb/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
----------------------------------------------------------------------
diff --git a/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml b/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
index 1c12d9b..2e80909 100644
--- a/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
+++ b/components/camel-barcode/src/test/resources/org/apache/camel/dataformat/barcode/barcodeDataformatSpring.xml
@@ -31,6 +31,7 @@
<barcode id="code2" width="200" height="200" />
<barcode id="code3" imageType="JPG" />
<barcode id="code4" width="200" height="200" imageType="JPG" barcodeFormat="PDF_417"/>
+ <barcode id="code5" width="200" height="200" imageType="PNG" barcodeFormat="AZTEC"/>
</dataFormats>
@@ -57,7 +58,13 @@
<marshal ref="code4"/>
<to uri="file:target/out"/>
</route>
-
+
+ <route>
+ <from uri="direct:code5"/>
+ <marshal ref="code5"/>
+ <to uri="file:target/out"/>
+ </route>
+
<route>
<from uri="file:target/out?noop=true"/>
<multicast>
[6/8] git commit: CAMEL-7855: Fixed resuming JMS consumer to work if
the route has never been initialized before.
Posted by da...@apache.org.
CAMEL-7855: Fixed resuming JMS consumer to work if the route has never been initialized before.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5c331211
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5c331211
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5c331211
Branch: refs/heads/camel-2.13.x
Commit: 5c331211e22691eb3c3fe74746a90542b9a1326d
Parents: b840c4d
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 27 13:55:53 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 27 14:15:48 2014 +0200
----------------------------------------------------------------------
.../apache/camel/component/jms/JmsConsumer.java | 9 +-
.../jms/issues/JmsLifecycleIssueTest.java | 93 ++++++++++++++++++++
2 files changed, 100 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/5c331211/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
index 87f39fa..5d66555 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
@@ -230,8 +230,13 @@ public class JmsConsumer extends DefaultConsumer implements SuspendableService {
@Override
protected void doResume() throws Exception {
- if (listenerContainer != null) {
- startListenerContainer();
+ // we may not have been started before, and now the end user calls resume, so lets handle that and start it first
+ if (!initialized) {
+ doStart();
+ } else {
+ if (listenerContainer != null) {
+ startListenerContainer();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/5c331211/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
new file mode 100644
index 0000000..32fb137
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.jms.issues;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.CamelJmsTestHelper;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.ServiceStatus.Started;
+import static org.apache.camel.ServiceStatus.Stopped;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+public class JmsLifecycleIssueTest extends CamelTestSupport {
+
+ public static final String ROUTE_ID = "simpleRoute";
+ public static final String ENDPOINT_URI = "activemq:processOrder";
+
+ @Test
+ public void routeThatIsStoppedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ @Test
+ public void routeThatIsStoppedSuspendedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.suspendRoute(ROUTE_ID);
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ private void assertThatRouteIs(ServiceStatus expectedStatus) {
+ assertEquals(expectedStatus, context.getRouteStatus(ROUTE_ID));
+ }
+
+ private void assertRouteWorks() throws Exception {
+ assertThatRouteIs(Started);
+
+ getMockEndpoint("mock:result").expectedBodiesReceived("anything");
+
+ template.sendBody(ENDPOINT_URI, "anything");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+ ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+ camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from(ENDPOINT_URI).routeId(ROUTE_ID).autoStartup(false)
+ .to("log:input")
+ .to("mock:result");
+ }
+ });
+ }
+ };
+ }
+}
[4/8] git commit: CAMEL-7855: Fixed resuming JMS consumer to work if
the route has never been initialized before.
Posted by da...@apache.org.
CAMEL-7855: Fixed resuming JMS consumer to work if the route has never been initialized before.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fa62b651
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fa62b651
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fa62b651
Branch: refs/heads/camel-2.14.x
Commit: fa62b651db4f26a4c6320c28c453c6be0e5e81b9
Parents: 728a4c5
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 27 13:55:53 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 27 14:15:29 2014 +0200
----------------------------------------------------------------------
.../apache/camel/component/jms/JmsConsumer.java | 9 +-
.../jms/issues/JmsLifecycleIssueTest.java | 93 ++++++++++++++++++++
2 files changed, 100 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fa62b651/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
index 87f39fa..5d66555 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
@@ -230,8 +230,13 @@ public class JmsConsumer extends DefaultConsumer implements SuspendableService {
@Override
protected void doResume() throws Exception {
- if (listenerContainer != null) {
- startListenerContainer();
+ // we may not have been started before, and now the end user calls resume, so lets handle that and start it first
+ if (!initialized) {
+ doStart();
+ } else {
+ if (listenerContainer != null) {
+ startListenerContainer();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/fa62b651/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
new file mode 100644
index 0000000..32fb137
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.jms.issues;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.CamelJmsTestHelper;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.ServiceStatus.Started;
+import static org.apache.camel.ServiceStatus.Stopped;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+public class JmsLifecycleIssueTest extends CamelTestSupport {
+
+ public static final String ROUTE_ID = "simpleRoute";
+ public static final String ENDPOINT_URI = "activemq:processOrder";
+
+ @Test
+ public void routeThatIsStoppedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ @Test
+ public void routeThatIsStoppedSuspendedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.suspendRoute(ROUTE_ID);
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ private void assertThatRouteIs(ServiceStatus expectedStatus) {
+ assertEquals(expectedStatus, context.getRouteStatus(ROUTE_ID));
+ }
+
+ private void assertRouteWorks() throws Exception {
+ assertThatRouteIs(Started);
+
+ getMockEndpoint("mock:result").expectedBodiesReceived("anything");
+
+ template.sendBody(ENDPOINT_URI, "anything");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+ ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+ camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from(ENDPOINT_URI).routeId(ROUTE_ID).autoStartup(false)
+ .to("log:input")
+ .to("mock:result");
+ }
+ });
+ }
+ };
+ }
+}
[7/8] git commit: CAMEL-7855: Fixed resuming JMS consumer to work if
the route has never been initialized before.
Posted by da...@apache.org.
CAMEL-7855: Fixed resuming JMS consumer to work if the route has never been initialized before.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f5ae2b70
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f5ae2b70
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f5ae2b70
Branch: refs/heads/camel-2.12.x
Commit: f5ae2b7080a2711db4b0a89418a904fa5f93190e
Parents: c288a7d
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Sep 27 13:55:53 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Sep 27 14:16:03 2014 +0200
----------------------------------------------------------------------
.../apache/camel/component/jms/JmsConsumer.java | 9 +-
.../jms/issues/JmsLifecycleIssueTest.java | 93 ++++++++++++++++++++
2 files changed, 100 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f5ae2b70/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
index 7bf6ab5..7d17b62 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
@@ -230,8 +230,13 @@ public class JmsConsumer extends DefaultConsumer implements SuspendableService {
@Override
protected void doResume() throws Exception {
- if (listenerContainer != null) {
- startListenerContainer();
+ // we may not have been started before, and now the end user calls resume, so lets handle that and start it first
+ if (!initialized) {
+ doStart();
+ } else {
+ if (listenerContainer != null) {
+ startListenerContainer();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/f5ae2b70/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
new file mode 100644
index 0000000..32fb137
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsLifecycleIssueTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.jms.issues;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.CamelJmsTestHelper;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.ServiceStatus.Started;
+import static org.apache.camel.ServiceStatus.Stopped;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+public class JmsLifecycleIssueTest extends CamelTestSupport {
+
+ public static final String ROUTE_ID = "simpleRoute";
+ public static final String ENDPOINT_URI = "activemq:processOrder";
+
+ @Test
+ public void routeThatIsStoppedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ @Test
+ public void routeThatIsStoppedSuspendedAndThenResumedAcceptsMessage() throws Exception {
+ assertThatRouteIs(Stopped);
+
+ context.suspendRoute(ROUTE_ID);
+ context.resumeRoute(ROUTE_ID);
+
+ assertRouteWorks();
+ }
+
+ private void assertThatRouteIs(ServiceStatus expectedStatus) {
+ assertEquals(expectedStatus, context.getRouteStatus(ROUTE_ID));
+ }
+
+ private void assertRouteWorks() throws Exception {
+ assertThatRouteIs(Started);
+
+ getMockEndpoint("mock:result").expectedBodiesReceived("anything");
+
+ template.sendBody(ENDPOINT_URI, "anything");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+ ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+ camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from(ENDPOINT_URI).routeId(ROUTE_ID).autoStartup(false)
+ .to("log:input")
+ .to("mock:result");
+ }
+ });
+ }
+ };
+ }
+}