LocalClusteredQueue queue2 = new LocalClusteredQueue(office2, "node2", "queue1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
LocalClusteredQueue queue2 = new LocalClusteredQueue(office2, 2, "queue1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);
   protected void routeSharedQueue(boolean persistentMessage) throws Throwable   {      ClusteredPostOffice office1 = null;            ClusteredPostOffice office2 = null;            ClusteredPostOffice office3 = null;            ClusteredPostOffice office4 = null;            ClusteredPostOffice office5 = null;            ClusteredPostOffice office6 = null;              try      {            office1 = createClusteredPostOffice("node1", "testgroup");         office2 = createClusteredPostOffice("node2", "testgroup");         office3 = createClusteredPostOffice("node3", "testgroup");         office4 = createClusteredPostOffice("node4", "testgroup");         office5 = createClusteredPostOffice("node5", "testgroup");         office6 = createClusteredPostOffice("node6", "testgroup");             //We deploy the queue on nodes 1, 2, 3, 4 and 5         //We don't deploy on node 6                  LocalClusteredQueue queue1 = new LocalClusteredQueue(office1, "node1", "queue1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding1 = office1.bindClusteredQueue("queue1", queue1);         SimpleReceiver receiver1 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);         queue1.add(receiver1);                  LocalClusteredQueue queue2 = new LocalClusteredQueue(office2, "node2", "queue1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding2 = office2.bindClusteredQueue("queue1", queue2);          SimpleReceiver receiver2 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);         queue2.add(receiver2);                  LocalClusteredQueue queue3 = new LocalClusteredQueue(office3, "node3", "queue1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding3 = office3.bindClusteredQueue("queue1", queue3);         SimpleReceiver receiver3 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);         queue3.add(receiver3);                  LocalClusteredQueue queue4 = new LocalClusteredQueue(office4, "node4", "queue1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding4 = office4.bindClusteredQueue("queue1", queue4);          SimpleReceiver receiver4 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);         queue4.add(receiver4);                  LocalClusteredQueue queue5 = new LocalClusteredQueue(office5, "node5", "queue1", im.getId(), ms, pm, true, false, (QueuedExecutor)pool.get(), null, tr);         Binding binding5 = office5.bindClusteredQueue("queue1", queue5);         SimpleReceiver receiver5 = new SimpleReceiver("blah", SimpleReceiver.ACCEPTING);         queue5.add(receiver5);                 //We are using a AlwaysLocalRoutingPolicy so only the local queue should ever get the message if the filter matches                                   Message msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);               MessageReference ref = ms.reference(msg);                  boolean routed = office1.route(ref, "queue1", null);                  assertTrue(routed);         checkContainsAndAcknowledge(msg, receiver1, queue1);         this.checkEmpty(receiver2);         this.checkEmpty(receiver3);         this.checkEmpty(receiver4);         this.checkEmpty(receiver5);                  msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);               ref = ms.reference(msg);                  routed = office2.route(ref, "queue1", null);                  assertTrue(routed);         this.checkEmpty(receiver1);         checkContainsAndAcknowledge(msg, receiver2, queue2);         this.checkEmpty(receiver3);         this.checkEmpty(receiver4);         this.checkEmpty(receiver5);                  msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);               ref = ms.reference(msg);                  routed = office3.route(ref, "queue1", null);                  assertTrue(routed);         this.checkEmpty(receiver1);         this.checkEmpty(receiver2);         checkContainsAndAcknowledge(msg, receiver3, queue3);         this.checkEmpty(receiver4);         this.checkEmpty(receiver5);                  msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);               ref = ms.reference(msg);                  routed = office4.route(ref, "queue1", null);                  assertTrue(routed);         this.checkEmpty(receiver1);         this.checkEmpty(receiver2);         this.checkEmpty(receiver3);         checkContainsAndAcknowledge(msg, receiver4, queue3);         this.checkEmpty(receiver5);                  msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);               ref = ms.reference(msg);                  routed = office5.route(ref, "queue1", null);                  assertTrue(routed);         this.checkEmpty(receiver1);         this.checkEmpty(receiver2);                  this.checkEmpty(receiver3);         this.checkEmpty(receiver4);         checkContainsAndAcknowledge(msg, receiver5, queue5);                  msg = CoreMessageFactory.createCoreMessage(1, persistentMessage, null);               ref = ms.reference(msg);                  routed = office6.route(ref, "queue1", null);                  assertTrue(routed);                  //The actual queue that receives the mesage is determined by the routing policy         //The default uses round robin for the nodes (this is tested more thoroughly in         //its own test)                  Thread.sleep(1000);                  checkContainsAndAcknowledge(msg, receiver1, queue1);         this.checkEmpty(receiver1);         this.checkEmpty(receiver2);                  this.checkEmpty(receiver3);         this.checkEmpty(receiver4);         this.checkEmpty(receiver5);                       }      finally      {         if (office1 != null)         {                        office1.stop();         }                  if (office2 != null)         {            office2.stop();         }                  if (office3 != null)         {                        office3.stop();         }                  if (office4 != null)         {            office4.stop();         }                  if (office5 != null)         {                        office5.stop();         }                  if (office6 != null)         {                        office6.stop();         }                  checkNoMessageData();      }   }