camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-12022) direct component - Let the producer able to block and wait for consumers to be started
Date Sun, 17 Dec 2017 18:37:02 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-12022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16294258#comment-16294258
] 

ASF GitHub Bot commented on CAMEL-12022:
----------------------------------------

davsclaus closed pull request #2125: "CAMEL-12022:direct component - Let the producer able
to block and wa…
URL: https://github.com/apache/camel/pull/2125
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/camel-core/src/main/docs/direct-component.adoc b/camel-core/src/main/docs/direct-component.adoc
index 4c035b68196..6dea0bc8634 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 d6f7b213da6..77f5ace3ea9 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 200f6884ddc..e1dee2541e3 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 @@
     // 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 855a30d7a7f..cf3db0405f3 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 @@
     @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 26ecca8ae49..0577e3aad87 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 @@
     // 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 9ecdeaba178..b4188cfc734 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 @@
     @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 a756ea6ecd2..19366ffb66c 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 void configure() throws Exception {
         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 void configure() throws Exception {
         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 53867747aca..ffb319d7413 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 boolean applyFilterToCamelHeaders(String headerName, Object headerValue,
             }
         });
         
-        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 ae9789978d1..9e0ff4d4242 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 void configure() throws Exception {
         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 void configure() throws Exception {
         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 23b2598ebf1..8e4d09be764 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 @@ protected CamelContext createCamelContext() throws Exception {
         
         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 6a94bba736f..b64f4c8003f 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 void configure() throws Exception {
                 // 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 1b5b0f35974..24e2f5fbf92 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 @@
 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 8bae6645590..49ff49a1f42 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 @@
 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 37a4a43034b..5a77b969dd3 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 @@
      * 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 f87ab23c1d4..2c7787be8bf 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 @@
      * 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.
      */


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> direct component - Let the producer able to block and wait for consumers to be started
> --------------------------------------------------------------------------------------
>
>                 Key: CAMEL-12022
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12022
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.21.0
>
>
> Similar to what direct-vm component can do. We should let the direct producer detect
that if there is no consumer yet, then it can wait until its ready (with timeout) during starting
routes. 
> This can avoid the slim chance during route startup that you get a DirectConsumerNotAvailableException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message