Package org.hornetq.core.server.impl

Examples of org.hornetq.core.server.impl.QueueImpl$DelayedAddRedistributor


   }

   public void testGetNonExistentReference() throws Exception
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);
      MessageReference messageReference = generateReference(queue, 1);
      MessageReference messageReference2 = generateReference(queue, 2);
      MessageReference messageReference3 = generateReference(queue, 3);
      queue.addHead(messageReference);
      queue.addHead(messageReference2);
      queue.addHead(messageReference3);
      Assert.assertNull(queue.getReference(5));

   }
View Full Code Here


    * Test the paused and resumed states with async deliveries.
    * @throws Exception
    */
   public void testPauseAndResumeWithAsync() throws Exception
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);

      // pauses the queue
      queue.pause();

      final int numMessages = 10;

      List<MessageReference> refs = new ArrayList<MessageReference>();

      for (int i = 0; i < numMessages; i++)
      {
         MessageReference ref = generateReference(queue, i);

         refs.add(ref);

         queue.addTail(ref);
      }
      // even as this queue is paused, it will receive the messages anyway
      Assert.assertEquals(10, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(0, queue.getDeliveringCount());

      // Now add a consumer
      FakeConsumer consumer = new FakeConsumer();

      queue.addConsumer(consumer);

      Assert.assertTrue(consumer.getReferences().isEmpty());
      Assert.assertEquals(10, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      // explicit order of delivery
      queue.deliverNow();
      // As the queue is paused, even an explicit order of delivery will not work.
      Assert.assertEquals(0, consumer.getReferences().size());
      Assert.assertEquals(numMessages, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(0, queue.getDeliveringCount());
      // resuming work
      queue.resume();
     
      awaitExecution();;

      // after resuming the delivery begins.
      assertRefListsIdenticalRefs(refs, consumer.getReferences());
      Assert.assertEquals(numMessages, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(numMessages, queue.getDeliveringCount());

   }
View Full Code Here

    * @throws Exception
    */

   public void testPauseAndResumeWithDirect() throws Exception
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);

      // Now add a consumer
      FakeConsumer consumer = new FakeConsumer();

      queue.addConsumer(consumer);

      // brings to queue to paused state
      queue.pause();

      final int numMessages = 10;

      List<MessageReference> refs = new ArrayList<MessageReference>();

      for (int i = 0; i < numMessages; i++)
      {
         MessageReference ref = generateReference(queue, i);
         refs.add(ref);
         queue.addTail(ref);
      }

      // the queue even if it's paused will receive the message but won't forward
      // directly to the consumer until resumed.
      Assert.assertEquals(numMessages, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(0, queue.getDeliveringCount());
      Assert.assertTrue(consumer.getReferences().isEmpty());

      // brings the queue to resumed state.
      queue.resume();
     
     
      awaitExecution();;
     
      // resuming delivery of messages
      assertRefListsIdenticalRefs(refs, consumer.getReferences());
      Assert.assertEquals(numMessages, queue.getMessageCount());
      Assert.assertEquals(numMessages, queue.getDeliveringCount());

   }
View Full Code Here

   }

  
   public void testRoundRobinWithQueueing() throws Exception
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);

      final int numMessages = 10;

      List<MessageReference> refs = new ArrayList<MessageReference>();

      // Test first with queueing

      for (int i = 0; i < numMessages; i++)
      {
         MessageReference ref = generateReference(queue, i);

         refs.add(ref);

         queue.addTail(ref);
      }

      FakeConsumer cons1 = new FakeConsumer();

      FakeConsumer cons2 = new FakeConsumer();

      queue.addConsumer(cons1);

      queue.addConsumer(cons2);

      queue.deliverNow();

      Assert.assertEquals(numMessages / 2, cons1.getReferences().size());

      Assert.assertEquals(numMessages / 2, cons2.getReferences().size());
View Full Code Here

      }
   }

   public void testWithPriorities() throws Exception
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);

      final int numMessages = 10;

      List<MessageReference> refs = new ArrayList<MessageReference>();

      for (int i = 0; i < numMessages; i++)
      {
         MessageReference ref = generateReference(queue, i);

         ref.getMessage().setPriority((byte)i);

         refs.add(ref);

         queue.addTail(ref);
      }
     
      queue.deliverNow();

      FakeConsumer consumer = new FakeConsumer();

      queue.addConsumer(consumer);
     
      queue.deliverNow();
     
      List<MessageReference> receivedRefs = consumer.getReferences();

      // Should be in reverse order
View Full Code Here

      testConsumerWithFilters(false);
   }

   public void testConsumerWithFilterAddAndRemove()
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
View Full Code Here

      FakeConsumer consumer = new FakeConsumer(filter);
   }

   public void testIterator()
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);

      final int numMessages = 20;

      List<MessageReference> refs = new ArrayList<MessageReference>();

      for (int i = 0; i < numMessages; i++)
      {
         MessageReference ref = generateReference(queue, i);

         queue.addTail(ref);

         refs.add(ref);
      }

      Assert.assertEquals(numMessages, queue.getMessageCount());

      Iterator<MessageReference> iterator = queue.iterator();     
      List<MessageReference> list = new ArrayList<MessageReference>();
      while (iterator.hasNext())
      {
         list.add(iterator.next());
      }
