Search in sources :

Example 6 with InvalidPacketException

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

the class DestinationList method handleInvalidPacket.

private static void handleInvalidPacket(String sysidstr, String duidstr, String comment, InvalidPacketException ipex, PartitionedStore ps) throws BrokerException {
    Properties props = new Properties();
    props.put(DMQ.UNDELIVERED_REASON, RemoveReason.ERROR.toString());
    props.put(DMQ.UNDELIVERED_TIMESTAMP, Long.valueOf(System.currentTimeMillis()));
    props.put(DMQ.UNDELIVERED_COMMENT, comment);
    String cstr = SupportUtil.getStackTraceString(ipex);
    props.put(DMQ.UNDELIVERED_EXCEPTION, cstr);
    props.put(DMQ.BROKER, Globals.getMyAddress().toString());
    props.put(DMQ.DEAD_BROKER, Globals.getMyAddress().toString());
    byte[] data = ipex.getBytes();
    Queue[] dmqs = DL.getDMQ(ps);
    Queue dmq = dmqs[0];
    Packet pkt = new Packet();
    pkt.setPacketType(PacketType.BYTES_MESSAGE);
    pkt.setProperties(props);
    pkt.setDestination(dmq.getDestinationName());
    pkt.setIsQueue(true);
    pkt.setPersistent(true);
    pkt.setIP(Globals.getBrokerInetAddress().getAddress());
    pkt.setPort(Globals.getPortMapper().getPort());
    pkt.updateSequenceNumber();
    pkt.updateTimestamp();
    pkt.generateSequenceNumber(false);
    pkt.generateTimestamp(false);
    pkt.setSendAcknowledge(false);
    pkt.setMessageBody(data);
    PacketReference ref = PacketReference.createReference(dmq.getPartitionedStore(), pkt, null);
    String[] args1 = { sysidstr, duidstr, ref.getSysMessageID().toString() + "[" + PacketType.getString(PacketType.BYTES_MESSAGE) + "]" };
    Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().getKString(BrokerResources.I_PLACING_CORRUPTED_MSG_TO_DMQ, args1));
    dmq.queueMessage(ref, false);
    Set s = dmq.routeNewMessage(ref);
    String[] args2 = { sysidstr, duidstr, ref.getSysMessageID().toString() + "[" + PacketType.getString(PacketType.BYTES_MESSAGE) + "]" };
    Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().getKString(BrokerResources.I_PLACED_CORRUPTED_MSG_TO_DMQ, args2));
    dmq.forwardMessage(s, ref);
    Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().getKString(BrokerResources.I_REMOVE_CORRUPTED_MSG_IN_STORE, sysidstr, duidstr));
    try {
        ps.removeMessage((new DestinationUID(duidstr)), sysidstr, true);
    } catch (Exception e) {
        String emsg = Globals.getBrokerResources().getKString(BrokerResources.X_PERSIST_MESSAGE_REMOVE_FAILED, sysidstr);
        Globals.getLogger().logStack(Logger.ERROR, emsg, e);
        if (e instanceof BrokerException) {
            throw (BrokerException) e;
        }
        throw new BrokerException(emsg, e);
    }
}
Also used : Packet(com.sun.messaging.jmq.io.Packet) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) SizeString(com.sun.messaging.jmq.util.SizeString) InvalidSysMessageIDException(com.sun.messaging.jmq.io.InvalidSysMessageIDException) PartitionNotFoundException(com.sun.messaging.jmq.jmsserver.util.PartitionNotFoundException) ConflictException(com.sun.messaging.jmq.jmsserver.util.ConflictException) LoadException(com.sun.messaging.jmq.jmsserver.persist.api.LoadException) TransactionAckExistException(com.sun.messaging.jmq.jmsserver.util.TransactionAckExistException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) InvalidPacketException(com.sun.messaging.jmq.io.InvalidPacketException)

Aggregations

InvalidPacketException (com.sun.messaging.jmq.io.InvalidPacketException)6 Packet (com.sun.messaging.jmq.io.Packet)5 InvalidSysMessageIDException (com.sun.messaging.jmq.io.InvalidSysMessageIDException)3 PacketReadEOFException (com.sun.messaging.jmq.io.PacketReadEOFException)3 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)3 SizeString (com.sun.messaging.jmq.util.SizeString)3 LoadException (com.sun.messaging.jmq.jmsserver.persist.api.LoadException)2 ConflictException (com.sun.messaging.jmq.jmsserver.util.ConflictException)2 PartitionNotFoundException (com.sun.messaging.jmq.jmsserver.util.PartitionNotFoundException)2 TransactionAckExistException (com.sun.messaging.jmq.jmsserver.util.TransactionAckExistException)2 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)1 TransactionAcknowledgement (com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement)1 TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)1 TransactionState (com.sun.messaging.jmq.jmsserver.data.TransactionState)1 TransactionUID (com.sun.messaging.jmq.jmsserver.data.TransactionUID)1 RefCompare (com.sun.messaging.jmq.jmsserver.data.handlers.RefCompare)1 Logger (com.sun.messaging.jmq.util.log.Logger)1