Search in sources :

Example 1 with ReplaceMessageHandler

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

the class MessageManagerConfig method replaceMessage.

public String replaceMessage(String destinationType, String destinationName, String messageID, HashMap messageBody) throws MBeanException {
    String newMsgID = null;
    try {
        if (destinationType == null) {
            throw new BrokerException("Admin replaceMessage: destination name and 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);
        ReplaceMessageHandler hd = (ReplaceMessageHandler) dhd.getHandler(com.sun.messaging.jmq.util.admin.MessageType.REPLACE_MESSAGE);
        newMsgID = hd.replaceMessage(messageID, destinationName, messageBody, 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("replaceMessage", e);
    }
    return (newMsgID);
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) PacketRouter(com.sun.messaging.jmq.jmsserver.data.PacketRouter) AdminDataHandler(com.sun.messaging.jmq.jmsserver.data.handlers.admin.AdminDataHandler) ReplaceMessageHandler(com.sun.messaging.jmq.jmsserver.data.handlers.admin.ReplaceMessageHandler) 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 ReplaceMessageHandler (com.sun.messaging.jmq.jmsserver.data.handlers.admin.ReplaceMessageHandler)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 MBeanException (javax.management.MBeanException)1