Search in sources :

Example 21 with ActiveMQTextMessage

use of org.apache.activemq.command.ActiveMQTextMessage in project activemq-artemis by apache.

the class BrowseOverNetworkTest method browseMessages.

protected int browseMessages(QueueBrowser browser, String name) throws Exception {
    Enumeration<?> msgs = browser.getEnumeration();
    int browsedMessage = 0;
    while (msgs.hasMoreElements()) {
        browsedMessage++;
        ActiveMQTextMessage message = (ActiveMQTextMessage) msgs.nextElement();
        LOG.info(name + " browsed: " + message.getText() + " " + message.getDestination() + " " + message.getMessageId() + " " + Arrays.toString(message.getBrokerPath()));
    }
    return browsedMessage;
}
Also used : ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage)

Example 22 with ActiveMQTextMessage

use of org.apache.activemq.command.ActiveMQTextMessage in project rocketmq-externals by apache.

the class ReplicatorTest method commitAddGetQueueTest.

@Test
public void commitAddGetQueueTest() {
    Message message = new ActiveMQTextMessage();
    replicator.commit(message, false);
    Assert.assertEquals(replicator.getQueue().poll(), message);
}
Also used : Message(javax.jms.Message) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) Test(org.junit.Test)

Example 23 with ActiveMQTextMessage

use of org.apache.activemq.command.ActiveMQTextMessage in project rocketmq-externals by apache.

the class ActivemqSourceTaskTest method pollTest.

@Test
public void pollTest() throws Exception {
    ActivemqSourceTask task = new ActivemqSourceTask();
    TextMessage textMessage = new ActiveMQTextMessage();
    textMessage.setText("hello rocketmq");
    Replicator replicatorObject = Mockito.mock(Replicator.class);
    BlockingQueue<Message> queue = new LinkedBlockingQueue<>();
    Mockito.when(replicatorObject.getQueue()).thenReturn(queue);
    Field replicator = ActivemqSourceTask.class.getDeclaredField("replicator");
    replicator.setAccessible(true);
    replicator.set(task, replicatorObject);
    Field config = ActivemqSourceTask.class.getDeclaredField("config");
    config.setAccessible(true);
    config.set(task, new Config());
    queue.put(textMessage);
    Collection<SourceDataEntry> list = task.poll();
    Assert.assertEquals(list.size(), 1);
    list = task.poll();
    Assert.assertEquals(list.size(), 0);
}
Also used : Field(java.lang.reflect.Field) SourceDataEntry(io.openmessaging.connector.api.data.SourceDataEntry) ActiveMQBytesMessage(org.apache.activemq.command.ActiveMQBytesMessage) MapMessage(javax.jms.MapMessage) ObjectMessage(javax.jms.ObjectMessage) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) ActiveMQObjectMessage(org.apache.activemq.command.ActiveMQObjectMessage) Message(javax.jms.Message) ActiveMQMapMessage(org.apache.activemq.command.ActiveMQMapMessage) TextMessage(javax.jms.TextMessage) StreamMessage(javax.jms.StreamMessage) BytesMessage(javax.jms.BytesMessage) ActiveMQStreamMessage(org.apache.activemq.command.ActiveMQStreamMessage) Config(org.apache.rocketmq.connect.activemq.Config) Replicator(org.apache.rocketmq.connect.activemq.Replicator) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) TextMessage(javax.jms.TextMessage) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) Test(org.junit.Test)

Example 24 with ActiveMQTextMessage

use of org.apache.activemq.command.ActiveMQTextMessage in project brave by openzipkin.

the class PropertyFilterTest method filterProperties_message_empty.

@Test
public void filterProperties_message_empty() {
    TextMessage message = new ActiveMQTextMessage();
    PropertyFilter.filterProperties(message, Collections.singleton("b3"));
}
Also used : TextMessage(javax.jms.TextMessage) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) Test(org.junit.Test)

Example 25 with ActiveMQTextMessage

use of org.apache.activemq.command.ActiveMQTextMessage in project brave by openzipkin.

the class TracingJMSConsumerTest method receive_continues_parent_trace_single_header.

@Test
public void receive_continues_parent_trace_single_header() throws Exception {
    ActiveMQTextMessage message = new ActiveMQTextMessage();
    message.setStringProperty("b3", B3SingleFormat.writeB3SingleFormatWithoutParentId(parent));
    receive(message);
    // Ensure the current span in on the message, not the parent
    MutableSpan consumer = testSpanHandler.takeRemoteSpan(CONSUMER);
    assertChildOf(consumer, parent);
    TraceContext messageContext = parseB3SingleFormat(message.getStringProperty("b3")).context();
    assertThat(messageContext.traceIdString()).isEqualTo(consumer.traceId());
    assertThat(messageContext.spanIdString()).isEqualTo(consumer.id());
}
Also used : MutableSpan(brave.handler.MutableSpan) TraceContext(brave.propagation.TraceContext) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) Test(org.junit.Test)

Aggregations

ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)71 Test (org.junit.Test)36 TextMessage (javax.jms.TextMessage)16 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)14 Message (javax.jms.Message)10 MessageProducer (javax.jms.MessageProducer)10 MessageConsumer (javax.jms.MessageConsumer)9 MessageId (org.apache.activemq.command.MessageId)9 JMSException (javax.jms.JMSException)7 ActiveMQBytesMessage (org.apache.activemq.command.ActiveMQBytesMessage)7 DestinationStatistics (org.apache.activemq.broker.region.DestinationStatistics)6 MessageReference (org.apache.activemq.broker.region.MessageReference)6 Queue (org.apache.activemq.broker.region.Queue)6 ActiveMQMapMessage (org.apache.activemq.command.ActiveMQMapMessage)6 ActiveMQObjectMessage (org.apache.activemq.command.ActiveMQObjectMessage)6 ActiveMQStreamMessage (org.apache.activemq.command.ActiveMQStreamMessage)6 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)6 SystemUsage (org.apache.activemq.usage.SystemUsage)6 MutableSpan (brave.handler.MutableSpan)5 MessageNotWriteableException (javax.jms.MessageNotWriteableException)5