2 Replies Latest reply on Dec 30, 2014 11:53 AM by jbkinney

    Appropriate use of JMSQueueControl.move

    jbkinney

      I am buffering messages in a queue (waitingQueue) which are waiting for work to be done in other queues (~ 1..1K messages).

      Once the work is done, I use a message property to lookup the corresponding message in the waitingQueue

      to then route the message to its next step (nextStepQueue) using the JMSQueueControl.move method.

       

      Is it appropriate to use the JMSQueueControl.move functionality like this?

       

      for example:

       

      @Stateless

      public class WorkManagerSSB {

       

      // messages enqueue on a queue with no consumers

      @Resource(mappedName = "java:/queue/waitingQueue")

          private Queue queueWaiting;


      // queue has a MessageDrivenBean associated for processing

      @Resource(mappedName = "java:/queue/nextStepQueue")

          private Queue queueNextStep;



      @TransactionAttribute(TransactionAttributeType.MANDATORY)

          public void resumeFromWaitingToNextStep(Message message) throws Exception {

       

              ObjectName waitingQueue = ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueWaiting.getQueueName());

       

              MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();

       

              JMSQueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mbsc,

                                                                                           waitingQueue,

                                                                                           JMSQueueControl.class,

                                                                                           false);

       

           int moved = queueControl.moveMessages(createCorrelatingIdFilter(message)), queueNextStep.getQueueName());

                ...

      }