You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jkorab <ja...@gmail.com> on 2013/01/22 23:06:13 UTC
Invalid endpoint on recipient list
Hi,
I am going through the recipient list pattern and am trying to work out what
constitutes an "invalid endpoint". Given the following RouteBuilder:
public class RecipientListUnrecognizedEndpointRouteBuilder extends
RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:in")
.setHeader("multicastTo").constant("direct:first,direct:second,direct:cheese")
.recipientList().header("multicastTo").ignoreInvalidEndpoints();
from("direct:first").to("mock:first");
from("direct:second").to("mock:second");
}
}
I would expect that if I send a message to "direct:in", the pattern would
not throw an exception when it reaches the "direct:cheese" endpoint, but it
does.
org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[Message: Message to be distributed via
recipientList]
...
Caused by: org.apache.camel.CamelExchangeException: No consumers available
on endpoint: Endpoint[direct://cheese]. Exchange[Message: Message to be
distributed via recipientList]
...
Test below.
public class RecipientListUnrecognizedEndpointTest extends CamelTestSupport
{
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RecipientListUnrecognizedEndpointRouteBuilder();
}
@Produce(uri = "direct:in")
protected ProducerTemplate template;
@EndpointInject(uri = "mock:first")
private MockEndpoint first;
@EndpointInject(uri = "mock:second")
private MockEndpoint second;
@Test
public void testMessageRoutedToMulticastEndpoints() throws
InterruptedException {
String messageBody = "Message to be distributed via recipientList";
first.setExpectedMessageCount(1);
first.message(0).equals(messageBody);
second.setExpectedMessageCount(1);
second.message(0).equals(messageBody);
template.sendBody(messageBody);
assertMockEndpointsSatisfied();
}
}
>From my reading of the wiki, and the Camel unit tests, the pattern only
determines that an endpoint is invalid if the component named is
unrecognized, whereas here it's a question of no consumers being available
on the endpoint. Is the use case that I have outlined something that ought
to be handled by the EIP?
Cheers,
Jakub
--
View this message in context: http://camel.465427.n5.nabble.com/Invalid-endpoint-on-recipient-list-tp5726030.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Invalid endpoint on recipient list
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jan 22, 2013 at 11:06 PM, jkorab <ja...@gmail.com> wrote:
> Hi,
>
> I am going through the recipient list pattern and am trying to work out what
> constitutes an "invalid endpoint". Given the following RouteBuilder:
>
> public class RecipientListUnrecognizedEndpointRouteBuilder extends
> RouteBuilder {
> @Override
> public void configure() throws Exception {
> from("direct:in")
>
> .setHeader("multicastTo").constant("direct:first,direct:second,direct:cheese")
> .recipientList().header("multicastTo").ignoreInvalidEndpoints();
>
> from("direct:first").to("mock:first");
>
> from("direct:second").to("mock:second");
> }
> }
>
> I would expect that if I send a message to "direct:in", the pattern would
> not throw an exception when it reaches the "direct:cheese" endpoint, but it
> does.
>
You have hit a edge case with the direct component. The endpoint
resolution is valid and hence working as designed.
Though since its a direct endpoint and when you actually use it, and
there is no running consumers, then the message
cannot be processed and you get a failure.
Its like sending to a HTTP server which is not responding etc. The
http endpoint is valid from Camel point of view.
But sending to it could fail.
Is this related to any real-life use-case or are you just playing with Camel?
> org.apache.camel.CamelExecutionException: Exception occurred during
> execution on the exchange: Exchange[Message: Message to be distributed via
> recipientList]
> ...
> Caused by: org.apache.camel.CamelExchangeException: No consumers available
> on endpoint: Endpoint[direct://cheese]. Exchange[Message: Message to be
> distributed via recipientList]
> ...
>
> Test below.
>
> public class RecipientListUnrecognizedEndpointTest extends CamelTestSupport
> {
>
> @Override
> protected RouteBuilder createRouteBuilder() throws Exception {
> return new RecipientListUnrecognizedEndpointRouteBuilder();
> }
>
> @Produce(uri = "direct:in")
> protected ProducerTemplate template;
>
> @EndpointInject(uri = "mock:first")
> private MockEndpoint first;
>
> @EndpointInject(uri = "mock:second")
> private MockEndpoint second;
>
> @Test
> public void testMessageRoutedToMulticastEndpoints() throws
> InterruptedException {
> String messageBody = "Message to be distributed via recipientList";
>
> first.setExpectedMessageCount(1);
> first.message(0).equals(messageBody);
> second.setExpectedMessageCount(1);
> second.message(0).equals(messageBody);
>
> template.sendBody(messageBody);
>
> assertMockEndpointsSatisfied();
> }
>
> }
>
> From my reading of the wiki, and the Camel unit tests, the pattern only
> determines that an endpoint is invalid if the component named is
> unrecognized, whereas here it's a question of no consumers being available
> on the endpoint. Is the use case that I have outlined something that ought
> to be handled by the EIP?
>
> Cheers,
>
> Jakub
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Invalid-endpoint-on-recipient-list-tp5726030.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen