本文整理汇总了Java中javax.jms.JMSConsumer类的典型用法代码示例。如果您正苦于以下问题:Java JMSConsumer类的具体用法?Java JMSConsumer怎么用?Java JMSConsumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JMSConsumer类属于javax.jms包,在下文中一共展示了JMSConsumer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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());
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例10: startIfNeeded
import javax.jms.JMSConsumer; //导入依赖的package包/类
private JMSConsumer startIfNeeded(JMSConsumer consumer) throws JMSException {
if (getAutoStart()) {
connection.start();
}
return consumer;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例15: testCloseMoreThanOnce
import javax.jms.JMSConsumer; //导入依赖的package包/类
@Test
public void testCloseMoreThanOnce() throws JMSException {
JMSConsumer consumer = context.createConsumer(context.createTemporaryQueue());
consumer.close();
consumer.close();
}