@Override
 public String[] getBindingNames() throws Exception {
   clearIO();
   try {
     Bindings bindings = postOffice.getBindingsForAddress(address);
     String[] bindingNames = new String[bindings.getBindings().size()];
     int i = 0;
     for (Binding binding : bindings.getBindings()) {
       bindingNames[i++] = binding.getUniqueName().toString();
     }
     return bindingNames;
   } catch (Throwable t) {
     throw new IllegalStateException(t.getMessage());
   } finally {
     blockOnIO();
   }
 }
 @Override
 public String[] getQueueNames() throws Exception {
   clearIO();
   try {
     Bindings bindings = postOffice.getBindingsForAddress(address);
     List<String> queueNames = new ArrayList<>();
     for (Binding binding : bindings.getBindings()) {
       if (binding instanceof QueueBinding) {
         queueNames.add(binding.getUniqueName().toString());
       }
     }
     return queueNames.toArray(new String[queueNames.size()]);
   } catch (Throwable t) {
     throw new IllegalStateException(t.getMessage());
   } finally {
     blockOnIO();
   }
 }
 @Override
 public long getNumberOfMessages() throws Exception {
   clearIO();
   long totalMsgs = 0;
   try {
     Bindings bindings = postOffice.getBindingsForAddress(address);
     List<String> queueNames = new ArrayList<>();
     for (Binding binding : bindings.getBindings()) {
       if (binding instanceof QueueBinding) {
         totalMsgs += ((QueueBinding) binding).getQueue().getMessageCount();
       }
     }
     return totalMsgs;
   } catch (Throwable t) {
     throw new IllegalStateException(t.getMessage());
   } finally {
     blockOnIO();
   }
 }
  @Test
  public void testDeploySameNames() throws Exception {
    final String testAddress = "testAddress";

    final String queueName1 = "queue1";

    final String queueName2 = "queue2";

    CoreQueueConfiguration queue1 =
        new CoreQueueConfiguration().setAddress(testAddress).setName(queueName1);

    CoreQueueConfiguration queue2 =
        new CoreQueueConfiguration().setAddress(testAddress).setName(queueName2);

    configuration.addQueueConfiguration(queue1).addQueueConfiguration(queue2);

    ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));

    server.start();

    Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(testAddress));

    Assert.assertEquals(2, bindings.getBindings().size());

    ServerLocator locator = createInVMNonHALocator();

    ClientSessionFactory sf = createSessionFactory(locator);

    ClientSession session = addClientSession(sf.createSession(false, true, true));

    session.start();

    ClientProducer producer =
        addClientProducer(session.createProducer(new SimpleString(testAddress)));

    ClientConsumer consumer1 = addClientConsumer(session.createConsumer(queueName1));

    ClientConsumer consumer2 = addClientConsumer(session.createConsumer(queueName2));

    final int numMessages = 10;

    final SimpleString propKey = new SimpleString("testkey");

    for (int i = 0; i < numMessages; i++) {
      ClientMessage message = session.createMessage(false);

      message.putIntProperty(propKey, i);

      producer.send(message);
    }

    for (int i = 0; i < numMessages; i++) {
      ClientMessage message = consumer1.receive(200);
      Assert.assertNotNull(message);
      Assert.assertEquals(i, message.getObjectProperty(propKey));
      message.acknowledge();

      message = consumer2.receive(200);
      Assert.assertNotNull(message);
      Assert.assertEquals(i, message.getObjectProperty(propKey));
      message.acknowledge();
    }

    Assert.assertNull(consumer1.receiveImmediate());
    Assert.assertNull(consumer2.receiveImmediate());
  }