This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit cde349fc9b1e85f9ad6054644a766977ee11a819 Author: Ramu <kkaka...@redhat.com> AuthorDate: Fri Dec 1 14:35:37 2017 +0530 "CAMEL-12022:direct component - Let the producer able to block and wait for consumers to be started" --- camel-core/src/main/docs/direct-component.adoc | 4 ++-- camel-core/src/main/docs/direct-vm-component.adoc | 4 ++-- .../org/apache/camel/component/direct/DirectComponent.java | 4 ++-- .../org/apache/camel/component/direct/DirectEndpoint.java | 4 ++-- .../apache/camel/component/directvm/DirectVmComponent.java | 4 ++-- .../apache/camel/component/directvm/DirectVmEndpoint.java | 4 ++-- .../apache/camel/component/direct/DirectNoConsumerTest.java | 12 +++++++----- .../component/directvm/DirectVmHeaderFilterStrategyTest.java | 2 +- .../camel/component/directvm/DirectVmNoConsumerTest.java | 12 +++++++----- .../directvm/DirectVmNoPropertyPropagationComponentTest.java | 1 + .../directvm/DirectVmNoPropertyPropagationTest.java | 2 +- .../ThrottlingExceptionRoutePolicyHalfOpenHandlerTest.java | 2 +- .../ThrottlingExceptionRoutePolicyHalfOpenTest.java | 2 +- .../direct/springboot/DirectComponentConfiguration.java | 2 +- .../directvm/springboot/DirectVmComponentConfiguration.java | 2 +- 15 files changed, 33 insertions(+), 28 deletions(-) diff --git a/camel-core/src/main/docs/direct-component.adoc b/camel-core/src/main/docs/direct-component.adoc index 4c035b6..6dea0bc 100644 --- a/camel-core/src/main/docs/direct-component.adoc +++ b/camel-core/src/main/docs/direct-component.adoc @@ -36,7 +36,7 @@ The Direct component supports 3 options which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | false | boolean +| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | true | boolean | *timeout* (producer) | The timeout value to use if block is enabled. | 30000 | long | *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean |=== @@ -70,7 +70,7 @@ with the following path and query parameters: | *bridgeErrorHandler* (consumer) | 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 message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. | false | boolean | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the default exchange pattern when creating an exchange. | | ExchangePattern -| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | false | boolean +| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | true | boolean | *failIfNoConsumers* (producer) | Whether the producer should fail by throwing an exception when sending to a DIRECT endpoint with no active consumers. | false | boolean | *timeout* (producer) | The timeout value to use if block is enabled. | 30000 | long | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean diff --git a/camel-core/src/main/docs/direct-vm-component.adoc b/camel-core/src/main/docs/direct-vm-component.adoc index d6f7b21..77f5ace 100644 --- a/camel-core/src/main/docs/direct-vm-component.adoc +++ b/camel-core/src/main/docs/direct-vm-component.adoc @@ -47,7 +47,7 @@ The Direct VM component supports 5 options which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | false | boolean +| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | true | boolean | *timeout* (producer) | The timeout value to use if block is enabled. | 30000 | long | *headerFilterStrategy* (advanced) | Sets a HeaderFilterStrategy that will only be applied on producer endpoints (on both directions: request and response). Default value: none. | | HeaderFilterStrategy | *propagateProperties* (advanced) | Whether to propagate or not properties from the producer side to the consumer side and vice versa. Default value: true. | true | boolean @@ -83,7 +83,7 @@ with the following path and query parameters: | *bridgeErrorHandler* (consumer) | 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 message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. | false | boolean | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the default exchange pattern when creating an exchange. | | ExchangePattern -| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | false | boolean +| *block* (producer) | If sending a message to a direct endpoint which has no active consumer then we can tell the producer to block and wait for the consumer to become active. | true | boolean | *failIfNoConsumers* (producer) | Whether the producer should fail by throwing an exception when sending to a Direct-VM endpoint with no active consumers. | false | boolean | *timeout* (producer) | The timeout value to use if block is enabled. | 30000 | long | *headerFilterStrategy* (producer) | Sets a HeaderFilterStrategy that will only be applied on producer endpoints (on both directions: request and response). Default value: none. | | HeaderFilterStrategy diff --git a/camel-core/src/main/java/org/apache/camel/component/direct/DirectComponent.java b/camel-core/src/main/java/org/apache/camel/component/direct/DirectComponent.java index 200f688..e1dee25 100644 --- a/camel-core/src/main/java/org/apache/camel/component/direct/DirectComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/direct/DirectComponent.java @@ -35,8 +35,8 @@ public class DirectComponent extends UriEndpointComponent { // later in case the DirectEndpoint was re-created due the old was evicted from the endpoints LRUCache // on DefaultCamelContext private final Map<String, DirectConsumer> consumers = new HashMap<String, DirectConsumer>(); - @Metadata(label = "producer") - private boolean block; + @Metadata(label = "producer", defaultValue = "true" ) + private boolean block = true; @Metadata(label = "producer", defaultValue = "30000") private long timeout = 30000L; diff --git a/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java index 855a30d..cf3db04 100644 --- a/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/direct/DirectEndpoint.java @@ -43,8 +43,8 @@ public class DirectEndpoint extends DefaultEndpoint { @UriPath(description = "Name of direct endpoint") @Metadata(required = "true") private String name; - @UriParam(label = "producer") - private boolean block; + @UriParam(label = "producer", defaultValue = "true") + private boolean block = true; @UriParam(label = "producer", defaultValue = "30000") private long timeout = 30000L; @UriParam(label = "producer") diff --git a/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java b/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java index 26ecca8..0577e3a 100644 --- a/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java +++ b/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmComponent.java @@ -39,8 +39,8 @@ public class DirectVmComponent extends UriEndpointComponent { // later in case the DirectVmEndpoint was re-created due the old was evicted from the endpoints LRUCache // on DefaultCamelContext private static final ConcurrentMap<String, DirectVmConsumer> CONSUMERS = new ConcurrentHashMap<String, DirectVmConsumer>(); - @Metadata(label = "producer") - private boolean block; + @Metadata(label = "producer", defaultValue = "true") + private boolean block = true; @Metadata(label = "producer", defaultValue = "30000") private long timeout = 30000L; @Metadata(label = "advanced") diff --git a/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmEndpoint.java index 9ecdeab..b4188cf 100644 --- a/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmEndpoint.java @@ -39,8 +39,8 @@ public class DirectVmEndpoint extends DefaultEndpoint implements AsyncEndpoint { @UriPath(description = "Name of direct-vm endpoint") @Metadata(required = "true") private String name; - @UriParam(label = "producer") - private boolean block; + @UriParam(label = "producer", defaultValue = "true") + private boolean block = true; @UriParam(label = "producer", defaultValue = "30000") private long timeout = 30000L; @UriParam(label = "producer") diff --git a/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoConsumerTest.java b/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoConsumerTest.java index a756ea6..19366ff 100644 --- a/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoConsumerTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoConsumerTest.java @@ -82,7 +82,7 @@ public class DirectNoConsumerTest extends ContextTestSupport { try { template.sendBody("direct:start", "Hello World"); } catch (CamelExecutionException e) { - fail("Should not throw an exception"); + assertIsInstanceOf(DirectConsumerNotAvailableException.class, e.getCause()); } } @@ -146,10 +146,12 @@ public class DirectNoConsumerTest extends ContextTestSupport { context.start(); getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World"); - - template.sendBody("direct:in", "Hello World"); - - assertMockEndpointsSatisfied(); + try { + template.sendBody("direct:in", "Hello World"); + fail("Should throw an exception"); + } catch (CamelExecutionException e) { + assertIsInstanceOf(DirectConsumerNotAvailableException.class, e.getCause()); + } } diff --git a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmHeaderFilterStrategyTest.java b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmHeaderFilterStrategyTest.java index 5386774..ffb319d 100644 --- a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmHeaderFilterStrategyTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmHeaderFilterStrategyTest.java @@ -40,7 +40,7 @@ public class DirectVmHeaderFilterStrategyTest extends ContextTestSupport { } }); - Exchange response = template.request("direct-vm:start.filter?headerFilterStrategy=#headerFilterStrategy", exchange -> { + Exchange response = template.request("direct-vm:start.filter?headerFilterStrategy=#headerFilterStrategy&block=false", exchange -> { exchange.getIn().setBody("Hello World"); exchange.getIn().setHeader("Header1", "Value1"); }); diff --git a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoConsumerTest.java b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoConsumerTest.java index ae97899..9e0ff4d 100644 --- a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoConsumerTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoConsumerTest.java @@ -82,7 +82,7 @@ public class DirectVmNoConsumerTest extends ContextTestSupport { try { template.sendBody("direct-vm:start", "Hello World"); } catch (CamelExecutionException e) { - fail("Should not throw an exception"); + assertIsInstanceOf(DirectVmConsumerNotAvailableException.class, e.getCause()); } } @@ -146,10 +146,12 @@ public class DirectVmNoConsumerTest extends ContextTestSupport { context.start(); getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World"); - - template.sendBody("direct-vm:in", "Hello World"); - - assertMockEndpointsSatisfied(); + try { + template.sendBody("direct-vm:in", "Hello World"); + fail("Should throw an exception"); + } catch (CamelExecutionException e) { + assertIsInstanceOf(DirectVmConsumerNotAvailableException.class, e.getCause()); + } } diff --git a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationComponentTest.java b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationComponentTest.java index 23b2598..8e4d09b 100644 --- a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationComponentTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationComponentTest.java @@ -31,6 +31,7 @@ public class DirectVmNoPropertyPropagationComponentTest extends ContextTestSuppo DirectVmComponent directvm = new DirectVmComponent(); directvm.setPropagateProperties(false); + directvm.setBlock(false); context.addComponent("direct-vm", directvm); return context; diff --git a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationTest.java b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationTest.java index 6a94bba..b64f4c8 100644 --- a/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/directvm/DirectVmNoPropertyPropagationTest.java @@ -36,7 +36,7 @@ public class DirectVmNoPropertyPropagationTest extends ContextTestSupport { // Starters. from("direct-vm:start.noprops") .setProperty("abc", constant("def")) - .to("direct-vm:foo.noprops?propagateProperties=false"); + .to("direct-vm:foo.noprops?propagateProperties=false&block=false"); from("direct-vm:start.props") .setProperty("abc", constant("def")) diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenHandlerTest.java index 1b5b0f3..24e2f5f 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenHandlerTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenHandlerTest.java @@ -38,7 +38,7 @@ import static org.awaitility.Awaitility.await; public class ThrottlingExceptionRoutePolicyHalfOpenHandlerTest extends ContextTestSupport { private static Logger log = LoggerFactory.getLogger(ThrottlingExceptionRoutePolicyHalfOpenHandlerTest.class); - private String url = "direct:start"; + private String url = "direct:start?block=false"; private MockEndpoint result; @Before diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenTest.java b/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenTest.java index 8bae664..49ff49a 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/ThrottlingExceptionRoutePolicyHalfOpenTest.java @@ -37,7 +37,7 @@ import static org.awaitility.Awaitility.await; public class ThrottlingExceptionRoutePolicyHalfOpenTest extends ContextTestSupport { private static Logger log = LoggerFactory.getLogger(ThrottlingExceptionRoutePolicyHalfOpenTest.class); - private String url = "direct:start"; + private String url = "direct:start?block=false"; private MockEndpoint result; @Before diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentConfiguration.java index 37a4a43..5a77b96 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentConfiguration.java @@ -37,7 +37,7 @@ public class DirectComponentConfiguration * then we can tell the producer to block and wait for the consumer to * become active. */ - private Boolean block = false; + private Boolean block = true; /** * The timeout value to use if block is enabled. */ diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentConfiguration.java index f87ab23..2c7787b 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentConfiguration.java @@ -39,7 +39,7 @@ public class DirectVmComponentConfiguration * then we can tell the producer to block and wait for the consumer to * become active. */ - private Boolean block = false; + private Boolean block = true; /** * The timeout value to use if block is enabled. */ -- To stop receiving notification emails like this one, please contact "commits@camel.apache.org" <commits@camel.apache.org>.