Search in sources :

Example 21 with ConsumerUID

use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.

the class ProtocolConsumerUIDIterator method next.

/**
 * Caller must catch RuntimeException and getCause
 */
@Override
public Object next() throws RuntimeException {
    try {
        ConsumerUID cid = ClusterConsumerInfo.readConsumerUID(dis);
        if (from != null) {
            cid.setBrokerAddress(from);
        }
        count_read++;
        return cid;
    } catch (IOException e) {
        count_read = -1;
        throw new RuntimeException(e);
    }
}
Also used : ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID)

Example 22 with ConsumerUID

use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.

the class ConnectionMonitor method getConsumerIDs.

public String[] getConsumerIDs() throws MBeanException {
    List consumerIDs = ConnectionUtil.getConsumerIDs(id);
    String[] ids;
    if ((consumerIDs == null) || (consumerIDs.size() == 0)) {
        return (null);
    }
    ids = new String[consumerIDs.size()];
    Iterator iter = consumerIDs.iterator();
    int i = 0;
    while (iter.hasNext()) {
        ConsumerUID cid = (ConsumerUID) iter.next();
        long conID = cid.longValue();
        String id;
        try {
            id = Long.toString(conID);
            ids[i] = id;
        } catch (Exception ex) {
            handleOperationException(ConnectionOperations.GET_CONSUMER_IDS, ex);
        }
        i++;
    }
    return (ids);
}
Also used : ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) Iterator(java.util.Iterator) List(java.util.List) MBeanException(javax.management.MBeanException)

Example 23 with ConsumerUID

use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.

the class ConsumerManagerConfig method purge.

public void purge(String consumerID) throws MBeanException {
    ConsumerUID cid = null;
    try {
        cid = new ConsumerUID(Long.parseLong(consumerID));
    } catch (Exception e) {
        /*
             * XXX - should send specific 'cannot parse consumerID' exception
             */
        handleOperationException(ConsumerOperations.PURGE, e);
    }
    Consumer con = Consumer.getConsumer(cid);
    if (!con.isDurableSubscriber()) {
        logger.log(Logger.INFO, "Purge not supported for non durable subscribers.");
        return;
    }
    if (con instanceof Subscription) {
        Subscription sub = (Subscription) con;
        try {
            sub.purge();
        } catch (Exception e) {
            handleOperationException(ConsumerOperations.PURGE, e);
        }
    }
}
Also used : Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) Subscription(com.sun.messaging.jmq.jmsserver.core.Subscription) MBeanException(javax.management.MBeanException)

Example 24 with ConsumerUID

use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.

the class ConsumerManagerMonitor method getNumWildcardConsumers.

public Integer getNumWildcardConsumers(String wildcard) throws MBeanException {
    int numWildcardConsumers = Consumer.getNumWildcardConsumers();
    if (numWildcardConsumers <= 0) {
        return (Integer.valueOf(0));
    }
    Iterator consumers = Consumer.getWildcardConsumers();
    if (consumers == null) {
        return (Integer.valueOf(0));
    }
    int count = 0;
    while (consumers.hasNext()) {
        ConsumerUID cid = (ConsumerUID) consumers.next();
        Consumer oneCon = Consumer.getConsumer(cid);
        /*
             * If wildcard param is not null, check for matches If it is null, return total count of wildcards
             */
        if (wildcard != null) {
            DestinationUID id = oneCon.getDestinationUID();
            if (id.getName().equals(wildcard)) {
                count++;
            }
        } else {
            count++;
        }
    }
    return (Integer.valueOf(count));
}
Also used : DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) Iterator(java.util.Iterator)

Example 25 with ConsumerUID

use of com.sun.messaging.jmq.jmsserver.core.ConsumerUID in project openmq by eclipse-ee4j.

the class ConsumerUtil method getAllConsumersNoChildren.

public static HashMap getAllConsumersNoChildren() {
    Iterator it = Consumer.getAllConsumers();
    HashMap<ConsumerUID, Consumer> consumersNoChildren = new HashMap<>();
    while (it.hasNext()) {
        Consumer oneCon = (Consumer) it.next();
        ConsumerUID cid = oneCon.getConsumerUID();
        if (oneCon.getSubscription() == null) {
            consumersNoChildren.put(cid, oneCon);
        }
    }
    return (consumersNoChildren);
}
Also used : Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) HashMap(java.util.HashMap) Iterator(java.util.Iterator)

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