use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterMessageInfo method getGPacket.
public GPacket getGPacket() throws Exception {
assert (ref != null);
assert (consumers != null);
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_MESSAGE_DATA);
gp.putProp("D", Boolean.valueOf(sendMessageDeliveredAck));
gp.putProp("C", Integer.valueOf(consumers.size()));
if (Globals.getDestinationList().isPartitionMode()) {
gp.putProp("partitionID", Long.valueOf(ref.getPartitionedStore().getPartitionID().longValue()));
}
c.marshalBrokerAddress(c.getSelfAddress(), gp);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
Packet roPkt = null;
try {
for (int i = 0; i < consumers.size(); i++) {
ConsumerUID intid = consumers.get(i).getConsumerUID();
ClusterConsumerInfo.writeConsumerUID(intid, dos);
gp.putProp(PROP_PREFIX_CUID_DCT + intid.longValue(), deliveryCnts.get(i));
}
if (redelivered) {
gp.putProp(PROP_REDELIVERED, Boolean.valueOf(redelivered));
}
roPkt = ref.getPacket();
if (roPkt == null) {
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.X_NULL_PACKET_FROM_REF, ref.toString()));
}
roPkt.generateTimestamp(false);
roPkt.generateSequenceNumber(false);
roPkt.writePacket(dos);
dos.flush();
bos.flush();
} catch (Exception e) {
String emsg = Globals.getBrokerResources().getKString(BrokerResources.X_EXCEPTION_WRITE_PKT_ON_SEND_MSG_REMOTE, ref.toString(), e.getMessage());
if (e instanceof BrokerException) {
logger.log(Logger.WARNING, emsg);
throw e;
}
logger.logStack(Logger.WARNING, emsg, e);
throw e;
}
byte[] buf = bos.toByteArray();
gp.setPayload(ByteBuffer.wrap(buf));
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterTakeoverInfo method getGPacket.
public GPacket getGPacket(short protocol) throws BrokerException {
// protocol == ProtocolGlobals.G_TAKEOVER_ABORT );
if (!Globals.getHAEnabled()) {
throw new BrokerException(Globals.getBrokerResources().getKString(BrokerResources.E_INTERNAL_BROKER_ERROR, "Broker is not running in HA mode"));
}
if (pkt != null) {
assert (pkt.getType() == protocol);
return pkt;
}
GPacket gp = GPacket.getInstance();
gp.putProp("brokerID", brokerID);
gp.putProp("storeSession", Long.valueOf(storeSession.longValue()));
if (protocol == ProtocolGlobals.G_TAKEOVER_COMPLETE) {
gp.setType(protocol);
gp.setBit(gp.A_BIT, false);
return gp;
}
HAClusteredBroker cb = (HAClusteredBroker) Globals.getClusterManager().getLocalBroker();
if (protocol == ProtocolGlobals.G_TAKEOVER_PENDING) {
gp.setType(ProtocolGlobals.G_TAKEOVER_PENDING);
gp.setBit(gp.A_BIT, false);
gp.putProp("brokerSession", Long.valueOf(brokerSession.longValue()));
gp.putProp("brokerHost", brokerHost);
if (fromTaker) {
taker = cb.getBrokerName();
gp.putProp("taker", taker);
gp.putProp("timestamp", Long.valueOf(cb.getHeartbeat()));
gp.setBit(gp.A_BIT, true);
} else if (timedout) {
gp.putProp("timestamp", Long.valueOf(0));
}
gp.putProp("X", xid);
return gp;
}
if (protocol == ProtocolGlobals.G_TAKEOVER_ABORT) {
gp.setType(ProtocolGlobals.G_TAKEOVER_ABORT);
if (fromTaker) {
gp.putProp("taker", cb.getBrokerName());
}
gp.setBit(gp.A_BIT, false);
gp.putProp("X", xid);
return gp;
}
throw new BrokerException("Unknown protocol: " + protocol);
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterTransferFileListInfo method getGPacket.
public GPacket getGPacket() throws BrokerException {
if (pkt != null) {
return pkt;
}
GPacket gp = GPacket.getInstance();
gp.putProp("uuid", uuid);
gp.putProp("brokerID", brokerID);
gp.putProp("numfiles", numfiles);
gp.putProp("module", module);
gp.setType(ProtocolGlobals.G_TRANSFER_FILE_LIST);
gp.setBit(gp.A_BIT, false);
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterBrokerInfoReply method getGPacket.
public GPacket getGPacket() throws Exception {
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_BROKER_INFO_REPLY);
gp.setBit(pkt.A_BIT, false);
gp.putProp("S", Integer.valueOf(status));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(brokerInfo);
oos.flush();
oos.close();
byte[] buf = bos.toByteArray();
gp.setPayload(ByteBuffer.wrap(buf));
return gp;
}
use of com.sun.messaging.jmq.io.GPacket in project openmq by eclipse-ee4j.
the class ClusterNewMasterBrokerInfo method getGPacket.
public GPacket getGPacket() throws Exception {
GPacket gp = GPacket.getInstance();
gp.setType(ProtocolGlobals.G_NEW_MASTER_BROKER);
gp.putProp("TS", Long.valueOf(System.currentTimeMillis()));
gp.putProp("X", xid);
gp.putProp("UUID", uuid);
gp.putProp("oldMasterBroker", oldmaster.toProtocolString());
c.marshalBrokerAddress(newmaster, gp);
gp.setBit(gp.A_BIT, true);
return gp;
}
Aggregations