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 2019/12/30 09:11:22 UTC
[camel] 02/05: CAMEL-14327: camel-jt400 no longer needs to be non
singleton. Thanks to Rafal Gala for the 2nd patch.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 868eb80aa2071634c6bbdf894a8d07b20b046e22
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Dec 30 10:07:37 2019 +0100
CAMEL-14327: camel-jt400 no longer needs to be non singleton. Thanks to Rafal Gala for the 2nd patch.
---
.../component/jt400/Jt400DataQueueProducer.java | 26 +++++++---------------
.../component/jt400/Jt400DataQueueService.java | 10 +++++++--
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java
index 8f3c282..65c38ba 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueProducer.java
@@ -33,12 +33,9 @@ public class Jt400DataQueueProducer extends DefaultProducer {
/**
* Performs the lifecycle logic of this producer.
*/
- private final Jt400DataQueueService queueService;
-
protected Jt400DataQueueProducer(Jt400Endpoint endpoint) {
super(endpoint);
this.endpoint = endpoint;
- this.queueService = new Jt400DataQueueService(endpoint);
}
/**
@@ -53,11 +50,14 @@ public class Jt400DataQueueProducer extends DefaultProducer {
*/
@Override
public void process(Exchange exchange) throws Exception {
- BaseDataQueue queue = queueService.getDataQueue();
- if (endpoint.isKeyed()) {
- process((KeyedDataQueue) queue, exchange);
- } else {
- process((DataQueue) queue, exchange);
+ try (Jt400DataQueueService queueService = new Jt400DataQueueService(endpoint)) {
+ queueService.start();
+ BaseDataQueue queue = queueService.getDataQueue();
+ if (endpoint.isKeyed()) {
+ process((KeyedDataQueue) queue, exchange);
+ } else {
+ process((DataQueue) queue, exchange);
+ }
}
}
@@ -77,14 +77,4 @@ public class Jt400DataQueueProducer extends DefaultProducer {
}
}
- @Override
- protected void doStart() throws Exception {
- queueService.start();
- }
-
- @Override
- protected void doStop() throws Exception {
- queueService.stop();
- }
-
}
diff --git a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
index 40aaecd..276494a 100644
--- a/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
+++ b/components/camel-jt400/src/main/java/org/apache/camel/component/jt400/Jt400DataQueueService.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.jt400;
+import java.io.IOException;
+
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.BaseDataQueue;
import com.ibm.as400.access.DataQueue;
@@ -69,7 +71,7 @@ class Jt400DataQueueService implements Service {
}
}
if (!queue.getSystem().isConnected(AS400.DATAQUEUE)) {
- LOG.info("Connecting to {}", endpoint);
+ LOG.debug("Connecting to {}", endpoint);
try {
queue.getSystem().connectService(AS400.DATAQUEUE);
} catch (Exception e) {
@@ -81,7 +83,7 @@ class Jt400DataQueueService implements Service {
@Override
public void stop() {
if (queue != null) {
- LOG.info("Releasing connection to {}", endpoint);
+ LOG.debug("Releasing connection to {}", endpoint);
AS400 system = queue.getSystem();
queue = null;
endpoint.releaseSystem(system);
@@ -99,4 +101,8 @@ class Jt400DataQueueService implements Service {
return queue;
}
+ @Override
+ public void close() throws IOException {
+ stop();
+ }
}