Java Code Examples for javax.jms.TextMessage#clearBody()
The following examples show how to use
javax.jms.TextMessage#clearBody() .
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: QueueBridgeTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void onMessage(Message msg) { try { TextMessage textMsg = (TextMessage) msg; String payload = "REPLY: " + textMsg.getText(); Destination replyTo; replyTo = msg.getJMSReplyTo(); textMsg.clearBody(); textMsg.setText(payload); requestServerProducer.send(replyTo, textMsg); } catch (JMSException e) { e.printStackTrace(); } }
Example 2
Source File: TopicBridgeSpringTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void onMessage(Message msg) { try { TextMessage textMsg = (TextMessage) msg; String payload = "REPLY: " + textMsg.getText(); Destination replyTo; replyTo = msg.getJMSReplyTo(); textMsg.clearBody(); textMsg.setText(payload); LOG.info("Sending response: " + textMsg); requestServerProducer.send(replyTo, textMsg); } catch (JMSException e) { e.printStackTrace(); } }
Example 3
Source File: MessageBodyTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * Test that the <code>TextMessage.clearBody()</code> method does not clear the * message properties. */ @Test public void testClearBody_2() { try { TextMessage message = senderSession.createTextMessage(); message.setStringProperty("prop", "foo"); message.clearBody(); Assert.assertEquals("sec. 3.11.1 Clearing a message's body does not clear its property entries.\n", "foo", message.getStringProperty("prop")); } catch (JMSException e) { fail(e); } }
Example 4
Source File: MessageBodyTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * Test that the <code>TextMessage.clearBody()</code> effectively clear the body of the message */ @Test public void testClearBody_1() { try { TextMessage message = senderSession.createTextMessage(); message.setText("bar"); message.clearBody(); Assert.assertEquals("sec. 3 .11.1 the clearBody method of Message resets the value of the message body " + "to the 'empty' initial message value as set by the message type's create " + "method provided by Session.\n", null, message.getText()); } catch (JMSException e) { fail(e); } }