You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Frank <fd...@gmail.com> on 2012/03/06 19:06:44 UTC

Sending multiple messages in Camel

When I am trying to send multiple messages, I am getting the below error
message.

Exhausted after delivery attempt: 1 caught:
java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the same
endpoint.

Also, please see the attached files for the routes. If I comment out the
line
"template.sendBody("direct:a","second message");" in Main class it works
fine. But I don't want to comment that line. Please help me how to solve
this problem.
http://camel.465427.n5.nabble.com/file/n5541723/files.zip files.zip 

Thanks,
Frank

--
View this message in context: http://camel.465427.n5.nabble.com/Sending-multiple-messages-in-Camel-tp5541723p5541723.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Sending multiple messages in Camel

Posted by Ashwin Karpe <ak...@fusesource.com>.
Oops... Should have looked at the error closer.

Yes it is exactly as Claus mentioned... You have 2 routes consuming from the
same Direct endpoint...

Strangely in the zip file, I missed this in the code. Are you sure your code
is identical to the one in the Zip file..

In any case, you have your answer... In fact, you also have answers to
issues, you may encountered down the road in my response ;)

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Sending-multiple-messages-in-Camel-tp5541723p5547938.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Sending multiple messages in Camel

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The direct component only allow 1 route to consume from the same
endpoint. So in your case you have 2 or more routes that are from the
same direct endpoint.



On Wed, Mar 7, 2012 at 6:31 AM, Frank <fd...@gmail.com> wrote:
> Hi Ashwin,
>
> I am getting the same error after I changed to template.requestBody(). I am
> unable to figure it out. Could you help me?
>
> Exhausted after delivery attempt: 1 caught:
> java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the same
> endpoint. Endpoint Endpoint[direct://level2] only allows one consumer.
> java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the same
> endpoint. Endpoint Endpoint[direct://level2] only allows one consumer.
>
> Thanks,
> Frank
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Sending-multiple-messages-in-Camel-tp5541723p5543220.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Sending multiple messages in Camel

Posted by Frank <fd...@gmail.com>.
Hi Ashwin, 

I am getting the same error after I changed to template.requestBody(). I am
unable to figure it out. Could you help me?

Exhausted after delivery attempt: 1 caught:
java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the same
endpoint. Endpoint Endpoint[direct://level2] only allows one consumer.
java.lang.IllegalArgumentException: Cannot add a 2nd consumer to the same
endpoint. Endpoint Endpoint[direct://level2] only allows one consumer.

Thanks, 
Frank

--
View this message in context: http://camel.465427.n5.nabble.com/Sending-multiple-messages-in-Camel-tp5541723p5543220.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Sending multiple messages in Camel

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Your route expects to send back a response, however you are using
template.sendBody() that does not expect to receive anything (one-way send).

If you expect to receive a response from your bean, you should use
template.requestBody() that sends a request and expects a response.

Cheers,

Ashwin...

P.S: I have not inspected your beans closely but notice that they have
return values... You may also want to append a logger and/or a camel tracer
to trace messages flowing through the route...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Sending-multiple-messages-in-Camel-tp5541723p5542792.html
Sent from the Camel - Users mailing list archive at Nabble.com.