Search in sources :

Example 6 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project activemq-artemis by apache.

the class MessageDispatchTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    MessageDispatch info = (MessageDispatch) object;
    info.setConsumerId(createConsumerId("ConsumerId:1"));
    info.setDestination(createActiveMQDestination("Destination:2"));
    info.setMessage(createMessage("Message:3"));
    info.setRedeliveryCounter(1);
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Example 7 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project activemq-artemis by apache.

the class ThreeBrokerQueueNetworkTest method testNoDuplicateQueueSubsHasLowestPriority.

public void testNoDuplicateQueueSubsHasLowestPriority() throws Exception {
    boolean suppressQueueDuplicateSubscriptions = true;
    boolean decreaseNetworkConsumerPriority = true;
    bridgeAllBrokers("default", 3, suppressQueueDuplicateSubscriptions, decreaseNetworkConsumerPriority);
    // Setup destination
    final Destination dest = createDestination("TEST.FOO", false);
    // delay the advisory messages so that one can percolate fully (cyclically) before the other
    BrokerItem brokerB = brokers.get("BrokerA");
    brokerB.broker.setPlugins(new BrokerPlugin[] { new BrokerPlugin() {

        @Override
        public Broker installPlugin(Broker broker) throws Exception {
            return new BrokerFilter(broker) {

                final AtomicInteger count = new AtomicInteger();

                @Override
                public void preProcessDispatch(MessageDispatch messageDispatch) {
                    if (messageDispatch.getDestination().getPhysicalName().contains("ActiveMQ.Advisory.Consumer")) {
                        // lets delay the first advisory
                        if (count.getAndIncrement() == 0) {
                            LOG.info("Sleeping on first advisory: " + messageDispatch);
                            try {
                                Thread.sleep(2000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    super.postProcessDispatch(messageDispatch);
                }
            };
        }
    } });
    startAllBrokers();
    waitForBridgeFormation();
    // Setup consumers
    String brokerName = "BrokerA";
    createConsumer(brokerName, dest);
    // wait for advisories
    Thread.sleep(5000);
    // verify there is one consumer on each broker, no cycles
    Collection<BrokerItem> brokerList = brokers.values();
    for (Iterator<BrokerItem> i = brokerList.iterator(); i.hasNext(); ) {
        BrokerService broker = i.next().broker;
        verifyConsumerCount(broker, 1, dest);
        if (!brokerName.equals(broker.getBrokerName())) {
            verifyConsumePriority(broker, ConsumerInfo.NETWORK_CONSUMER_PRIORITY, dest);
        }
    }
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) Destination(javax.jms.Destination) Broker(org.apache.activemq.broker.Broker) RegionBroker(org.apache.activemq.broker.region.RegionBroker) BrokerPlugin(org.apache.activemq.broker.BrokerPlugin) BrokerFilter(org.apache.activemq.broker.BrokerFilter) MessageDispatch(org.apache.activemq.command.MessageDispatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BrokerService(org.apache.activemq.broker.BrokerService)

Example 8 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project activemq-artemis by apache.

the class MessageDispatchTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    MessageDispatch info = (MessageDispatch) object;
    info.setConsumerId(createConsumerId("ConsumerId:1"));
    info.setDestination(createActiveMQDestination("Destination:2"));
    info.setMessage(createMessage("Message:3"));
    info.setRedeliveryCounter(1);
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Example 9 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project activemq-artemis by apache.

the class MessageDispatchTest method createObject.

@Override
public Object createObject() throws Exception {
    MessageDispatch info = new MessageDispatch();
    populateObject(info);
    return info;
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Example 10 with MessageDispatch

use of org.apache.activemq.command.MessageDispatch in project activemq-artemis by apache.

the class MessageDispatchTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    MessageDispatch info = (MessageDispatch) object;
    info.setConsumerId(createConsumerId("ConsumerId:1"));
    info.setDestination(createActiveMQDestination("Destination:2"));
    info.setMessage(createMessage("Message:3"));
    info.setRedeliveryCounter(1);
}
Also used : MessageDispatch(org.apache.activemq.command.MessageDispatch)

Aggregations

MessageDispatch (org.apache.activemq.command.MessageDispatch)34 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)6 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)4 ActiveMQSessionGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.ActiveMQSessionGetter)3 Transport (org.apache.activemq.transport.Transport)3 IOException (java.io.IOException)2 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)2 ActiveMQSession (org.apache.activemq.ActiveMQSession)2 BrokerService (org.apache.activemq.broker.BrokerService)2 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)2 SocketGetter (com.navercorp.pinpoint.plugin.activemq.client.field.getter.SocketGetter)1 Socket (java.net.Socket)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Destination (javax.jms.Destination)1 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)1 Broker (org.apache.activemq.broker.Broker)1 BrokerFilter (org.apache.activemq.broker.BrokerFilter)1 BrokerPlugin (org.apache.activemq.broker.BrokerPlugin)1