View Full Code Here

   }

   public void testConsumeWithFiltersAddAndRemoveConsumer() throws Exception
   {
   
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      new FakePostOffice(),
                                      null,
                                      null,
                                      executor);

      Filter filter = new FakeFilter("fruit", "orange");

      FakeConsumer consumer = new FakeConsumer(filter);

      queue.addConsumer(consumer);

      List<MessageReference> refs = new ArrayList<MessageReference>();

      MessageReference ref1 = generateReference(queue, 1);

      ref1.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("banana"));

      queue.addTail(ref1);

      MessageReference ref2 = generateReference(queue, 2);

      ref2.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("orange"));

      queue.addTail(ref2);

      refs.add(ref2);

      Assert.assertEquals(2, queue.getMessageCount());
     
      awaitExecution();;

      Assert.assertEquals(1, consumer.getReferences().size());

      Assert.assertEquals(1, queue.getDeliveringCount());

      assertRefListsIdenticalRefs(refs, consumer.getReferences());

      queue.acknowledge(ref2);

      queue.removeConsumer(consumer);

      queue.addConsumer(consumer);

      queue.deliverNow();

      refs.clear();

      consumer.clearReferences();

      MessageReference ref3 = generateReference(queue, 3);

      ref3.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("banana"));

      queue.addTail(ref3);

      MessageReference ref4 = generateReference(queue, 4);

      ref4.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("orange"));

      queue.addTail(ref4);

      refs.add(ref4);

      Assert.assertEquals(3, queue.getMessageCount());
     
      awaitExecution();;

      Assert.assertEquals(1, consumer.getReferences().size());

      Assert.assertEquals(1, queue.getDeliveringCount());

      assertRefListsIdenticalRefs(refs, consumer.getReferences());
   }
View Full Code Here

      assertRefListsIdenticalRefs(refs, consumer.getReferences());
   }

   public void testBusyConsumerWithFilterFirstCallBusy() throws Exception
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);

      FakeConsumer consumer = new FakeConsumer(FilterImpl.createFilter("color = 'green'"));

      consumer.setStatusImmediate(HandleStatus.BUSY);

      queue.addConsumer(consumer);

      final int numMessages = 10;

      List<MessageReference> refs = new ArrayList<MessageReference>();

      for (int i = 0; i < numMessages; i++)
      {
         MessageReference ref = generateReference(queue, i);
         ref.getMessage().putStringProperty("color", "green");
         refs.add(ref);

         queue.addTail(ref);
      }

      Assert.assertEquals(10, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(0, queue.getDeliveringCount());

      queue.deliverNow();

      consumer.setStatusImmediate(null);

      queue.deliverNow();

      List<MessageReference> receeivedRefs = consumer.getReferences();
      int currId = 0;
      for (MessageReference receeivedRef : receeivedRefs)
      {
View Full Code Here

      }
   }

   public void testBusyConsumerWithFilterThenAddMoreMessages() throws Exception
   {
      QueueImpl queue = new QueueImpl(1,
                                      QueueImplTest.address1,
                                      QueueImplTest.queue1,
                                      null,
                                      false,
                                      true,
                                      scheduledExecutor,
                                      null,
                                      null,
                                      null,
                                      executor);

      FakeConsumer consumer = new FakeConsumer(FilterImpl.createFilter("color = 'green'"));

      consumer.setStatusImmediate(HandleStatus.BUSY);

      queue.addConsumer(consumer);

      final int numMessages = 10;

      List<MessageReference> refs = new ArrayList<MessageReference>();

      for (int i = 0; i < numMessages; i++)
      {
         MessageReference ref = generateReference(queue, i);
         ref.getMessage().putStringProperty("color", "red");
         refs.add(ref);

         queue.addTail(ref);
      }

      Assert.assertEquals(10, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(0, queue.getDeliveringCount());

      queue.deliverNow();

      Assert.assertEquals(10, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(0, queue.getDeliveringCount());
      Assert.assertTrue(consumer.getReferences().isEmpty());

      for (int i = numMessages; i < numMessages * 2; i++)
      {
         MessageReference ref = generateReference(queue, i);

         refs.add(ref);
         ref.getMessage().putStringProperty("color", "green");
         queue.addTail(ref);
      }

      Assert.assertEquals(20, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(0, queue.getDeliveringCount());
      Assert.assertTrue(consumer.getReferences().isEmpty());

      consumer.setStatusImmediate(null);

      for (int i = numMessages * 2; i < numMessages * 3; i++)
      {
         MessageReference ref = generateReference(queue, i);

         refs.add(ref);

         queue.addTail(ref);
      }

      queue.deliverNow();

      Assert.assertEquals(numMessages, consumer.getReferences().size());
      Assert.assertEquals(30, queue.getMessageCount());
      Assert.assertEquals(0, queue.getScheduledCount());
      Assert.assertEquals(10, queue.getDeliveringCount());

      List<MessageReference> receeivedRefs = consumer.getReferences();
      int currId = 10;
      for (MessageReference receeivedRef : receeivedRefs)
      {
View Full Code Here

TOP

Related Classes of org.hornetq.core.server.impl.QueueImpl$DelayedAddRedistributor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.