1 Reply Latest reply on Jul 15, 2011 2:02 AM by Claus Ibsen

    Dynamic Consumers?

    jamie archibald Apprentice

      Does camel have a pattern for a dynamic consumer similar to the dynamic router?

       

      I'd like to create and remove consumers dynamically (at runtime) through some trigger such as a timer or event (such as a user interface).

       

      For example,

       

      private class DynamicConsumer {

       

         int i=0;

       

         // this will get called on each time event

         public static String[] getEndpoints() {

            if (i ==0) {

               // dont consume

               return null;

            } else if (i % 2 == 0) {

                return new String[] {"activemq:topic:ABC","activemq:topic:CDE"}

            } else {

                return new String[] {"activemq:topic:FGH" };

            }

         }

      }

       

       

      from("timer://...")

      .dynamicConsumer(bean(new DynamicConsumer())

      .to("direct:destination");