You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rich Peters <ri...@braxtontech.com> on 2014/11/06 17:19:12 UTC

Camel DynamicRouter requires state storage inside routing bean

Previously posted to the JBOSS Fuse mailing list with no response

Camel provides a nice capability in the dynamic router.  However it inherits
a weakness from routingSlip in that state must be kept inside the object
with the method call.  Is there a nice way to have a one time routing slip
without saving state?  currently you are forced to do something like this:
(to determine that the second call is for the same message)

public class MessageDistributionDynamicRouter

{
    //must keep state to stop the routing slip
    private volatile Object lastBody = null ;

    public String destinationQueue(@Header("sessionId") final String
sessionId, @Body final Object body)
    {
        if (lastBody == body)
        {
            return null;
        }
        lastBody = body;

        //route to destination outbound queue
        return QueueName.getOutboundQueueName(sessionId) ;
    }
}



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-DynamicRouter-requires-state-storage-inside-routing-bean-tp5758615.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel DynamicRouter requires state storage inside routing bean

Posted by Rich Peters <ri...@braxtontech.com>.
Thanks Claus

I guess I was looking for a construct in the dynamic router that provided
for a one time destination that didn't require saving state anywhere.  The
detection of the same body being sent seems brittle to me.

Rich




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-DynamicRouter-requires-state-storage-inside-routing-bean-tp5758615p5758619.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel DynamicRouter requires state storage inside routing bean

Posted by Claus Ibsen <cl...@gmail.com>.
You can keep state on the exchange itself on the properties

On Thu, Nov 6, 2014 at 5:19 PM, Rich Peters <ri...@braxtontech.com> wrote:
> Previously posted to the JBOSS Fuse mailing list with no response
>
> Camel provides a nice capability in the dynamic router.  However it inherits
> a weakness from routingSlip in that state must be kept inside the object
> with the method call.  Is there a nice way to have a one time routing slip
> without saving state?  currently you are forced to do something like this:
> (to determine that the second call is for the same message)
>
> public class MessageDistributionDynamicRouter
>
> {
>     //must keep state to stop the routing slip
>     private volatile Object lastBody = null ;
>
>     public String destinationQueue(@Header("sessionId") final String
> sessionId, @Body final Object body)
>     {
>         if (lastBody == body)
>         {
>             return null;
>         }
>         lastBody = body;
>
>         //route to destination outbound queue
>         return QueueName.getOutboundQueueName(sessionId) ;
>     }
> }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-DynamicRouter-requires-state-storage-inside-routing-bean-tp5758615.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/