You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "s.marjanovic" <sl...@gmail.com> on 2015/06/05 17:02:41 UTC

Netty component and acknowledgement message

Hello,

First time working with netty component and I run into issues while trying
to implement a chain of routes from a remote netty endpoint to ActiveMq
endpoint. I have a requirement that states a custom acknowledgement message
should be sent back to the remote netty endpoint. Different acknowledgement
messages are sent based on whether the exchange went well or failed in
Route2.

Routes are set up like this:

Route 1:
    from("remoteQueue")
    .to(remoteNettyEndpoint);

Route 2:
    from(myNettyEndpoint)
    .routePolicyRef("myRoutePolicy")
    .processRef("myProcessor")
    .to("myQueue");



myNettyEndpoint is a consumer server with sync option set to true in order
to enforce the InOut MEP. I was hoping that I could (ab)use this and put my
custom acknowledgement message into exchange like this:

exchange.getOut().setBody("ACK")

This is done in myRoutePolicy implementation that only implements the
onExchangeDone method.

remoteNettyEndpoint is a blackbox for me and it expects a custom
acknowledgement message when it send a message to myNettyEndpoint and that
message is processed by Route2.

In sunny day scenario, when there are no exceptions being thrown by
myProcessor which processes the message and puts the result into exchange, I
get a timeout exception 

org.apache.camel.ExchangeTimedOutException: The OUT message was not received
within: 20000 millis due reply message with correlationID ....

and the custom acknowledgement message I put into exchange in myRoutePolicy
implementation ends up on myQueue which I don't want to happen.

Can someone please point out where am I making the mistake here?

Regards,
Slavisa



--
View this message in context: http://camel.465427.n5.nabble.com/Netty-component-and-acknowledgement-message-tp5767915.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Netty component and acknowledgement message

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

See this FAQ
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

On Mon, Jun 8, 2015 at 11:19 AM, s.marjanovic
<sl...@gmail.com> wrote:
> Hello Claus,
>
> Thanks for the suggestion, setting the exchange pattern to InOut helped with
> the timeout issue. Great tip allaround, wasn't aware of the possibility to
> explicitly influence the MEP type of the exchange, thanks.
>
> Got another problem though, I'm putting the acknowledgement messages I
> mentioned into Out part of the exchange (exchange.getOut().setBody("ACK")
> in myRoutePolicy.onExchangeDone()) expecting that is the proper way to make
> a route send a response for the incoming messages. Partly, I think it's
> working. These do appear in the logs:
>
> Route2 log:
> Channel: [id: 0x9c1f061a, /127.0.0.1:52671 => /127.0.0.1:9010] writing body:
> Nak
>
> Route1 log:
> Channel: [id: 0xb32b3cf5, /127.0.0.1:52671 => localhost/127.0.0.1:9010]
> received body: Nak
>
> Looking at this, I see that netty endpoint from Route 1 received body "Nak".
>
> But the "Nak" message also ends up on "myQueue" which is wrong for my
> usecase. How can I make it stop getting routed to "myQueue" and keep the
> rest of the behavior?
>
> Regards,
> Slavisa
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Netty-component-and-acknowledgement-message-tp5767915p5767964.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Netty component and acknowledgement message

Posted by "s.marjanovic" <sl...@gmail.com>.
Hello Claus,

Thanks for the suggestion, setting the exchange pattern to InOut helped with
the timeout issue. Great tip allaround, wasn't aware of the possibility to
explicitly influence the MEP type of the exchange, thanks.

Got another problem though, I'm putting the acknowledgement messages I
mentioned into Out part of the exchange (exchange.getOut().setBody("ACK") 
in myRoutePolicy.onExchangeDone()) expecting that is the proper way to make
a route send a response for the incoming messages. Partly, I think it's
working. These do appear in the logs:

Route2 log:
Channel: [id: 0x9c1f061a, /127.0.0.1:52671 => /127.0.0.1:9010] writing body:
Nak

Route1 log:
Channel: [id: 0xb32b3cf5, /127.0.0.1:52671 => localhost/127.0.0.1:9010]
received body: Nak

Looking at this, I see that netty endpoint from Route 1 received body "Nak".

But the "Nak" message also ends up on "myQueue" which is wrong for my
usecase. How can I make it stop getting routed to "myQueue" and keep the
rest of the behavior?

Regards,
Slavisa



--
View this message in context: http://camel.465427.n5.nabble.com/Netty-component-and-acknowledgement-message-tp5767915p5767964.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Netty component and acknowledgement message

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

If .to("myQueue"); is using InOut as MEP and "myQueue" is JMS based
then its doing request/reply too, and therefore would expect a reply
message and if not you get a timeout error after 20 seconds.

If you just want to do a fire and forget on the queue then use event
message pattern
http://camel.apache.org/event-message.html

On Fri, Jun 5, 2015 at 5:02 PM, s.marjanovic
<sl...@gmail.com> wrote:
> Hello,
>
> First time working with netty component and I run into issues while trying
> to implement a chain of routes from a remote netty endpoint to ActiveMq
> endpoint. I have a requirement that states a custom acknowledgement message
> should be sent back to the remote netty endpoint. Different acknowledgement
> messages are sent based on whether the exchange went well or failed in
> Route2.
>
> Routes are set up like this:
>
> Route 1:
>     from("remoteQueue")
>     .to(remoteNettyEndpoint);
>
> Route 2:
>     from(myNettyEndpoint)
>     .routePolicyRef("myRoutePolicy")
>     .processRef("myProcessor")
>     .to("myQueue");
>
>
>
> myNettyEndpoint is a consumer server with sync option set to true in order
> to enforce the InOut MEP. I was hoping that I could (ab)use this and put my
> custom acknowledgement message into exchange like this:
>
> exchange.getOut().setBody("ACK")
>
> This is done in myRoutePolicy implementation that only implements the
> onExchangeDone method.
>
> remoteNettyEndpoint is a blackbox for me and it expects a custom
> acknowledgement message when it send a message to myNettyEndpoint and that
> message is processed by Route2.
>
> In sunny day scenario, when there are no exceptions being thrown by
> myProcessor which processes the message and puts the result into exchange, I
> get a timeout exception
>
> org.apache.camel.ExchangeTimedOutException: The OUT message was not received
> within: 20000 millis due reply message with correlationID ....
>
> and the custom acknowledgement message I put into exchange in myRoutePolicy
> implementation ends up on myQueue which I don't want to happen.
>
> Can someone please point out where am I making the mistake here?
>
> Regards,
> Slavisa
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Netty-component-and-acknowledgement-message-tp5767915.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/