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


Java ConsumerInfo.setExclusive方法代码示例

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


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

示例1: 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

示例2: populateObject

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
protected void populateObject(Object object) throws Exception {
   super.populateObject(object);
   ConsumerInfo info = (ConsumerInfo) object;
   info.setConsumerId(createConsumerId("ConsumerId:1"));
   info.setBrowser(true);
   info.setDestination(createActiveMQDestination("Destination:2"));
   info.setPrefetchSize(1);
   info.setMaximumPendingMessageLimit(2);
   info.setDispatchAsync(false);
   info.setSelector("Selector:3");
   info.setSubscriptionName("SubcriptionName:4");
   info.setNoLocal(true);
   info.setExclusive(false);
   info.setRetroactive(true);
   info.setPriority((byte) 1);

   {
      BrokerId value[] = new BrokerId[2];
      for (int i = 0; i < 2; i++) {
         value[i] = createBrokerId("BrokerPath:5");
      }
      info.setBrokerPath(value);
   }
   info.setAdditionalPredicate(createBooleanExpression("AdditionalPredicate:6"));
   info.setNetworkSubscription(false);
   info.setOptimizedAcknowledge(true);
   info.setNoRangeAcks(false);

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

示例3: populateObject

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Override
protected void populateObject(Object object) throws Exception {
   super.populateObject(object);
   ConsumerInfo info = (ConsumerInfo) object;

   info.setConsumerId(createConsumerId("ConsumerId:1"));
   info.setBrowser(true);
   info.setDestination(createActiveMQDestination("Destination:2"));
   info.setPrefetchSize(1);
   info.setMaximumPendingMessageLimit(2);
   info.setDispatchAsync(false);
   info.setSelector("Selector:3");
   info.setSubscriptionName("SubscriptionName:4");
   info.setNoLocal(true);
   info.setExclusive(false);
   info.setRetroactive(true);
   info.setPriority((byte) 1);
   {
      BrokerId value[] = new BrokerId[2];
      for (int i = 0; i < 2; i++) {
         value[i] = createBrokerId("BrokerPath:5");
      }
      info.setBrokerPath(value);
   }
   info.setAdditionalPredicate(createBooleanExpression("AdditionalPredicate:6"));
   info.setNetworkSubscription(false);
   info.setOptimizedAcknowledge(true);
   info.setNoRangeAcks(false);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:30,代码来源:ConsumerInfoTest.java

示例4: tightUnmarshal

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 tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs)
    throws IOException {
    super.tightUnmarshal(wireFormat, o, dataIn, bs);

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

    if (bs.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)tightUnmarsalNestedObject(wireFormat,
                                                                                       dataIn, bs);
        }
        info.setBrokerPath(value);
    } else {
        info.setBrokerPath(null);
    }
    info
        .setAdditionalPredicate((org.apache.activemq.filter.BooleanExpression)tightUnmarsalNestedObject(
                                                                                                        wireFormat,
                                                                                                        dataIn,
                                                                                                        bs));
    info.setNetworkSubscription(bs.readBoolean());
    info.setOptimizedAcknowledge(bs.readBoolean());
    info.setNoRangeAcks(bs.readBoolean());

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

示例5: 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

示例6: testNoDuplicateAfterCacheFullAndReadPast

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
public void testNoDuplicateAfterCacheFullAndReadPast() throws Exception {
   final PersistenceAdapter persistenceAdapter = brokerService.getPersistenceAdapter();
   final MessageStore queueMessageStore = persistenceAdapter.createQueueMessageStore(destination);
   final ConsumerInfo consumerInfo = new ConsumerInfo();
   final DestinationStatistics destinationStatistics = new DestinationStatistics();
   consumerInfo.setExclusive(true);

   final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);

   queueMessageStore.start();
   queueMessageStore.registerIndexListener(null);

   QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
   SystemUsage systemUsage = new SystemUsage();
   // ensure memory limit is reached
   systemUsage.getMemoryUsage().setLimit(messageBytesSize * (count + 2));
   underTest.setSystemUsage(systemUsage);
   underTest.setEnableAudit(false);
   underTest.start();
   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   final ConnectionContext contextNotInTx = new ConnectionContext();
   for (int i = 0; i < count; i++) {
      ActiveMQTextMessage msg = getMessage(i);
      msg.setMemoryUsage(systemUsage.getMemoryUsage());

      queueMessageStore.addMessage(contextNotInTx, msg);
      underTest.addMessageLast(msg);
   }

   assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
   int dequeueCount = 0;

   underTest.setMaxBatchSize(2);
   underTest.reset();
   while (underTest.hasNext() && dequeueCount < count) {
      MessageReference ref = underTest.next();
      ref.decrementReferenceCount();
      underTest.remove();
      LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
      assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
   }
   underTest.release();
   assertEquals(count, dequeueCount);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:46,代码来源:StoreQueueCursorNoDuplicateTest.java

