Search in sources :

Example 1 with InvalidSysMessageIDException

use of com.sun.messaging.jmq.io.InvalidSysMessageIDException in project openmq by eclipse-ee4j.

the class DestinationList method remoteCheckTakeoverMsgs.

public static void remoteCheckTakeoverMsgs(Map<String, String> msgs, String brokerid, PartitionedStore ps) throws BrokerException {
    Set destroyConns = new HashSet();
    Map<String, String> badsysids = null;
    Iterator<Map.Entry<String, String>> itr = msgs.entrySet().iterator();
    Map.Entry<String, String> me = null;
    String sysidstr = null, duidstr = null;
    SysMessageID sysid = null;
    DestinationUID duid = null;
    while (itr.hasNext()) {
        me = itr.next();
        sysidstr = me.getKey();
        duidstr = me.getValue();
        try {
            sysid = SysMessageID.get(sysidstr);
        } catch (InvalidSysMessageIDException e) {
            Globals.getLogger().logStack(Logger.ERROR, e.getMessage(), e);
            if (!Globals.getStore().getStoreType().equals(Store.JDBC_STORE_TYPE)) {
                throw e;
            }
            duid = new DestinationUID(duidstr);
            Globals.getLogger().log(Logger.WARNING, Globals.getBrokerResources().getKString(BrokerResources.X_TAKEOVER_MSGID_CORRUPT_TRY_REPAIR, sysidstr, duidstr));
            try {
                Packet p = null;
                try {
                    p = ps.getMessage(duid, sysidstr);
                } catch (BrokerException ee) {
                    Throwable cause = ee.getCause();
                    String[] args = { sysidstr, "[?]", duidstr, cause.toString() };
                    String emsg = Globals.getBrokerResources().getKString(BrokerResources.X_REPAIR_CORRUPTED_MSGID_IN_STORE, args);
                    Globals.getLogger().logStack(Logger.ERROR, emsg, ee);
                    if (cause instanceof InvalidPacketException) {
                        handleInvalidPacket(sysidstr, duidstr, emsg, (InvalidPacketException) cause, ps);
                        itr.remove();
                        continue;
                    } else {
                        throw ee;
                    }
                }
                sysid = p.getSysMessageID();
                String realsysidstr = sysid.getUniqueName();
                String[] args3 = { sysidstr, realsysidstr, duidstr };
                Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().getKString(BrokerResources.X_REPAIR_CORRUPTED_MSGID_TO, args3));
                ps.repairCorruptedSysMessageID(sysid, sysidstr, duidstr, true);
                if (badsysids == null) {
                    badsysids = new HashMap<>();
                }
                badsysids.put(sysidstr, realsysidstr);
            } catch (BrokerException ee) {
                Globals.getLogger().logStack(Logger.ERROR, e.getMessage(), ee);
                throw e;
            }
        }
        PacketReference ref = get(null, sysid);
        if (ref == null) {
            continue;
        }
        Iterator cnitr = ref.getRemoteConsumerUIDs().values().iterator();
        while (cnitr.hasNext()) {
            destroyConns.add(cnitr.next());
        }
    }
    if (badsysids != null) {
        itr = badsysids.entrySet().iterator();
        String v = null;
        while (itr.hasNext()) {
            me = itr.next();
            v = msgs.remove(me.getKey());
            msgs.put(me.getValue(), v);
        }
    }
    destroyConnections(destroyConns, GoodbyeReason.BKR_IN_TAKEOVER, GoodbyeReason.toString(GoodbyeReason.BKR_IN_TAKEOVER) + ":" + brokerid);
}
Also used : Packet(com.sun.messaging.jmq.io.Packet) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) SizeString(com.sun.messaging.jmq.util.SizeString) InvalidPacketException(com.sun.messaging.jmq.io.InvalidPacketException) InvalidSysMessageIDException(com.sun.messaging.jmq.io.InvalidSysMessageIDException) SysMessageID(com.sun.messaging.jmq.io.SysMessageID)

Aggregations

InvalidPacketException (com.sun.messaging.jmq.io.InvalidPacketException)1 InvalidSysMessageIDException (com.sun.messaging.jmq.io.InvalidSysMessageIDException)1 Packet (com.sun.messaging.jmq.io.Packet)1 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 SizeString (com.sun.messaging.jmq.util.SizeString)1