Search in sources :

Example 1 with RemoveReason

use of com.sun.messaging.jmq.jmsserver.util.lists.RemoveReason in project openmq by eclipse-ee4j.

the class AckHandler method handleDeadMsgs.

public void handleDeadMsgs(IMQConnection con, SysMessageID[] ids, ConsumerUID[] cids, int deadrs, Throwable thr, String comment, int deliverCnt, List cleanList) throws BrokerException {
    RemoveReason deadReason = RemoveReason.UNDELIVERABLE;
    if (deadrs == DEAD_REASON_EXPIRED) {
        deadReason = RemoveReason.EXPIRED_BY_CLIENT;
    }
    for (int i = 0; i < ids.length; i++) {
        Session s = Session.getSession(cids[i]);
        if (s == null) {
            // consumer does not have session
            // really nothing to do, ignore
            logger.log(Logger.DEBUG, "Dead message for Unknown Consumer/Session" + cids[i]);
            continue;
        }
        if (DEBUG) {
            logger.log(logger.INFO, "handleDead[" + i + ", " + ids.length + "]:sysid=" + ids[i] + ", cid=" + cids[i] + ", on connection " + con);
        }
        PacketReference ref = (PacketReference) s.handleDead(cids[i], ids[i], deadReason, thr, comment, deliverCnt);
        // no consumers .. so clean it up
        if (ref != null) {
            cleanList.add(ref);
        }
    }
}
Also used : RemoveReason(com.sun.messaging.jmq.jmsserver.util.lists.RemoveReason) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference) Session(com.sun.messaging.jmq.jmsserver.core.Session)

Example 2 with RemoveReason

use of com.sun.messaging.jmq.jmsserver.util.lists.RemoveReason in project openmq by eclipse-ee4j.

the class BrokerConsumers method removeRemoteDeadMessage.

private boolean removeRemoteDeadMessage(int ackType, PacketReference ref, ConsumerUID cuid, ConsumerUID storedid, Map optionalProps) throws BrokerException {
    if (ref == null) {
        return true;
    }
    Destination d = ref.getDestination();
    Queue[] qs = DL.getDMQ(ref.getPartitionedStore());
    if (d == qs[0]) {
        // already gone, ignore
        return true;
    }
    // first pull out properties
    String comment = null;
    Exception ex = null;
    Integer deliverCnt = null;
    Integer reasonInt = null;
    String deadbkr = null;
    if (optionalProps != null) {
        comment = (String) optionalProps.get(DMQ.UNDELIVERED_COMMENT);
        ex = (Exception) optionalProps.get(DMQ.UNDELIVERED_EXCEPTION);
        deliverCnt = (Integer) optionalProps.get(Destination.TEMP_CNT);
        reasonInt = (Integer) optionalProps.get("REASON");
        deadbkr = (String) optionalProps.get(DMQ.DEAD_BROKER);
    }
    RemoveReason rr = null;
    if (ackType == ClusterBroadcast.MSG_UNDELIVERABLE) {
        rr = RemoveReason.UNDELIVERABLE;
    } else {
        rr = RemoveReason.ERROR;
        if (reasonInt != null) {
            rr = RemoveReason.findReason(reasonInt.intValue());
        }
    }
    if (comment == null) {
        comment = "none";
    }
    if (ref.markDead(cuid, storedid, comment, ex, rr, (deliverCnt == null ? 0 : deliverCnt.intValue()), deadbkr)) {
        try {
            if (ref.isDead()) {
                if (getDEBUG()) {
                    Globals.getLogger().log(logger.INFO, "Remove dead message " + ref + " for remote consumer " + cuid + " on destination " + d + " with reason " + rr);
                }
                try {
                    d.removeDeadMessage(ref);
                } catch (Exception e) {
                    logger.log(logger.WARNING, "Unable to remove dead[" + rr + ", " + deadbkr + "] message " + ref + "[" + cuid + "]: " + e.getMessage(), e);
                }
            }
        } finally {
            ref.postAcknowledgedRemoval();
        }
        return true;
    }
    return false;
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) RemoveReason(com.sun.messaging.jmq.jmsserver.util.lists.RemoveReason) Queue(com.sun.messaging.jmq.jmsserver.core.Queue) ConsumerAlreadyAddedException(com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException) SelectorFormatException(com.sun.messaging.jmq.util.selector.SelectorFormatException) IOException(java.io.IOException) AckEntryNotFoundException(com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Aggregations

RemoveReason (com.sun.messaging.jmq.jmsserver.util.lists.RemoveReason)2 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)1 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)1 Queue (com.sun.messaging.jmq.jmsserver.core.Queue)1 Session (com.sun.messaging.jmq.jmsserver.core.Session)1 AckEntryNotFoundException (com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 ConsumerAlreadyAddedException (com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException)1 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)1 IOException (java.io.IOException)1