示例7: tesBlockedFuture

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Test
public void tesBlockedFuture() throws Exception {
   final int count = 2;
   final Message[] messages = new Message[count];
   final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
   final ConsumerInfo consumerInfo = new ConsumerInfo();
   final DestinationStatistics destinationStatistics = new DestinationStatistics();
   consumerInfo.setExclusive(true);

   final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);

   queueMessageStore.start();
   queueMessageStore.registerIndexListener(null);

   QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
   SystemUsage systemUsage = new SystemUsage();
   // ensure memory limit is reached
   systemUsage.getMemoryUsage().setLimit(messageBytesSize * 1);
   underTest.setSystemUsage(systemUsage);
   underTest.setEnableAudit(false);
   underTest.start();
   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   ActiveMQTextMessage msg = getMessage(0);
   messages[1] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.setRecievedByDFBridge(true);
   FutureTask<Long> future = new FutureTask<Long>(new Runnable() {
      @Override
      public void run() {
      }
   }, 2L) {
   };
   msg.getMessageId().setFutureOrSequenceLong(future);
   underTest.addMessageLast(msg);

   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   // second message will flip the cache but will be stored before the future task
   msg = getMessage(1);
   messages[0] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.getMessageId().setFutureOrSequenceLong(1L);
   underTest.addMessageLast(msg);

   assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
   assertEquals("setBatch unset", 0L, queueMessageStore.batch.get());

   int dequeueCount = 0;

   underTest.setMaxBatchSize(2);
   underTest.reset();
   while (underTest.hasNext() && dequeueCount < count) {
      MessageReference ref = underTest.next();
      ref.decrementReferenceCount();
      underTest.remove();
      LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
      assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
   }
   underTest.release();
   assertEquals(count, dequeueCount);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:63,代码来源:StoreQueueCursorOrderTest.java

示例8: testNoSetBatchWithUnOrderedFutureCurrentSync

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Test
public void testNoSetBatchWithUnOrderedFutureCurrentSync() throws Exception {
   final int count = 2;
   final Message[] messages = new Message[count];
   final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
   final ConsumerInfo consumerInfo = new ConsumerInfo();
   final DestinationStatistics destinationStatistics = new DestinationStatistics();
   consumerInfo.setExclusive(true);

   final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);

   queueMessageStore.start();
   queueMessageStore.registerIndexListener(null);

   QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
   SystemUsage systemUsage = new SystemUsage();
   // ensure memory limit is reached
   systemUsage.getMemoryUsage().setLimit(messageBytesSize * 1);
   underTest.setSystemUsage(systemUsage);
   underTest.setEnableAudit(false);
   underTest.start();
   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   ActiveMQTextMessage msg = getMessage(0);
   messages[1] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.setRecievedByDFBridge(true);
   final ActiveMQTextMessage msgRef = msg;
   FutureTask<Long> future = new FutureTask<Long>(new Runnable() {
      @Override
      public void run() {
         msgRef.getMessageId().setFutureOrSequenceLong(1L);
      }
   }, 1L) {
   };
   msg.getMessageId().setFutureOrSequenceLong(future);
   Executors.newSingleThreadExecutor().submit(future);
   underTest.addMessageLast(msg);

   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   // second message will flip the cache but will be stored before the future task
   msg = getMessage(1);
   messages[0] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.getMessageId().setFutureOrSequenceLong(1L);
   underTest.addMessageLast(msg);

   assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
   assertEquals("setBatch unset", 0L, queueMessageStore.batch.get());

   int dequeueCount = 0;

   underTest.setMaxBatchSize(2);
   underTest.reset();
   while (underTest.hasNext() && dequeueCount < count) {
      MessageReference ref = underTest.next();
      ref.decrementReferenceCount();
      underTest.remove();
      LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
      assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
   }
   underTest.release();
   assertEquals(count, dequeueCount);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:66,代码来源:StoreQueueCursorOrderTest.java

