Search in sources :

Example 56 with ConsumerUID

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) TransactionUID(com.sun.messaging.jmq.jmsserver.data.TransactionUID) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) Iterator(java.util.Iterator) SysMessageID(com.sun.messaging.jmq.io.SysMessageID) Subscription(com.sun.messaging.jmq.jmsserver.core.Subscription) Vector(java.util.Vector) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 57 with ConsumerUID

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;
}
Also used : ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID) BrokerAddress(com.sun.messaging.jmq.jmsserver.core.BrokerAddress)

Example 58 with ConsumerUID

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;
    }
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) Logger(com.sun.messaging.jmq.util.log.Logger) ConsumerAlreadyAddedException(com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException) SelectorFormatException(com.sun.messaging.jmq.util.selector.SelectorFormatException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) SelectorFormatException(com.sun.messaging.jmq.util.selector.SelectorFormatException) ConsumerAlreadyAddedException(com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) Subscription(com.sun.messaging.jmq.jmsserver.core.Subscription)

Example 59 with ConsumerUID

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;
}
Also used : ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) AckEntryNotFoundException(com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException) SysMessageID(com.sun.messaging.jmq.io.SysMessageID) AckEntryNotFoundException(com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)

Example 60 with ConsumerUID

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;
}
Also used : ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) ConsumerSpi(com.sun.messaging.jmq.jmsserver.plugin.spi.ConsumerSpi) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Aggregations

ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)83 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)29 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)28 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)27 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)22 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)21 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)21 Iterator (java.util.Iterator)21 HashMap (java.util.HashMap)19 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)17 TransactionUID (com.sun.messaging.jmq.jmsserver.data.TransactionUID)16 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)15 Map (java.util.Map)15 List (java.util.List)13 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)10 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)10 Session (com.sun.messaging.jmq.jmsserver.core.Session)10 TransactionList (com.sun.messaging.jmq.jmsserver.data.TransactionList)10 AckEntryNotFoundException (com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)9