@Override public List<String> getConnectionfactories() throws MBeanException { try { return jmsService.connectionFactories(); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
@Override public int complete(String buffer, int cursor, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { for (String connectionFactory : jmsService.connectionFactoryFileNames()) { delegate.getStrings().add(connectionFactory.replace("connectionfactory-", "").replace(".xml", "")); } } catch (Exception e) { // nothing to do } return delegate.complete(buffer, cursor, candidates); }
@Override public Object execute() throws Exception { System.out.println(getJmsService().consume(connectionFactory, queue, selector, username, password) + " message(s) consumed"); return null; }
@Override public void create(String name, String type, String url, String username, String password, String pool) throws MBeanException { try { jmsService.create(name, type, url, username, password, pool); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
@Override public Map<String, String> info(String connectionFactory, String username, String password) throws MBeanException { try { return jmsService.info(connectionFactory, username, password); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
@Override public List<String> queues(String connectionFactory, String username, String password) throws MBeanException { try { return jmsService.queues(connectionFactory, username, password); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
@Override public int count(String connectionFactory, String queue, String username, String password) throws MBeanException { try { return jmsService.count(connectionFactory, queue, username, password); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
@Override public Object execute() throws Exception { getJmsService().delete(name); return null; }
@Override public Object execute() throws Exception { System.out.println(getJmsService().move(connectionFactory, source, destination, selector, username, password) + " message(s) moved"); return null; }
@Override public TabularData browse(String connectionFactory, String queue, String selector, String username, String password) throws MBeanException { try { CompositeType type = new CompositeType("message", "JMS Message", new String[]{ "id", "content", "charset", "type", "correlation", "delivery", "destination", "expiration", "priority", "redelivered", "replyto", "timestamp" }, new String[]{ "Message ID", "Content", "Charset", "Type", "Correlation ID", "Delivery Mode", "Destination", "Expiration Date", "Priority", "Redelivered", "Reply-To", "Timestamp" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN, SimpleType.STRING, SimpleType.STRING }); TabularType tableType = new TabularType("messages", "JMS Messages", type, new String[]{ "id" }); TabularData table = new TabularDataSupport(tableType); for (JmsMessage message : getJmsService().browse(connectionFactory, queue, selector, username, password)) { CompositeData data = new CompositeDataSupport(type, new String[]{ "id", "content", "charset", "type", "correlation", "delivery", "destination", "expiration", "priority", "redelivered", "replyto", "timestamp" }, new Object[]{ message.getMessageId(), message.getContent(), message.getCharset(), message.getType(), message.getCorrelationID(), message.getDeliveryMode(), message.getDestination(), message.getExpiration(), message.getPriority(), message.isRedelivered(), message.getReplyTo(), message.getTimestamp() } ); table.put(data); } return table; } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
@Override public Object execute() throws Exception { getJmsService().create(name, type, url, username, password, pool); return null; }
@Override public Object execute() throws Exception { ShellTable table = new ShellTable(); table.column("Property"); table.column("Value"); Map<String, String> info = getJmsService().info(connectionFactory, username, password); for (String key : info.keySet()) { table.addRow().addContent(key, info.get(key)); } table.print(System.out); return null; }
@Override public Object execute() throws Exception { ShellTable table = new ShellTable(); table.column("JMS Queues"); for (String queue : getJmsService().queues(connectionFactory, username, password)) { table.addRow().addContent(queue); } table.print(System.out); return null; }
@Override public Object execute() throws Exception { ShellTable table = new ShellTable(); table.column("Messages Count"); table.addRow().addContent(getJmsService().count(connectionFactory, queue, username, password)); table.print(System.out); return null; }
@Override public void delete(String name) throws MBeanException { try { jmsService.delete(name); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
@Override public int move(String connectionFactory, String source, String destination, String selector, String username, String password) throws MBeanException { try { return jmsService.move(connectionFactory, source, destination, selector, username, password); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
List<JmsMessage> messages = getJmsService().browse(connectionFactory, queue, selector, username, password); for (JmsMessage message : messages) { if (verbose) {
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); try { for (String connectionFactory : jmsService.connectionFactories()) { delegate.getStrings().add(connectionFactory); } } catch (Exception e) { // nothing to do } return delegate.complete(session, commandLine, candidates); }
@Override public void create(String name, String type, String url) throws MBeanException { try { jmsService.create(name, type, url); } catch (Throwable t) { throw new MBeanException(null, t.getMessage()); } }
public Object doExecute() throws Exception { ShellTable table = new ShellTable(); table.column("Property"); table.column("Value"); Map<String, String> info = getJmsService().info(connectionFactory, username, password); for (String key : info.keySet()) { table.addRow().addContent(key, info.get(key)); } table.print(System.out); return null; }