use of org.apache.activemq.command.ActiveMQTextMessage in project syndesis-qe by syndesisio.
the class JMSUtils method getMessageText.
public static String getMessageText(String appName, String jmsProtocol, String user, String pass, Destination type, String destinationName) {
Message m = getMessage(appName, jmsProtocol, user, pass, type, destinationName, 60000L);
if (m == null) {
return null;
}
String text = null;
try {
if (m instanceof JmsTextMessage) {
text = ((JmsTextMessage) m).getText();
} else if (m instanceof ActiveMQBytesMessage) {
text = new String(((ActiveMQBytesMessage) m).getContent().getData());
} else {
text = ((ActiveMQTextMessage) m).getText();
}
} catch (JMSException e) {
log.error("Unable to get text from message", e);
e.printStackTrace();
}
log.debug("Got message: " + text);
return text;
}
use of org.apache.activemq.command.ActiveMQTextMessage in project rocketmq-externals by apache.
the class ActivemqSourceTaskTest method getMessageConnentTest.
@Test(expected = RuntimeException.class)
public void getMessageConnentTest() throws JMSException {
String value = "hello rocketmq";
ActivemqSourceTask task = new ActivemqSourceTask();
TextMessage textMessage = new ActiveMQTextMessage();
textMessage.setText(value);
ByteBuffer buffer = task.getMessageConnent(textMessage);
Assert.assertEquals(new String(buffer.array()), textMessage.getText());
ObjectMessage objectMessage = new ActiveMQObjectMessage();
objectMessage.setObject(value);
buffer = task.getMessageConnent(objectMessage);
Assert.assertEquals(new String(buffer.array()), "\"" + objectMessage.getObject().toString() + "\"");
BytesMessage bytes = new ActiveMQBytesMessage();
bytes.writeBytes(value.getBytes());
bytes.reset();
buffer = task.getMessageConnent(bytes);
Assert.assertEquals(new String(buffer.array()), value);
MapMessage mapMessage = new ActiveMQMapMessage();
mapMessage.setString("hello", "rocketmq");
buffer = task.getMessageConnent(mapMessage);
Map<String, String> map = JSON.parseObject(buffer.array(), Map.class);
Assert.assertEquals(map.get("hello"), "rocketmq");
Assert.assertEquals(map.size(), 1);
StreamMessage streamMessage = new ActiveMQStreamMessage();
String valueTwo = null;
for (int i = 0; i < 200; i++) {
valueTwo = valueTwo + value;
}
streamMessage.writeBytes(valueTwo.getBytes());
streamMessage.reset();
buffer = task.getMessageConnent(streamMessage);
Assert.assertEquals(new String(buffer.array()), valueTwo);
task.getMessageConnent(null);
}
use of org.apache.activemq.command.ActiveMQTextMessage in project brave by openzipkin.
the class TracingMessageListenerTest method consumer_and_listener_have_names.
@Test
public void consumer_and_listener_have_names() {
ActiveMQTextMessage message = new ActiveMQTextMessage();
onMessageConsumed(message);
assertThat(testSpanHandler.takeRemoteSpan(CONSUMER).name()).isEqualTo("receive");
assertThat(testSpanHandler.takeLocalSpan().name()).isEqualTo("on-message");
}
use of org.apache.activemq.command.ActiveMQTextMessage in project brave by openzipkin.
the class TracingMessageListenerTest method consumer_span_starts_before_listener.
@Test
public void consumer_span_starts_before_listener() {
ActiveMQTextMessage message = new ActiveMQTextMessage();
onMessageConsumed(message);
MutableSpan consumerSpan = testSpanHandler.takeRemoteSpan(CONSUMER);
MutableSpan listenerSpan = testSpanHandler.takeLocalSpan();
assertChildOf(listenerSpan, consumerSpan);
assertSequential(consumerSpan, listenerSpan);
}
use of org.apache.activemq.command.ActiveMQTextMessage in project brave by openzipkin.
the class TracingMessageListenerTest method starts_new_trace_if_none_exists.
@Test
public void starts_new_trace_if_none_exists() {
ActiveMQTextMessage message = new ActiveMQTextMessage();
onMessageConsumed(message);
testSpanHandler.takeRemoteSpan(CONSUMER);
testSpanHandler.takeLocalSpan();
}
Aggregations