use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.
the class BrokerConsumers method getDebugState.
public Hashtable getDebugState() {
Hashtable ht = new Hashtable();
ArrayList l = null;
synchronized (deliveredMessages) {
l = new ArrayList(deliveredMessages.values());
}
ht.put("CLUSTER_ROUTER:deliveredMessagesCount", l.size());
Iterator itr = l.iterator();
while (itr.hasNext()) {
AckEntry e = (AckEntry) itr.next();
SysMessageID id = e.getSysMessageID();
ht.put("[deliveredMessages]" + id.toString(), e.toString());
}
synchronized (consumers) {
l = new ArrayList(consumers.keySet());
}
ht.put("consumersCount", l.size());
itr = l.iterator();
while (itr.hasNext()) {
ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID) itr.next();
Consumer c = (Consumer) consumers.get(cuid);
if (c instanceof Subscription) {
ht.put("[consumers]" + cuid.toString(), "Subscription: " + c);
} else {
ht.put("[consumers]" + cuid.toString(), c.toString());
}
}
synchronized (activeConsumers) {
l = new ArrayList(activeConsumers);
}
ht.put("activeConsumersCount", l.size());
Vector v = new Vector();
itr = l.iterator();
while (itr.hasNext()) {
Consumer c = (Consumer) itr.next();
if (c instanceof Subscription) {
v.add("Subscription: " + c);
} else {
v.add(c.toString());
}
}
ht.put("activeConsumers", v);
synchronized (pendingConsumerUIDs) {
l = new ArrayList(pendingConsumerUIDs.keySet());
}
ht.put("pendingConsumerUIDsCount", l.size());
itr = l.iterator();
while (itr.hasNext()) {
ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID) itr.next();
Map<TransactionUID, Set<AckEntry>> pending0, pending = null;
synchronized (deliveredMessages) {
pending0 = pendingConsumerUIDs.get(cuid);
if (pending0 != null) {
pending = new LinkedHashMap<>(pending0);
}
}
if (pending == null) {
ht.put("[pendingConsumerUIDs]" + cuid.toString(), "null");
} else {
Hashtable htt = new Hashtable();
Map.Entry<TransactionUID, Set<AckEntry>> pair = null;
TransactionUID key = null;
Iterator<Map.Entry<TransactionUID, Set<AckEntry>>> itr1 = pending.entrySet().iterator();
while (itr1.hasNext()) {
pair = itr1.next();
key = pair.getKey();
htt.put("PENDING-TID:" + (key == null ? "null" : key), new Vector(pair.getValue()));
}
ht.put("[pendingConsumerUIDs]" + cuid.toString(), htt);
}
}
synchronized (cleanupList) {
l = new ArrayList(cleanupList.keySet());
}
ht.put("cleanupListCount", l.size());
v = new Vector();
itr = l.iterator();
while (itr.hasNext()) {
ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID) itr.next();
v.add(cuid.toString());
}
ht.put("cleanupList", v);
synchronized (listeners) {
l = new ArrayList(listeners.keySet());
}
ht.put("listenersCount", l.size());
v = new Vector();
itr = l.iterator();
while (itr.hasNext()) {
ConsumerUID cuid = (com.sun.messaging.jmq.jmsserver.core.ConsumerUID) itr.next();
v.add(cuid.toString());
}
ht.put("listeners", v);
return ht;
}
use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.
the class ClusterConsumerInfo method readConsumerUID.
public static ConsumerUID readConsumerUID(DataInputStream dis) throws IOException {
// UID write
long id = dis.readLong();
ConnectionUID conuid = new ConnectionUID(dis.readLong());
BrokerAddress tempaddr = Globals.getMyAddress();
BrokerAddress brokeraddr = (BrokerAddress) tempaddr.clone();
// UID write
brokeraddr.readBrokerAddress(dis);
ConsumerUID cuid = new ConsumerUID(id);
cuid.setConnectionUID(conuid);
cuid.setBrokerAddress(brokeraddr);
return cuid;
}
use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.
the class ClusterConsumerInfo method readConsumer.
public static Consumer readConsumer(DataInputStream dis) throws IOException {
Logger logger = Globals.getLogger();
ConsumerUID id = null;
String destName = null;
String clientID = null;
String durableName = null;
String selstr = null;
boolean isQueue;
boolean noLocalDelivery;
// boolean consumerReady;
int sharedcnt;
int position;
// version
long ver = dis.readLong();
if (ver != ConsumerVersionUID) {
throw new IOException("Wrong Consumer Version " + ver + " expected " + ConsumerVersionUID);
}
destName = dis.readUTF();
boolean hasId = dis.readBoolean();
if (hasId) {
id = readConsumerUID(dis);
}
boolean hasClientID = dis.readBoolean();
if (hasClientID) {
clientID = dis.readUTF();
}
boolean hasDurableName = dis.readBoolean();
if (hasDurableName) {
durableName = dis.readUTF();
}
boolean hasSelector = dis.readBoolean();
if (hasSelector) {
selstr = dis.readUTF();
}
isQueue = dis.readBoolean();
noLocalDelivery = dis.readBoolean();
// consumerReady = dis.readBoolean();
dis.readBoolean();
boolean sharedSet = false;
sharedcnt = 1;
try {
sharedSet = dis.readBoolean();
if (sharedSet == true) {
sharedcnt = dis.readInt();
}
} catch (Exception ex) {
// do nothing prevents failures with old brokers
}
position = -1;
try {
position = dis.readInt();
} catch (Exception ex) {
// do nothing prevents failures with old brokers
}
// 5.0
boolean jmsshare = false;
String ndsubname = null;
try {
jmsshare = dis.readBoolean();
boolean hasndsubname = dis.readBoolean();
if (hasndsubname) {
ndsubname = dis.readUTF();
}
} catch (Exception ex) {
// do nothing prevents failures with old brokers
}
try {
DestinationUID dest = DestinationUID.getUID(destName, isQueue);
if (durableName != null) {
Subscription sub = Subscription.findCreateDurableSubscription(clientID, durableName, (sharedcnt != 1), jmsshare, dest, selstr, noLocalDelivery, false, id, Integer.valueOf(sharedcnt));
return sub;
} else {
if (sharedSet) {
/* non-durable subscriber */
Subscription sub = Subscription.findCreateNonDurableSubscription(clientID, selstr, ndsubname, (sharedcnt != 1), jmsshare, dest, noLocalDelivery, id, Integer.valueOf(sharedcnt));
return sub;
} else {
Consumer c = Consumer.newConsumer(dest, selstr, noLocalDelivery, id);
c.setLockPosition(position);
return c;
}
}
} catch (SelectorFormatException ex) {
logger.logStack(Logger.WARNING, "Got bad selector[" + selstr + "] ", ex);
IOException ioe = new IOException(ex.getMessage());
ioe.initCause(ex);
throw ioe;
} catch (BrokerException ex) {
if (ex.getStatusCode() == Status.CONFLICT || ex instanceof ConsumerAlreadyAddedException) {
logger.log(Logger.WARNING, ex.getMessage());
} else {
logger.logStack(Logger.WARNING, ex.getMessage(), ex);
}
IOException ioe = new IOException(ex.getMessage());
ioe.initCause(ex);
throw ioe;
}
}
use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.
the class ClusterMessageAckInfo method getAckEntryNotFoundException.
public static AckEntryNotFoundException getAckEntryNotFoundException(GPacket ackack) {
Integer notfound = (Integer) ackack.getProp("notfound");
if (notfound == null) {
return null;
}
int cnt = notfound.intValue();
// Long tid = (Long)ackack.getProp("transactionID");
String reason = (String) ackack.getProp("reason");
AckEntryNotFoundException aee = new AckEntryNotFoundException(reason);
byte[] buf = ackack.getPayload().array();
ByteArrayInputStream bis = new ByteArrayInputStream(buf);
DataInputStream dis = new DataInputStream(bis);
SysMessageID sysid = null;
ConsumerUID intid = null;
try {
for (int i = 0; i < cnt; i++) {
sysid = new SysMessageID();
sysid.readID(dis);
intid = ClusterConsumerInfo.readConsumerUID(dis);
aee.addAckEntry(sysid, intid);
}
} catch (Exception e) {
Globals.getLogger().logStack(Globals.getLogger().WARNING, e.getMessage(), e);
}
return aee;
}
use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.
the class FlowHandler method handle.
/**
* Method to handle flow messages
*/
@Override
public boolean handle(IMQConnection con, Packet msg) throws BrokerException {
if (DEBUG) {
logger.log(Logger.DEBUGHIGH, "FlowHandler: handle() [ Received Flow Message]");
}
assert msg.getPacketType() == PacketType.RESUME_FLOW;
Hashtable props = null;
try {
props = msg.getProperties();
} catch (Exception ex) {
logger.logStack(Logger.WARNING, "RESUME-FLOW Packet.getProperties()", ex);
props = new Hashtable();
}
Integer bufsize = null;
ConsumerSpi consumer = null;
if (props != null) {
bufsize = (Integer) props.get("JMQSize");
if (bufsize == null) {
// try old protocol
bufsize = (Integer) props.get("JMQRBufferSize");
}
Long cuid = (Long) props.get("JMQConsumerID");
if (cuid != null) {
ConsumerUID tmpuid = new ConsumerUID(cuid.longValue());
consumer = coreLifecycle.getConsumer(tmpuid);
}
}
if (DEBUG) {
logger.log(Logger.DEBUG, "Setting JMQRBufferSize -" + bufsize);
}
if (consumer != null) {
// consumer flow control
int size = (bufsize == null ? -1 : bufsize.intValue());
consumerFlow(consumer, size);
} else {
// connection flow control
int size = (bufsize == null ? -1 : bufsize.intValue());
connectionFlow(con, size);
}
return true;
}
Aggregations