当前位置: 首页>>代码示例>>Java>>正文


Java ConsumerInfo.setPrefetchSize方法代码示例

本文整理汇总了Java中org.apache.activemq.command.ConsumerInfo.setPrefetchSize方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumerInfo.setPrefetchSize方法的具体用法?Java ConsumerInfo.setPrefetchSize怎么用?Java ConsumerInfo.setPrefetchSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.command.ConsumerInfo的用法示例。


在下文中一共展示了ConsumerInfo.setPrefetchSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createConnectionConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages, boolean noLocal)
    throws JMSException {

    checkClosedOrFailed();
    ensureConnectionInfoSent();

    ConsumerId consumerId = createConsumerId();
    ConsumerInfo consumerInfo = new ConsumerInfo(consumerId);
    consumerInfo.setDestination(ActiveMQMessageTransformation.transformDestination(destination));
    consumerInfo.setSelector(messageSelector);
    consumerInfo.setPrefetchSize(maxMessages);
    consumerInfo.setNoLocal(noLocal);
    consumerInfo.setDispatchAsync(isDispatchAsync());

    // Allows the options on the destination to configure the consumerInfo
    if (consumerInfo.getDestination().getOptions() != null) {
        Map<String, String> options = new HashMap<String, String>(consumerInfo.getDestination().getOptions());
        IntrospectionSupport.setProperties(consumerInfo, options, "consumer.");
    }

    return new ActiveMQConnectionConsumer(this, sessionPool, consumerInfo);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:23,代码来源:ActiveMQConnection.java

示例2: testSendingSmallMessage

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testSendingSmallMessage() throws Exception {
   ConsumerInfo expected = new ConsumerInfo();
   expected.setSelector("Cheese");
   expected.setExclusive(true);
   expected.setExclusive(true);
   expected.setPrefetchSize(3456);

   try {
      LOG.info("About to send: " + expected);
      producer.oneway(expected);

      Command received = assertCommandReceived();
      assertTrue("Should have received a ConsumerInfo but was: " + received, received instanceof ConsumerInfo);
      ConsumerInfo actual = (ConsumerInfo) received;
      assertEquals("Selector", expected.getSelector(), actual.getSelector());
      assertEquals("isExclusive", expected.isExclusive(), actual.isExclusive());
      assertEquals("getPrefetchSize", expected.getPrefetchSize(), actual.getPrefetchSize());
   } catch (Exception e) {
      LOG.info("Caught: " + e);
      e.printStackTrace();
      fail("Failed to send to transport: " + e);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:UdpTestSupport.java

示例3: createConsumerInfo

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
protected ConsumerInfo createConsumerInfo(SessionInfo sessionInfo,
                                          ActiveMQDestination destination) throws Exception {
   ConsumerInfo info = new ConsumerInfo(sessionInfo, ++idGenerator);
   info.setBrowser(false);
   info.setDestination(destination);
   info.setPrefetchSize(1000);
   info.setDispatchAsync(false);
   return info;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:10,代码来源:FailoverTransportBrokerTest.java

示例4: testTransactedAckWithPrefetchOfOne

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testTransactedAckWithPrefetchOfOne() throws Exception {

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      destination = createDestinationInfo(connection1, connectionInfo1, destinationType);

      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
      consumerInfo1.setPrefetchSize(1);
      connection1.send(consumerInfo1);

      // Send the messages
      for (int i = 0; i < 4; i++) {
         Message message = createMessage(producerInfo1, destination, deliveryMode);
         connection1.send(message);
      }

      // Now get the messages.
      for (int i = 0; i < 4; i++) {
         // Begin the transaction.
         LocalTransactionId txid = createLocalTransaction(sessionInfo1);
         connection1.send(createBeginTransaction(connectionInfo1, txid));
         Message m1 = receiveMessage(connection1);
         assertNotNull(m1);
         MessageAck ack = createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE);
         ack.setTransactionId(txid);
         connection1.send(ack);
         // Commit the transaction.
         connection1.send(createCommitTransaction1Phase(connectionInfo1, txid));
      }
      assertNoMessagesLeft(connection1);
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:39,代码来源:BrokerTest.java

示例5: testConsumerPrefetchAndDeliveredAck

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testConsumerPrefetchAndDeliveredAck() throws Exception {

      // Start a producer and consumer
      StubConnection connection = createConnection();
      ConnectionInfo connectionInfo = createConnectionInfo();
      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
      connection.send(connectionInfo);
      connection.send(sessionInfo);
      connection.send(producerInfo);

      destination = createDestinationInfo(connection, connectionInfo, destinationType);

      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
      consumerInfo.setPrefetchSize(1);
      connection.request(consumerInfo);

      // Send 3 messages to the broker.
      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.request(createMessage(producerInfo, destination, deliveryMode));

      // Make sure only 1 message was delivered.
      Message m1 = receiveMessage(connection);
      assertNotNull(m1);

      assertNoMessagesLeft(connection);

      // Acknowledge the first message. This should cause the next message to
      // get dispatched.
      connection.request(createAck(consumerInfo, m1, 1, MessageAck.DELIVERED_ACK_TYPE));

      Message m2 = receiveMessage(connection);
      assertNotNull(m2);
      connection.request(createAck(consumerInfo, m2, 1, MessageAck.DELIVERED_ACK_TYPE));

      Message m3 = receiveMessage(connection);
      assertNotNull(m3);
      connection.request(createAck(consumerInfo, m3, 1, MessageAck.DELIVERED_ACK_TYPE));
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:41,代码来源:BrokerTest.java

示例6: testConsumerPrefetchAtOne

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testConsumerPrefetchAtOne() throws Exception {

      // Start a producer and consumer
      StubConnection connection = createConnection();
      ConnectionInfo connectionInfo = createConnectionInfo();
      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
      connection.send(connectionInfo);
      connection.send(sessionInfo);
      connection.send(producerInfo);

      destination = createDestinationInfo(connection, connectionInfo, destinationType);

      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
      consumerInfo.setPrefetchSize(1);
      connection.send(consumerInfo);

      // Send 2 messages to the broker.
      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.send(createMessage(producerInfo, destination, deliveryMode));

      // Make sure only 1 message was delivered.
      Message m = receiveMessage(connection);
      assertNotNull(m);
      assertNoMessagesLeft(connection);

   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:28,代码来源:BrokerTest.java

示例7: AdvisoryConsumer

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public AdvisoryConsumer(ActiveMQConnection connection, ConsumerId consumerId) throws JMSException {
    this.connection = connection;
    info = new ConsumerInfo(consumerId);
    info.setDestination(AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC);
    info.setPrefetchSize(1000);
    info.setNoLocal(true);
    info.setDispatchAsync(true);

    this.connection.addDispatcher(info.getConsumerId(), this);
    this.connection.syncSendPacket(this.info);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:12,代码来源:AdvisoryConsumer.java

示例8: testConsumerPrefetchAtTwo

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testConsumerPrefetchAtTwo() throws Exception {

      // Start a producer and consumer
      StubConnection connection = createConnection();
      ConnectionInfo connectionInfo = createConnectionInfo();
      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
      connection.send(connectionInfo);
      connection.send(sessionInfo);
      connection.send(producerInfo);

      destination = createDestinationInfo(connection, connectionInfo, destinationType);

      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
      consumerInfo.setPrefetchSize(2);
      connection.send(consumerInfo);

      // Send 3 messages to the broker.
      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.send(createMessage(producerInfo, destination, deliveryMode));

      // Make sure only 1 message was delivered.
      Message m = receiveMessage(connection);
      assertNotNull(m);
      m = receiveMessage(connection);
      assertNotNull(m);
      assertNoMessagesLeft(connection);

   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:31,代码来源:BrokerTest.java

示例9: testWildcardConsume

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testWildcardConsume() throws Exception {

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      // setup the wildcard consumer.
      ActiveMQDestination compositeDestination = ActiveMQDestination.createDestination("WILD.*.TEST", destinationType);
      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, compositeDestination);
      consumerInfo1.setPrefetchSize(100);
      connection1.send(consumerInfo1);

      // These two message should NOT match the wild card.
      connection1.send(createMessage(producerInfo1, ActiveMQDestination.createDestination("WILD.CARD", destinationType), deliveryMode));
      connection1.send(createMessage(producerInfo1, ActiveMQDestination.createDestination("WILD.TEST", destinationType), deliveryMode));

      // These two message should match the wild card.
      ActiveMQDestination d1 = ActiveMQDestination.createDestination("WILD.CARD.TEST", destinationType);
      connection1.send(createMessage(producerInfo1, d1, deliveryMode));

      Message m = receiveMessage(connection1);
      assertNotNull(m);
      assertEquals(d1, m.getDestination());

      ActiveMQDestination d2 = ActiveMQDestination.createDestination("WILD.FOO.TEST", destinationType);
      connection1.request(createMessage(producerInfo1, d2, deliveryMode));
      m = receiveMessage(connection1);
      assertNotNull(m);
      assertEquals(d2, m.getDestination());

      assertNoMessagesLeft(connection1);
      connection1.send(closeConnectionInfo(connectionInfo1));
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:39,代码来源:BrokerTest.java

示例10: testTopicRetroactiveConsumerSeeMessagesBeforeCreation

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testTopicRetroactiveConsumerSeeMessagesBeforeCreation() throws Exception {

      ActiveMQDestination destination = new ActiveMQTopic("TEST");

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      connectionInfo1.setClientId("A");
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      // Send the messages
      Message m = createMessage(producerInfo1, destination, deliveryMode);
      connection1.send(m);

      // Create the durable subscription.
      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
      if (durableConsumer) {
         consumerInfo1.setSubscriptionName("test");
      }
      consumerInfo1.setPrefetchSize(100);
      consumerInfo1.setRetroactive(true);
      connection1.send(consumerInfo1);

      connection1.send(createMessage(producerInfo1, destination, deliveryMode));
      connection1.request(createMessage(producerInfo1, destination, deliveryMode));

      // the behavior is VERY dependent on the recovery policy used.
      // But the default broker settings try to make it as consistent as
      // possible

      // Subscription should see all messages sent.
      Message m2 = receiveMessage(connection1);
      assertNotNull(m2);
      assertEquals(m.getMessageId(), m2.getMessageId());
      for (int i = 0; i < 2; i++) {
         m2 = receiveMessage(connection1);
         assertNotNull(m2);
      }

      assertNoMessagesLeft(connection1);
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:46,代码来源:BrokerTest.java

示例11: testTopicDispatchIsBroadcast

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testTopicDispatchIsBroadcast() throws Exception {

      ActiveMQDestination destination = new ActiveMQTopic("TEST");

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
      consumerInfo1.setRetroactive(true);
      consumerInfo1.setPrefetchSize(100);
      connection1.send(consumerInfo1);

      // Setup a second connection
      StubConnection connection2 = createConnection();
      ConnectionInfo connectionInfo2 = createConnectionInfo();
      SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
      ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
      consumerInfo2.setRetroactive(true);
      consumerInfo2.setPrefetchSize(100);
      connection2.send(connectionInfo2);
      connection2.send(sessionInfo2);
      connection2.send(consumerInfo2);

      // Send the messages
      connection1.send(createMessage(producerInfo1, destination, deliveryMode));
      connection1.send(createMessage(producerInfo1, destination, deliveryMode));
      connection1.send(createMessage(producerInfo1, destination, deliveryMode));
      connection1.send(createMessage(producerInfo1, destination, deliveryMode));

      // Get the messages
      for (int i = 0; i < 4; i++) {
         Message m1 = receiveMessage(connection1);
         assertNotNull(m1);
         m1 = receiveMessage(connection2);
         assertNotNull(m1);
      }
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:44,代码来源:BrokerTest.java

示例12: testTopicDurableSubscriptionCanBeRestored

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testTopicDurableSubscriptionCanBeRestored() throws Exception {

      ActiveMQDestination destination = new ActiveMQTopic("TEST");

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      connectionInfo1.setClientId("clientid1");
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
      consumerInfo1.setPrefetchSize(100);
      consumerInfo1.setSubscriptionName("test");
      connection1.send(consumerInfo1);

      // Send the messages
      connection1.send(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));
      connection1.send(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));
      connection1.send(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));
      connection1.request(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));

      // Get the messages
      Message m = null;
      for (int i = 0; i < 2; i++) {
         m = receiveMessage(connection1);
         assertNotNull(m);
      }
      // Ack the last message.
      connection1.send(createAck(consumerInfo1, m, 2, MessageAck.STANDARD_ACK_TYPE));
      // Close the connection.
      connection1.request(closeConnectionInfo(connectionInfo1));
      connection1.stop();

      // Setup a second connection
      StubConnection connection2 = createConnection();
      ConnectionInfo connectionInfo2 = createConnectionInfo();
      connectionInfo2.setClientId("clientid1");
      SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
      ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
      consumerInfo2.setPrefetchSize(100);
      consumerInfo2.setSubscriptionName("test");

      connection2.send(connectionInfo2);
      connection2.send(sessionInfo2);
      connection2.send(consumerInfo2);

      // Get the rest of the messages
      for (int i = 0; i < 2; i++) {
         Message m1 = receiveMessage(connection2);
         assertNotNull("m1 is null for index: " + i, m1);
      }
      assertNoMessagesLeft(connection2);
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:58,代码来源:BrokerTest.java

示例13: testQueueBrowserWith2ConsumersBrowseFirst

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testQueueBrowserWith2ConsumersBrowseFirst() throws Exception {

      ActiveMQDestination destination = new ActiveMQQueue("TEST");
      deliveryMode = DeliveryMode.NON_PERSISTENT;

      // Setup a second connection with a queue browser.
      StubConnection connection2 = createConnection();
      ConnectionInfo connectionInfo2 = createConnectionInfo();
      SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
      ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
      consumerInfo2.setPrefetchSize(10);
      consumerInfo2.setBrowser(true);
      connection2.send(connectionInfo2);
      connection2.send(sessionInfo2);
      connection2.request(consumerInfo2);

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo);

      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
      consumerInfo1.setPrefetchSize(10);
      connection1.request(consumerInfo1);

      // Send the messages
      connection1.send(createMessage(producerInfo, destination, deliveryMode));
      connection1.send(createMessage(producerInfo, destination, deliveryMode));
      connection1.send(createMessage(producerInfo, destination, deliveryMode));
      //as the messages are sent async - need to synchronize the last
      //one to ensure they arrive in the order we want
      connection1.request(createMessage(producerInfo, destination, deliveryMode));

      List<Message> messages = new ArrayList<>();

      for (int i = 0; i < 4; i++) {
         Message m1 = receiveMessage(connection1);
         assertNotNull("m1 is null for index: " + i, m1);
         messages.add(m1);
      }

      // no messages present in queue browser as there were no messages when it
      // was created
      assertNoMessagesLeft(connection1);
      assertNoMessagesLeft(connection2);
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:51,代码来源:BrokerTest.java

示例14: looseUnmarshal

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
/**
 * Un-marshal an object instance from the data input stream
 * 
 * @param o the object to un-marshal
 * @param dataIn the data input stream to build the object from
 * @throws IOException
 */
public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
    super.looseUnmarshal(wireFormat, o, dataIn);

    ConsumerInfo info = (ConsumerInfo)o;
    info.setConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat,
                                                                                         dataIn));
    info.setBrowser(dataIn.readBoolean());
    info
        .setDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(
                                                                                                   wireFormat,
                                                                                                   dataIn));
    info.setPrefetchSize(dataIn.readInt());
    info.setMaximumPendingMessageLimit(dataIn.readInt());
    info.setDispatchAsync(dataIn.readBoolean());
    info.setSelector(looseUnmarshalString(dataIn));
    info.setSubscriptionName(looseUnmarshalString(dataIn));
    info.setNoLocal(dataIn.readBoolean());
    info.setExclusive(dataIn.readBoolean());
    info.setRetroactive(dataIn.readBoolean());
    info.setPriority(dataIn.readByte());

    if (dataIn.readBoolean()) {
        short size = dataIn.readShort();
        org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
        for (int i = 0; i < size; i++) {
            value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
        }
        info.setBrokerPath(value);
    } else {
        info.setBrokerPath(null);
    }
    info
        .setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression)looseUnmarsalNestedObject(
                                                                                                        wireFormat,
                                                                                                        dataIn));
    info.setNetworkSubscription(dataIn.readBoolean());
    info.setOptimizedAcknowledge(dataIn.readBoolean());
    info.setNoRangeAcks(dataIn.readBoolean());

}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:48,代码来源:ConsumerInfoMarshaller.java

示例15: testQueueOnlyOnceDeliveryWith2Consumers

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testQueueOnlyOnceDeliveryWith2Consumers() throws Exception {

      ActiveMQDestination destination = new ActiveMQQueue("TEST");

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo);

      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
      consumerInfo1.setPrefetchSize(1);
      connection1.request(consumerInfo1);

      // Setup a second connection
      StubConnection connection2 = createConnection();
      ConnectionInfo connectionInfo2 = createConnectionInfo();
      SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
      ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
      consumerInfo2.setPrefetchSize(1);
      connection2.send(connectionInfo2);
      connection2.send(sessionInfo2);
      connection2.request(consumerInfo2);

      // Send the messages
      connection1.send(createMessage(producerInfo, destination, deliveryMode));
      connection1.send(createMessage(producerInfo, destination, deliveryMode));
      connection1.send(createMessage(producerInfo, destination, deliveryMode));
      connection1.request(createMessage(producerInfo, destination, deliveryMode));

      for (int i = 0; i < 2; i++) {
         Message m1 = receiveMessage(connection1);
         Message m2 = receiveMessage(connection2);

         assertNotNull("m1 is null for index: " + i, m1);
         assertNotNull("m2 is null for index: " + i, m2);

         assertNotSame(m1.getMessageId(), m2.getMessageId());
         connection1.send(createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE));
         connection2.send(createAck(consumerInfo2, m2, 1, MessageAck.STANDARD_ACK_TYPE));
      }

      assertNoMessagesLeft(connection1);
      assertNoMessagesLeft(connection2);
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:49,代码来源:BrokerTest.java


注:本文中的org.apache.activemq.command.ConsumerInfo.setPrefetchSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。