This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 39986dd CAMEL-17190: camel-quickfix - Add option to turn off eager stop engines to have the old behaviour if needed. 39986dd is described below commit 39986dd8021da5143ff81595de11d5841fdb6f4b Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Nov 14 09:25:33 2021 +0100 CAMEL-17190: camel-quickfix - Add option to turn off eager stop engines to have the old behaviour if needed. --- .../apache/camel/catalog/components/quickfix.json | 1 + .../quickfixj/QuickfixjComponentConfigurer.java | 6 ++++++ .../apache/camel/component/quickfixj/quickfix.json | 1 + .../component/quickfixj/QuickfixjComponent.java | 20 +++++++++++++++++++- .../component/quickfixj/QuickfixjEndpoint.java | 4 ++-- .../dsl/QuickfixComponentBuilderFactory.java | 21 +++++++++++++++++++++ 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/quickfix.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/quickfix.json index 09798ed..1ac6801 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/quickfix.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/quickfix.json @@ -22,6 +22,7 @@ "lenientProperties": false }, "componentProperties": { + "eagerStopEngines": { "kind": "property", "displayName": "Eager Stop Engines", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to eager stop engines when there are no active consumer or producers using the engine. For example when stopping a route, then the engine can be stopped as well. And when the route is started, then the engine is [...] "lazyCreateEngines": { "kind": "property", "displayName": "Lazy Create Engines", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true, the engines will be created and started when needed (when first message is send)" }, "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a me [...] "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] diff --git a/components/camel-quickfix/src/generated/java/org/apache/camel/component/quickfixj/QuickfixjComponentConfigurer.java b/components/camel-quickfix/src/generated/java/org/apache/camel/component/quickfixj/QuickfixjComponentConfigurer.java index 71a9ceb..6538995 100644 --- a/components/camel-quickfix/src/generated/java/org/apache/camel/component/quickfixj/QuickfixjComponentConfigurer.java +++ b/components/camel-quickfix/src/generated/java/org/apache/camel/component/quickfixj/QuickfixjComponentConfigurer.java @@ -25,6 +25,8 @@ public class QuickfixjComponentConfigurer extends PropertyConfigurerSupport impl case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; + case "eagerstopengines": + case "eagerStopEngines": target.setEagerStopEngines(property(camelContext, boolean.class, value)); return true; case "lazycreateengines": case "lazyCreateEngines": target.setLazyCreateEngines(property(camelContext, boolean.class, value)); return true; case "lazystartproducer": @@ -46,6 +48,8 @@ public class QuickfixjComponentConfigurer extends PropertyConfigurerSupport impl case "autowiredEnabled": return boolean.class; case "bridgeerrorhandler": case "bridgeErrorHandler": return boolean.class; + case "eagerstopengines": + case "eagerStopEngines": return boolean.class; case "lazycreateengines": case "lazyCreateEngines": return boolean.class; case "lazystartproducer": @@ -68,6 +72,8 @@ public class QuickfixjComponentConfigurer extends PropertyConfigurerSupport impl case "autowiredEnabled": return target.isAutowiredEnabled(); case "bridgeerrorhandler": case "bridgeErrorHandler": return target.isBridgeErrorHandler(); + case "eagerstopengines": + case "eagerStopEngines": return target.isEagerStopEngines(); case "lazycreateengines": case "lazyCreateEngines": return target.isLazyCreateEngines(); case "lazystartproducer": diff --git a/components/camel-quickfix/src/generated/resources/org/apache/camel/component/quickfixj/quickfix.json b/components/camel-quickfix/src/generated/resources/org/apache/camel/component/quickfixj/quickfix.json index 09798ed..1ac6801 100644 --- a/components/camel-quickfix/src/generated/resources/org/apache/camel/component/quickfixj/quickfix.json +++ b/components/camel-quickfix/src/generated/resources/org/apache/camel/component/quickfixj/quickfix.json @@ -22,6 +22,7 @@ "lenientProperties": false }, "componentProperties": { + "eagerStopEngines": { "kind": "property", "displayName": "Eager Stop Engines", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to eager stop engines when there are no active consumer or producers using the engine. For example when stopping a route, then the engine can be stopped as well. And when the route is started, then the engine is [...] "lazyCreateEngines": { "kind": "property", "displayName": "Lazy Create Engines", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true, the engines will be created and started when needed (when first message is send)" }, "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a me [...] "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] diff --git a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java index 66afb63..632c395 100644 --- a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java +++ b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java @@ -56,6 +56,8 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe private MessageFactory messageFactory; @Metadata private boolean lazyCreateEngines; + @Metadata(defaultValue = "true") + private boolean eagerStopEngines = true; public QuickfixjComponent() { } @@ -210,12 +212,28 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe } /** - * If set to <code>true</code>, the engines will be created and started when needed (when first message is send) + * If set to true, the engines will be created and started when needed (when first message is send) */ public void setLazyCreateEngines(boolean lazyCreateEngines) { this.lazyCreateEngines = lazyCreateEngines; } + public boolean isEagerStopEngines() { + return eagerStopEngines; + } + + /** + * Whether to eager stop engines when there are no active consumer or producers using the engine. + * + * For example when stopping a route, then the engine can be stopped as well. And when the route is started, then + * the engine is started again. + * + * This can be turned off to only stop the engines when Camel is shutdown. + */ + public void setEagerStopEngines(boolean eagerStopEngines) { + this.eagerStopEngines = eagerStopEngines; + } + @Override public void onCamelContextStarted(CamelContext camelContext, boolean alreadyStarted) throws Exception { // only start quickfix engines when CamelContext have finished starting diff --git a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java index 3851fac..6dc74b4 100644 --- a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java +++ b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEndpoint.java @@ -148,7 +148,7 @@ public class QuickfixjEndpoint extends DefaultEndpoint implements QuickfixjEvent protected void removeConsumer(QuickfixjConsumer consumer) { consumers.remove(consumer); int count = engine.decRefCount(); - if (count <= 0) { + if (count <= 0 && getComponent().isEagerStopEngines()) { LOG.info("Stopping QuickFIX/J Engine: {} no longer active in use", engine.getUri()); ServiceHelper.stopService(engine); } @@ -161,7 +161,7 @@ public class QuickfixjEndpoint extends DefaultEndpoint implements QuickfixjEvent protected void removeProducer(QuickfixjProducer producer) { int count = engine.decRefCount(); - if (count <= 0) { + if (count <= 0 && getComponent().isEagerStopEngines()) { LOG.info("Stopping QuickFIX/J Engine: {} no longer active in use", engine.getUri()); ServiceHelper.stopService(engine); } diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/QuickfixComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/QuickfixComponentBuilderFactory.java index 4766269..41991a2 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/QuickfixComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/QuickfixComponentBuilderFactory.java @@ -53,6 +53,26 @@ public interface QuickfixComponentBuilderFactory { extends ComponentBuilder<QuickfixjComponent> { /** + * Whether to eager stop engines when there are no active consumer or + * producers using the engine. For example when stopping a route, then + * the engine can be stopped as well. And when the route is started, + * then the engine is started again. This can be turned off to only stop + * the engines when Camel is shutdown. + * + * The option is a: <code>boolean</code> type. + * + * Default: true + * Group: common + * + * @param eagerStopEngines the value to set + * @return the dsl builder + */ + default QuickfixComponentBuilder eagerStopEngines( + boolean eagerStopEngines) { + doSetProperty("eagerStopEngines", eagerStopEngines); + return this; + } + /** * If set to true, the engines will be created and started when needed * (when first message is send). * @@ -200,6 +220,7 @@ public interface QuickfixComponentBuilderFactory { String name, Object value) { switch (name) { + case "eagerStopEngines": ((QuickfixjComponent) component).setEagerStopEngines((boolean) value); return true; case "lazyCreateEngines": ((QuickfixjComponent) component).setLazyCreateEngines((boolean) value); return true; case "bridgeErrorHandler": ((QuickfixjComponent) component).setBridgeErrorHandler((boolean) value); return true; case "lazyStartProducer": ((QuickfixjComponent) component).setLazyStartProducer((boolean) value); return true;