0 Replies Latest reply on Nov 5, 2014 1:53 PM by rich.peters

    Camel 2.10 dynamic router state

    rich.peters

      Camel provides a nice capability in the dynamic router.  However it inherits a weakness from routingSlip in that state must be kept inside 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

      :

      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) ;

          }

       

      }