Search in sources :

Example 1 with UnproposalListener

use of org.apache.activemq.artemis.core.server.group.UnproposalListener in project activemq-artemis by apache.

the class ClusteredGroupingTest method testTimeoutOnSending.

@Test
public void testTimeoutOnSending() throws Exception {
    setupServer(0, isFileStorage(), isNetty());
    setupServer(1, isFileStorage(), isNetty());
    setupServer(2, isFileStorage(), isNetty());
    setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1, 2);
    setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0, 2);
    setupClusterConnection("cluster2", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 0, 1);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1, 0);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2, 0);
    final CountDownLatch latch = new CountDownLatch(BindingsImpl.MAX_GROUP_RETRY);
    setUpGroupHandler(new GroupingHandler() {

        @Override
        public void awaitBindings() throws Exception {
        }

        @Override
        public void addListener(UnproposalListener listener) {
        }

        @Override
        public void resendPending() throws Exception {
        }

        @Override
        public void remove(SimpleString groupid, SimpleString clusterName) throws Exception {
        }

        @Override
        public void forceRemove(SimpleString groupid, SimpleString clusterName) throws Exception {
        }

        @Override
        public SimpleString getName() {
            return null;
        }

        @Override
        public void remove(SimpleString id, SimpleString groupId, int distance) {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        @Override
        public void start() throws Exception {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        @Override
        public void stop() throws Exception {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        @Override
        public boolean isStarted() {
            return false;
        }

        @Override
        public Response propose(final Proposal proposal) throws Exception {
            return null;
        }

        @Override
        public void proposed(final Response response) throws Exception {
            System.out.println("ClusteredGroupingTest.proposed");
        }

        @Override
        public void sendProposalResponse(final Response response, final int distance) throws Exception {
            System.out.println("ClusteredGroupingTest.send");
        }

        @Override
        public Response receive(final Proposal proposal, final int distance) throws Exception {
            latch.countDown();
            return null;
        }

        @Override
        public void onNotification(final Notification notification) {
            System.out.println("ClusteredGroupingTest.onNotification " + notification);
        }

        @Override
        public void addGroupBinding(final GroupBinding groupBinding) {
            System.out.println("ClusteredGroupingTest.addGroupBinding");
        }

        @Override
        public Response getProposal(final SimpleString fullID, boolean touchTime) {
            return null;
        }
    }, 0);
    startServers(0, 1, 2);
    setupSessionFactory(0, isNetty());
    setupSessionFactory(1, isNetty());
    setupSessionFactory(2, isNetty());
    createQueue(0, "queues.testaddress", "queue0", null, false);
    createQueue(1, "queues.testaddress", "queue0", null, false);
    createQueue(2, "queues.testaddress", "queue0", null, false);
    addConsumer(0, 0, "queue0", null);
    addConsumer(1, 1, "queue0", null);
    addConsumer(2, 2, "queue0", null);
    waitForBindings(0, "queues.testaddress", 1, 1, true);
    waitForBindings(1, "queues.testaddress", 1, 1, true);
    waitForBindings(2, "queues.testaddress", 1, 1, true);
    waitForBindings(0, "queues.testaddress", 2, 2, false);
    waitForBindings(1, "queues.testaddress", 2, 2, false);
    waitForBindings(2, "queues.testaddress", 2, 2, false);
    try {
        sendWithProperty(1, "queues.testaddress", 1, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
        // it should get the Retries on the latch
        assertTrue(latch.await(10, TimeUnit.SECONDS));
    } catch (Exception e) {
        // To change body of catch statement use File | Settings | File Templates.
        e.printStackTrace();
    }
}
Also used : Response(org.apache.activemq.artemis.core.server.group.impl.Response) UnproposalListener(org.apache.activemq.artemis.core.server.group.UnproposalListener) GroupBinding(org.apache.activemq.artemis.core.server.group.impl.GroupBinding) GroupingHandler(org.apache.activemq.artemis.core.server.group.GroupingHandler) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CountDownLatch(java.util.concurrent.CountDownLatch) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) Proposal(org.apache.activemq.artemis.core.server.group.impl.Proposal) Notification(org.apache.activemq.artemis.core.server.management.Notification) Test(org.junit.Test)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 GroupingHandler (org.apache.activemq.artemis.core.server.group.GroupingHandler)1 UnproposalListener (org.apache.activemq.artemis.core.server.group.UnproposalListener)1 GroupBinding (org.apache.activemq.artemis.core.server.group.impl.GroupBinding)1 Proposal (org.apache.activemq.artemis.core.server.group.impl.Proposal)1 Response (org.apache.activemq.artemis.core.server.group.impl.Response)1 Notification (org.apache.activemq.artemis.core.server.management.Notification)1 Test (org.junit.Test)1