Java Code Examples for javax.jms.JMSProducer#setAsync()
The following examples show how to use
javax.jms.JMSProducer#setAsync() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmsContextTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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()); }
Example 2
Source File: JmsContextTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test public void bytesMessage() throws Exception { context = cf.createContext(); try { JMSProducer producer = context.createProducer(); BytesMessage bMsg = context.createBytesMessage(); bMsg.setStringProperty("COM_SUN_JMS_TESTNAME", "sendAndRecvMsgOfEachTypeCLTest"); bMsg.writeByte((byte) 1); bMsg.writeInt(22); CountDownLatch latch = new CountDownLatch(1); SimpleCompletionListener listener = new SimpleCompletionListener(latch); producer.setAsync(listener); producer.send(queue1, bMsg); assertTrue(latch.await(5, TimeUnit.SECONDS)); assertEquals(listener.message.readByte(), (byte) 1); assertEquals(listener.message.readInt(), 22); } finally { context.close(); } }
Example 3
Source File: JmsPoolJMSProducerTest.java From pooled-jms with Apache License 2.0 | 5 votes |
@Test public void testAsync() { JMSProducer producer = context.createProducer(); TestJmsCompletionListener listener = new TestJmsCompletionListener(); producer.setAsync(listener); assertEquals(listener, producer.getAsync()); }
Example 4
Source File: JmsContextTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void illegalStateRuntimeExceptionTests() throws Exception { JMSProducer producer = context.createProducer(); JMSConsumer consumer = context.createConsumer(queue1); TextMessage expTextMessage = context.createTextMessage("Call commit"); CountDownLatch latch = new CountDownLatch(1); JMSCOntextStopCompletionListener listener = new JMSCOntextStopCompletionListener(context, latch); producer.setAsync(listener); producer.send(queue1, expTextMessage); assertTrue(latch.await(5, TimeUnit.SECONDS)); assertNull(listener.ex); }
Example 5
Source File: JmsProducerTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testAsync() { JMSProducer producer = context.createProducer(); TestJmsCompletionListener listener = new TestJmsCompletionListener(); producer.setAsync(listener); assertEquals(listener, producer.getAsync()); }