Java Code Examples for org.apache.activemq.command.ActiveMQTextMessage#setText()
The following examples show how to use
org.apache.activemq.command.ActiveMQTextMessage#setText() .
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: DummyMessageQuery.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override public void execute(ActiveMQDestination destination, MessageListener listener) throws Exception { LOG.info("Initial query is creating: " + MESSAGE_COUNT + " messages"); for (int i = 0; i < MESSAGE_COUNT; i++) { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setText("Initial message: " + i + " loaded from query"); listener.onMessage(message); } }
Example 2
Source File: NumberRangesWhileMarshallingTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
public void testMaxFrameSize() throws Exception { OpenWireFormat wf = new OpenWireFormat(); wf.setMaxFrameSize(10); ActiveMQTextMessage msg = new ActiveMQTextMessage(); msg.setText("This is a test"); writeObject(msg); ds.writeInt(endOfStreamMarker); // now lets read from the stream ds.close(); ByteArrayInputStream in = new ByteArrayInputStream(buffer.toByteArray()); DataInputStream dis = new DataInputStream(in); try { wf.unmarshal(dis); } catch (IOException ioe) { return; } fail("Should fail because of the large frame size"); }
Example 3
Source File: QueueDuplicatesFromStoreTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private Message getMessage(int i) throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setMessageId(new MessageId(mesageIdRoot + i)); message.setDestination(destination); message.setPersistent(true); message.setResponseRequired(true); message.setText("Msg:" + i + " " + text); assertEquals(message.getMessageId().getProducerSequenceId(), i); return message; }
Example 4
Source File: JmsCollectorTest.java From karaf-decanter with Apache License 2.0 | 5 votes |
@Test public void test() throws Exception { Connection connection = null; Session session = null; try { connection = connectionFactory.createConnection(); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(session.createQueue("decanter")); ActiveMQMapMessage mapMessage = new ActiveMQMapMessage(); mapMessage.setString("message", "map"); producer.send(mapMessage); Thread.sleep(200L); Assert.assertEquals(1, dispatcher.getPostEvents().size()); Event event = dispatcher.getPostEvents().get(0); Assert.assertEquals("map", event.getProperty("message")); Assert.assertEquals("jms", event.getProperty("type")); ActiveMQTextMessage textMessage = new ActiveMQTextMessage(); textMessage.setText("{ \"message\" : \"text\" }"); producer.send(textMessage); Thread.sleep(200L); Assert.assertEquals(2, dispatcher.getPostEvents().size()); event = dispatcher.getPostEvents().get(1); Assert.assertEquals("text", event.getProperty("message")); Assert.assertEquals("jms", event.getProperty("type")); } finally { if (session != null) { session.close(); } if (connection != null) { connection.close(); } } }
Example 5
Source File: FailoverTransportBrokerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator)); message.setDestination(destination); message.setPersistent(false); try { message.setText("Test Message Payload."); } catch (MessageNotWriteableException e) { } return message; }
Example 6
Source File: FanoutTransportBrokerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator)); message.setDestination(destination); message.setPersistent(false); try { message.setText("Test Message Payload."); } catch (MessageNotWriteableException e) { } return message; }
Example 7
Source File: UdpTestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void assertSendTextMessage(ActiveMQDestination destination, String text) throws MessageNotWriteableException { large = true; ActiveMQTextMessage expected = new ActiveMQTextMessage(); expected.setText(text); expected.setDestination(destination); try { LOG.info("About to send message of type: " + expected.getClass()); producer.oneway(expected); // lets send a dummy command to ensure things don't block if we // discard the last one // keepalive does not have a commandId... // producer.oneway(new KeepAliveInfo()); producer.oneway(new ProducerInfo()); producer.oneway(new ProducerInfo()); Command received = assertCommandReceived(); assertTrue("Should have received an ActiveMQTextMessage but was: " + received, received instanceof ActiveMQTextMessage); ActiveMQTextMessage actual = (ActiveMQTextMessage) received; assertEquals("getDestination", expected.getDestination(), actual.getDestination()); assertEquals("getText", expected.getText(), actual.getText()); LOG.info("Received text message with: " + actual.getText().length() + " character(s)"); } catch (Exception e) { LOG.info("Caught: " + e); e.printStackTrace(); fail("Failed to send to transport: " + e); } }
Example 8
Source File: BrokerTestSupport.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator)); message.setDestination(destination); message.setPersistent(false); try { message.setText("Test Message Payload."); } catch (MessageNotWriteableException e) { } return message; }
Example 9
Source File: StoreQueueCursorOrderTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private ActiveMQTextMessage getMessage(int i) throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); MessageId id = new MessageId(mesageIdRoot + i); id.setBrokerSequenceId(i); id.setProducerSequenceId(i); message.setMessageId(id); message.setDestination(destination); message.setPersistent(true); message.setResponseRequired(true); message.setText("Msg:" + i + " " + text); assertEquals(message.getMessageId().getProducerSequenceId(), i); return message; }
Example 10
Source File: StoreQueueCursorNoDuplicateTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private ActiveMQTextMessage getMessage(int i) throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); MessageId id = new MessageId(mesageIdRoot + i); id.setBrokerSequenceId(i); id.setProducerSequenceId(i); message.setMessageId(id); message.setDestination(destination); message.setPersistent(true); message.setResponseRequired(true); message.setText("Msg:" + i + " " + text); assertEquals(message.getMessageId().getProducerSequenceId(), i); return message; }
Example 11
Source File: QueueOptimizedDispatchExceptionTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private Message getMessage(int i) throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setMessageId(new MessageId(mesageIdRoot + i)); message.setDestination(destination); message.setPersistent(false); message.setResponseRequired(true); message.setText("Msg:" + i + " " + text); assertEquals(message.getMessageId().getProducerSequenceId(), i); return message; }
Example 12
Source File: BrokerNetworkWithStuckMessagesTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination) { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setMessageId(new MessageId(producerInfo, ++msgIdGenerator)); message.setDestination(destination); message.setPersistent(false); try { message.setText("Test Message Payload."); } catch (MessageNotWriteableException e) { } return message; }
Example 13
Source File: ActiveMQXAConnectionFactoryTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
public void testCloseSendConnection() throws Exception { String brokerName = "closeSend"; BrokerService broker = BrokerFactory.createBroker(new URI("broker:(tcp://localhost:0)/" + brokerName)); broker.start(); broker.waitUntilStarted(); ActiveMQXAConnectionFactory cf = new ActiveMQXAConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri()); XAConnection connection = (XAConnection) cf.createConnection(); connection.start(); XASession session = connection.createXASession(); XAResource resource = session.getXAResource(); Destination dest = new ActiveMQQueue(getName()); // publish a message Xid tid = createXid(); resource.start(tid, XAResource.TMNOFLAGS); MessageProducer producer = session.createProducer(dest); ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setText(getName()); producer.send(message); connection.close(); //comment out this check as it doesn't apply to artemis //assertTransactionGoneFromBroker(tid); broker.stop(); }
Example 14
Source File: ActiveMQXAConnectionFactoryTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void testConsumerCloseTransactionalSendReceive() throws Exception { ActiveMQXAConnectionFactory cf1 = new ActiveMQXAConnectionFactory("vm://localhost?broker.persistent=false"); XAConnection connection1 = (XAConnection) cf1.createConnection(); connection1.start(); XASession session = connection1.createXASession(); XAResource resource = session.getXAResource(); Destination dest = new ActiveMQQueue(getName()); // publish a message Xid tid = createXid(); resource.start(tid, XAResource.TMNOFLAGS); MessageProducer producer = session.createProducer(dest); ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setText(getName()); producer.send(message); producer.close(); resource.end(tid, XAResource.TMSUCCESS); resource.commit(tid, true); session.close(); session = connection1.createXASession(); MessageConsumer consumer = session.createConsumer(dest); tid = createXid(); resource = session.getXAResource(); resource.start(tid, XAResource.TMNOFLAGS); TextMessage receivedMessage = (TextMessage) consumer.receive(1000); consumer.close(); assertNotNull(receivedMessage); assertEquals(getName(), receivedMessage.getText()); resource.end(tid, XAResource.TMSUCCESS); resource.commit(tid, true); session = connection1.createXASession(); consumer = session.createConsumer(dest); tid = createXid(); resource = session.getXAResource(); resource.start(tid, XAResource.TMNOFLAGS); assertNull(consumer.receive(1000)); resource.end(tid, XAResource.TMSUCCESS); resource.commit(tid, true); }
Example 15
Source File: SelectorTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void testXPathSelectors() throws Exception { ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setJMSType("xml"); message.setText("<root><a key='first' num='1'/><b key='second' num='2'>b</b></root>"); assertSelector(message, "XPATH 'root/a'", true); assertSelector(message, "XPATH '//root/b'", true); assertSelector(message, "XPATH 'root/c'", false); assertSelector(message, "XPATH '//root/b/text()=\"b\"'", true); assertSelector(message, "XPATH '//root/b=\"b\"'", true); assertSelector(message, "XPATH '//root/b=\"c\"'", false); assertSelector(message, "XPATH '//root/b!=\"c\"'", true); assertSelector(message, "XPATH '//root/*[@key=''second'']'", true); assertSelector(message, "XPATH '//root/*[@key=''third'']'", false); assertSelector(message, "XPATH '//root/a[@key=''first'']'", true); assertSelector(message, "XPATH '//root/a[@num=1]'", true); assertSelector(message, "XPATH '//root/a[@key=''second'']'", false); assertSelector(message, "XPATH '/root/*[@key=''first'' or @key=''third'']'", true); assertSelector(message, "XPATH '//root/*[@key=''third'' or @key=''forth'']'", false); assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''second'']'", true); assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''first'']'", false); assertSelector(message, "XPATH 'not(//root/a)'", false); assertSelector(message, "XPATH 'not(//root/c)'", true); assertSelector(message, "XPATH '//root/a[not(@key=''first'')]'", false); assertSelector(message, "XPATH '//root/a[not(not(@key=''first''))]'", true); assertSelector(message, "XPATH 'string(//root/b)'", true); assertSelector(message, "XPATH 'string(//root/a)'", false); assertSelector(message, "XPATH 'sum(//@num) < 10'", true); assertSelector(message, "XPATH 'sum(//@num) > 10'", false); assertSelector(message, "XPATH '//root/a[@num > 1]'", false); assertSelector(message, "XPATH '//root/b[@num > 1]'", true); }
Example 16
Source File: DataFileGeneratorTestSupport.java From activemq-artemis with Apache License 2.0 | 4 votes |
protected Message createMessage(String string) throws Exception { ActiveMQTextMessage message = (ActiveMQTextMessage) ActiveMQTextMessageTest.SINGLETON.createObject(); message.setText(string); return message; }
Example 17
Source File: ActiveMQXAConnectionFactoryTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
public void testSessionCloseTransactionalSendReceive() throws Exception { ActiveMQXAConnectionFactory cf1 = new ActiveMQXAConnectionFactory("vm://localhost?broker.persistent=false"); XAConnection connection1 = (XAConnection) cf1.createConnection(); connection1.start(); XASession session = connection1.createXASession(); XAResource resource = session.getXAResource(); Destination dest = new ActiveMQQueue(getName()); // publish a message Xid tid = createXid(); resource.start(tid, XAResource.TMNOFLAGS); MessageProducer producer = session.createProducer(dest); ActiveMQTextMessage message = new ActiveMQTextMessage(); message.setText(getName()); producer.send(message); session.close(); resource.end(tid, XAResource.TMSUCCESS); resource.commit(tid, true); session = connection1.createXASession(); MessageConsumer consumer = session.createConsumer(dest); tid = createXid(); resource = session.getXAResource(); resource.start(tid, XAResource.TMNOFLAGS); TextMessage receivedMessage = (TextMessage) consumer.receive(1000); session.close(); assertNotNull(receivedMessage); assertEquals(getName(), receivedMessage.getText()); resource.end(tid, XAResource.TMSUCCESS); resource.commit(tid, true); session = connection1.createXASession(); consumer = session.createConsumer(dest); tid = createXid(); resource = session.getXAResource(); resource.start(tid, XAResource.TMNOFLAGS); assertNull(consumer.receive(1000)); resource.end(tid, XAResource.TMSUCCESS); resource.commit(tid, true); }