本文整理汇总了Java中javax.jms.JMSConsumer类的典型用法代码示例。如果您正苦于以下问题:Java JMSConsumer类的具体用法?Java JMSConsumer怎么用?Java JMSConsumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JMSConsumer类属于javax.jms包,在下文中一共展示了JMSConsumer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: connectInternal
import javax.jms.JMSConsumer; //导入依赖的package包/类
private void connectInternal(Runnable command) {
final JMSContext jmsCtx = mock(JMSContext.class);
when(this.jmsCtxProvider.get()).thenReturn(jmsCtx);
when(this.artemisConfig.getManagementNotificationAddress()).thenReturn(new SimpleString("notif"));
final JMSConsumer consumer = mock(JMSConsumer.class);
when(jmsCtx.createConsumer(any())).thenReturn(consumer);
command.run();
verify(this.jmsCtxProvider).get();
verify(this.artemisConfig).getManagementNotificationAddress();
verify(this.log).info("Connecting to broker for sourcing destination events.");
verify(jmsCtx).createConsumer(any());
verify(consumer).setMessageListener(this.eventProducer);
verifyNoMoreInteractions(consumer);
}
开发者ID:dansiviter,项目名称:cito,代码行数:18,代码来源:EventProducerTest.java
示例2: testSendStreamMessage
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testSendStreamMessage() throws JMSException, InterruptedException {
JmsProducerCompletionListenerTest.CountingCompletionListener cl = new JmsProducerCompletionListenerTest.CountingCompletionListener(1);
JMSProducer producer = context.createProducer();
producer.setAsync(cl);
StreamMessage msg = context.createStreamMessage();
msg.setStringProperty("name", name.getMethodName());
String bprop = "booleanProp";
String iprop = "intProp";
msg.setBooleanProperty(bprop, true);
msg.setIntProperty(iprop, 42);
msg.writeBoolean(true);
msg.writeInt(67);
producer.send(queue1, msg);
JMSConsumer consumer = context.createConsumer(queue1);
Message msg2 = consumer.receive(100);
Assert.assertNotNull(msg2);
Assert.assertTrue(cl.completionLatch.await(1, TimeUnit.SECONDS));
StreamMessage sm = (StreamMessage) cl.lastMessage;
Assert.assertEquals(true, sm.getBooleanProperty(bprop));
Assert.assertEquals(42, sm.getIntProperty(iprop));
Assert.assertEquals(true, sm.readBoolean());
Assert.assertEquals(67, sm.readInt());
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:JmsContextTest.java
示例3: sharedDurableSubSimpleRoundRobin
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void sharedDurableSubSimpleRoundRobin() throws Exception {
context = cf.createContext();
try {
JMSConsumer con1 = context.createSharedDurableConsumer(topic1, "mySharedCon");
JMSConsumer con2 = context.createSharedDurableConsumer(topic1, "mySharedCon");
context.start();
JMSProducer producer = context.createProducer();
int numMessages = 10;
for (int i = 0; i < numMessages; i++) {
producer.send(topic1, "msg:" + i);
}
for (int i = 0; i < numMessages; i += 2) {
String msg = con1.receiveBody(String.class, 5000);
System.out.println("msg = " + msg);
msg = con2.receiveBody(String.class, 5000);
System.out.println("msg = " + msg);
}
} finally {
context.close();
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:SharedConsumerTest.java
示例4: sharedNonDurableUnsubscribeDifferentTopic
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void sharedNonDurableUnsubscribeDifferentTopic() throws Exception {
context = cf.createContext();
try {
JMSConsumer con1 = context.createSharedConsumer(topic1, "mySharedCon");
JMSConsumer con2 = context.createSharedConsumer(topic1, "mySharedCon");
con1.close();
Binding binding = server.getPostOffice().getBinding(new SimpleString("nonDurable.mySharedCon"));
assertNotNull(binding);
con2.close();
binding = server.getPostOffice().getBinding(new SimpleString("nonDurable.mySharedCon"));
assertNull(binding);
con1 = context.createSharedConsumer(topic2, "mySharedCon");
} finally {
context.close();
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:SharedConsumerTest.java
示例5: testCreateConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test(timeout = 20000)
public void testCreateConsumer() throws Exception {
try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
JMSContext context = testFixture.createJMSContext(testPeer);
testPeer.expectBegin();
testPeer.expectReceiverAttach();
testPeer.expectLinkFlow();
Queue queue = context.createQueue("test");
JMSConsumer consumer = context.createConsumer(queue);
assertNotNull(consumer);
testPeer.expectEnd();
testPeer.expectClose();
context.close();
testPeer.waitForAllHandlersToComplete(1000);
}
}
开发者ID:apache,项目名称:qpid-jms,代码行数:20,代码来源:JMSConsumerIntegrationTest.java
示例6: createConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createConsumer(Destination destination) {
try {
return startIfNeeded(new JmsPoolJMSConsumer((JmsPoolMessageConsumer) getSession().createConsumer(destination)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:JmsPoolJMSContext.java
示例7: createDurableConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createDurableConsumer(Topic topic, String name) {
try {
return startIfNeeded(new JmsPoolJMSConsumer((JmsPoolMessageConsumer) getSession().createDurableConsumer(topic, name)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:JmsPoolJMSContext.java
示例8: createSharedConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createSharedConsumer(Topic topic, String name) {
try {
return startIfNeeded(new JmsPoolJMSConsumer((JmsPoolMessageConsumer) getSession().createSharedConsumer(topic, name)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:JmsPoolJMSContext.java
示例9: createSharedDurableConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createSharedDurableConsumer(Topic topic, String name) {
try {
return startIfNeeded(new JmsPoolJMSConsumer((JmsPoolMessageConsumer) getSession().createSharedDurableConsumer(topic, name)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:JmsPoolJMSContext.java
示例10: startIfNeeded
import javax.jms.JMSConsumer; //导入依赖的package包/类
private JMSConsumer startIfNeeded(JMSConsumer consumer) throws JMSException {
if (getAutoStart()) {
connection.start();
}
return consumer;
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:8,代码来源:JmsPoolJMSContext.java
示例11: createConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createConsumer(Destination destination) {
try {
return startIfNeeded(new MockJMSConsumer(getSession(), (MockJMSMessageConsumer) getSession().createConsumer(destination)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:MockJMSContext.java
示例12: createDurableConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createDurableConsumer(Topic topic, String name) {
try {
return startIfNeeded(new MockJMSConsumer(getSession(), (MockJMSMessageConsumer) getSession().createDurableConsumer(topic, name)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:MockJMSContext.java
示例13: createSharedConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createSharedConsumer(Topic topic, String name) {
try {
return startIfNeeded(new MockJMSConsumer(getSession(), (MockJMSMessageConsumer) getSession().createSharedConsumer(topic, name)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:MockJMSContext.java
示例14: createSharedDurableConsumer
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Override
public JMSConsumer createSharedDurableConsumer(Topic topic, String name) {
try {
return startIfNeeded(new MockJMSConsumer(getSession(), (MockJMSMessageConsumer) getSession().createSharedDurableConsumer(topic, name)));
} catch (JMSException jmse) {
throw JMSExceptionSupport.createRuntimeException(jmse);
}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:9,代码来源:MockJMSContext.java
示例15: testCloseMoreThanOnce
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testCloseMoreThanOnce() throws JMSException {
JMSConsumer consumer = context.createConsumer(context.createTemporaryQueue());
consumer.close();
consumer.close();
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:8,代码来源:JmsPoolJMSConsumerTest.java
示例16: testReceive
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testReceive() throws JMSException {
JMSConsumer consumer = context.createConsumer(context.createTemporaryQueue());
assertNull(consumer.receive());
consumer.close();
try {
consumer.receive();
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateRuntimeException ise) {}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:14,代码来源:JmsPoolJMSConsumerTest.java
示例17: testReceiveNoWait
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testReceiveNoWait() throws JMSException {
JMSConsumer consumer = context.createConsumer(context.createTemporaryQueue());
assertNull(consumer.receiveNoWait());
consumer.close();
try {
consumer.receiveNoWait();
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateRuntimeException ise) {}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:14,代码来源:JmsPoolJMSConsumerTest.java
示例18: testReceiveTimed
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testReceiveTimed() throws JMSException {
JMSConsumer consumer = context.createConsumer(context.createTemporaryQueue());
assertNull(consumer.receive(1));
consumer.close();
try {
consumer.receive(1);
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateRuntimeException ise) {}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:14,代码来源:JmsPoolJMSConsumerTest.java
示例19: testGetMessageSelector
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testGetMessageSelector() throws JMSException {
JMSConsumer consumer = context.createConsumer(context.createTemporaryQueue(), "Color = Red");
assertNotNull(consumer.getMessageSelector());
assertEquals("Color = Red", consumer.getMessageSelector());
consumer.close();
try {
consumer.getMessageSelector();
fail("Should not be able to interact with closed consumer");
} catch (IllegalStateRuntimeException ise) {}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:15,代码来源:JmsPoolJMSConsumerTest.java
示例20: testReceiveBody
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testReceiveBody() throws JMSException {
JMSConsumer consumer = context.createConsumer(context.createTemporaryQueue());
try {
consumer.receiveBody(String.class);
fail("Should not be able to interact with closed consumer");
} catch (JMSRuntimeException ise) {}
}
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:10,代码来源:JmsPoolJMSConsumerTest.java
注:本文中的javax.jms.JMSConsumer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论