Search in sources :

Example 1 with DeleteMessageHandler

use of com.sun.messaging.jmq.jmsserver.data.handlers.admin.DeleteMessageHandler in project openmq by eclipse-ee4j.

the class MessageManagerConfig method deleteMessage.

public void deleteMessage(String destinationType, String destinationName, String messageID) throws MBeanException {
    try {
        if (destinationType == null) {
            throw new BrokerException("Admin deleteMessage: destination type not specified", Status.BAD_REQUEST);
        }
        PacketRouter pr = Globals.getPacketRouter(1);
        if (pr == null) {
            throw new BrokerException("Admin deleteMessage: Could not locate Admin Packet Router");
        }
        AdminDataHandler dhd = (AdminDataHandler) pr.getHandler(PacketType.OBJECT_MESSAGE);
        DeleteMessageHandler hd = (DeleteMessageHandler) dhd.getHandler(com.sun.messaging.jmq.util.admin.MessageType.DELETE_MESSAGE);
        hd.deleteMessage(messageID, destinationName, destinationType.equals(DestinationType.QUEUE));
    } catch (Exception e) {
        boolean logstack = true;
        if (e instanceof BrokerException) {
            int status = ((BrokerException) e).getStatusCode();
            if (status == Status.NOT_ALLOWED || status == Status.NOT_FOUND || status == Status.CONFLICT || status == Status.BAD_REQUEST) {
                logstack = false;
            }
        }
        Object[] args = { messageID, destinationName, e.getMessage() };
        String emsg = rb.getKString(rb.X_ADMIN_DELETE_MSG, args);
        if (logstack) {
            logger.logStack(Logger.ERROR, emsg, e);
        } else {
            logger.log(Logger.ERROR, emsg, e);
        }
        handleOperationException("deleteMessage", e);
    }
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) PacketRouter(com.sun.messaging.jmq.jmsserver.data.PacketRouter) DeleteMessageHandler(com.sun.messaging.jmq.jmsserver.data.handlers.admin.DeleteMessageHandler) AdminDataHandler(com.sun.messaging.jmq.jmsserver.data.handlers.admin.AdminDataHandler) MBeanException(javax.management.MBeanException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Aggregations

PacketRouter (com.sun.messaging.jmq.jmsserver.data.PacketRouter)1 AdminDataHandler (com.sun.messaging.jmq.jmsserver.data.handlers.admin.AdminDataHandler)1 DeleteMessageHandler (com.sun.messaging.jmq.jmsserver.data.handlers.admin.DeleteMessageHandler)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 MBeanException (javax.management.MBeanException)1