示例9: testSetBatchWithOrderedFutureCurrentFuture

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Test
public void testSetBatchWithOrderedFutureCurrentFuture() throws Exception {
   final int count = 2;
   final Message[] messages = new Message[count];
   final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
   final ConsumerInfo consumerInfo = new ConsumerInfo();
   final DestinationStatistics destinationStatistics = new DestinationStatistics();
   consumerInfo.setExclusive(true);

   final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);

   queueMessageStore.start();
   queueMessageStore.registerIndexListener(null);

   QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
   SystemUsage systemUsage = new SystemUsage();
   // ensure memory limit is reached
   systemUsage.getMemoryUsage().setLimit(messageBytesSize * 1);
   underTest.setSystemUsage(systemUsage);
   underTest.setEnableAudit(false);
   underTest.start();
   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   ActiveMQTextMessage msg = getMessage(0);
   messages[0] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.setRecievedByDFBridge(true);
   final ActiveMQTextMessage msgRef = msg;
   FutureTask<Long> future = new FutureTask<Long>(new Runnable() {
      @Override
      public void run() {
         msgRef.getMessageId().setFutureOrSequenceLong(0L);
      }
   }, 0L) {
   };
   msg.getMessageId().setFutureOrSequenceLong(future);
   Executors.newSingleThreadExecutor().submit(future);
   underTest.addMessageLast(msg);

   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   // second message will flip the cache but will be stored before the future task
   msg = getMessage(1);
   messages[1] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.setRecievedByDFBridge(true);
   final ActiveMQTextMessage msgRe2f = msg;
   FutureTask<Long> future2 = new FutureTask<Long>(new Runnable() {
      @Override
      public void run() {
         msgRe2f.getMessageId().setFutureOrSequenceLong(1L);
      }
   }, 1L) {
   };
   msg.getMessageId().setFutureOrSequenceLong(future2);
   Executors.newSingleThreadExecutor().submit(future2);
   underTest.addMessageLast(msg);

   assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
   assertEquals("setBatch set", 1L, queueMessageStore.batch.get());

   int dequeueCount = 0;

   underTest.setMaxBatchSize(2);
   underTest.reset();
   while (underTest.hasNext() && dequeueCount < count) {
      MessageReference ref = underTest.next();
      ref.decrementReferenceCount();
      underTest.remove();
      LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
      assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
   }
   underTest.release();
   assertEquals(count, dequeueCount);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:76,代码来源:StoreQueueCursorOrderTest.java

示例10: testSetBatch

import org.apache.activemq.command.ConsumerInfo; //导入方法依赖的package包/类
@Test
public void testSetBatch() throws Exception {
   final int count = 3;
   final Message[] messages = new Message[count];
   final TestMessageStore queueMessageStore = new TestMessageStore(messages, destination);
   final ConsumerInfo consumerInfo = new ConsumerInfo();
   final DestinationStatistics destinationStatistics = new DestinationStatistics();
   consumerInfo.setExclusive(true);

   final Queue queue = new Queue(brokerService, destination, queueMessageStore, destinationStatistics, null);

   queueMessageStore.start();
   queueMessageStore.registerIndexListener(null);

   QueueStorePrefetch underTest = new QueueStorePrefetch(queue, brokerService.getBroker());
   SystemUsage systemUsage = new SystemUsage();
   // ensure memory limit is reached
   systemUsage.getMemoryUsage().setLimit(messageBytesSize * 5);
   underTest.setSystemUsage(systemUsage);
   underTest.setEnableAudit(false);
   underTest.start();
   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   ActiveMQTextMessage msg = getMessage(0);
   messages[0] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.getMessageId().setFutureOrSequenceLong(0L);
   underTest.addMessageLast(msg);

   msg = getMessage(1);
   messages[1] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.getMessageId().setFutureOrSequenceLong(1L);
   underTest.addMessageLast(msg);

   assertTrue("cache enabled", underTest.isUseCache() && underTest.isCacheEnabled());

   msg = getMessage(2);
   messages[2] = msg;
   msg.setMemoryUsage(systemUsage.getMemoryUsage());
   msg.getMessageId().setFutureOrSequenceLong(2L);
   underTest.addMessageLast(msg);

   assertTrue("cache is disabled as limit reached", !underTest.isCacheEnabled());
   assertEquals("setBatch set", 2L, queueMessageStore.batch.get());

   int dequeueCount = 0;

   underTest.setMaxBatchSize(2);
   underTest.reset();
   while (underTest.hasNext() && dequeueCount < count) {
      MessageReference ref = underTest.next();
      ref.decrementReferenceCount();
      underTest.remove();
      LOG.info("Received message: {} with body: {}", ref.getMessageId(), ((ActiveMQTextMessage) ref.getMessage()).getText());
      assertEquals(dequeueCount++, ref.getMessageId().getProducerSequenceId());
   }
   underTest.release();
   assertEquals(count, dequeueCount);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:61,代码来源:StoreQueueCursorOrderTest.java


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