0 Replies Latest reply on Mar 26, 2013 7:15 AM by Roger Eddy

    How to create a queue and add a push consumer from onMessage()

    Roger Eddy Newbie

      From inside PushConsumer.onMessage(), how can I create a queue and add a push consumer to that queue?  Here's a failing attempt:

       

      // create queue

       

      ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName()));

      ClientSessionFactory sf = serverLocator.createSessionFactory();

      ClientSession coreSession = sf.createSession(false, false, false);

      final String queueName = "queue.exampleQueue";

      coreSession.createQueue(queueName, queueName, true);

       

      // add consumer

       

      PushStore pushStore = QueueServiceManager().getPushStore();

       

      PushRegistration reg = new PushRegistration();

      reg.setDestination("http://somewhere.com/rest/service");

      reg.setEnabled(true);

       

      pushStore.add(reg);