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);
}
}
Aggregations