@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(); } }