List of usage examples for javax.management JMException toString
public String toString()
From source file:org.wso2.andes.server.information.management.QueueManagementInformationMBean.java
/** * {@inheritDoc}// w w w.ja v a2 s.com */ @Override public void deleteAllMessagesInQueue( @MBeanOperationParameter(name = "queueName", description = "Name of the queue to delete messages from") String queueName, @MBeanOperationParameter(name = "ownerName", description = "Username of user that calls for " + "purge") String ownerName) throws MBeanException { AMQQueue queue = queueRegistry.getQueue(new AMQShortString(queueName)); try { if (queue == null) { throw new JMException("The Queue " + queueName + " is not a registered queue."); } queue.purge(0l); //This is to trigger the AMQChannel purge event so that the queue // state of qpid is updated. This method also validates the request owner and throws // an exception if permission is denied. InboundQueueEvent storageQueue = AMQPUtils.createInboundQueueEvent(queue); int purgedMessageCount = Andes.getInstance().purgeQueue(storageQueue); log.info("Total message count purged for queue (from store) : " + queueName + " : " + purgedMessageCount + ". All in memory messages received before the purge call" + " are abandoned from delivery phase. "); } catch (JMException jme) { if (jme.toString().contains("not a registered queue")) { throw new MBeanException(jme, "The Queue " + queueName + " is not a registered " + "queue."); } else { throw new MBeanException(jme, PURGE_QUEUE_ERROR + queueName); } } catch (AMQException | AndesException amqex) { throw new MBeanException(amqex, PURGE_QUEUE_ERROR + queueName); } }