Search in sources :

Example 51 with Message

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

the class RecoverExpiredMessagesTest method consumeExpected.

private void consumeExpected() throws Exception {
    // Setup the consumer and receive the message.
    StubConnection connection = createConnection();
    ConnectionInfo connectionInfo = createConnectionInfo();
    SessionInfo sessionInfo = createSessionInfo(connectionInfo);
    connection.send(connectionInfo);
    connection.send(sessionInfo);
    ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
    connection.send(consumerInfo);
    Message m = receiveMessage(connection);
    assertNotNull("Should have received message " + expected.get(0) + " by now!", m);
    assertEquals(expected.get(0), m.getMessageId().toString());
    MessageAck ack = createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE);
    connection.send(ack);
    assertNoMessagesLeft(connection);
    connection.request(closeConnectionInfo(connectionInfo));
}
Also used : ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) StubConnection(org.apache.activemq.broker.StubConnection) SessionInfo(org.apache.activemq.command.SessionInfo) MessageAck(org.apache.activemq.command.MessageAck) ConnectionInfo(org.apache.activemq.command.ConnectionInfo)

Example 52 with Message

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

the class BrokerNetworkWithStuckMessagesTest method createMessage.

protected Message createMessage(ProducerInfo producerInfo, ActiveMQDestination destination, int deliveryMode) {
    Message message = createMessage(producerInfo, destination);
    message.setPersistent(deliveryMode == DeliveryMode.PERSISTENT);
    return message;
}
Also used : ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) Message(org.apache.activemq.command.Message) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage)

Example 53 with Message

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

the class DemandForwardingBridgeFilterTest method assertReceiveNoMessageOn.

private void assertReceiveNoMessageOn(String destinationName, byte destinationType) throws Exception, InterruptedException {
    ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, destinationType);
    // Send the message to the local broker.
    producerConnection.send(createMessage(producerInfo, destination, destinationType));
    // Make sure the message was delivered via the remote.
    Message m = createConsumerAndReceiveMessage(destination);
    assertNull(m);
}
Also used : Message(org.apache.activemq.command.Message) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 54 with Message

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

the class DemandForwardingBridgeFilterTest method assertReceiveMessageOn.

private void assertReceiveMessageOn(String destinationName, byte destinationType) throws Exception, InterruptedException {
    ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, destinationType);
    // Send the message to the local broker.
    producerConnection.send(createMessage(producerInfo, destination, destinationType));
    // Make sure the message was delivered via the remote.
    Message m = createConsumerAndReceiveMessage(destination);
    assertNotNull(m);
}
Also used : Message(org.apache.activemq.command.Message) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 55 with Message

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

the class ForwardingBridgeTest method testForwardMessageCompressed.

public void testForwardMessageCompressed() throws Exception {
    bridge.setUseCompression(true);
    // Start a producer on local broker
    StubConnection connection1 = createConnection();
    ConnectionInfo connectionInfo1 = createConnectionInfo();
    SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
    ProducerInfo producerInfo = createProducerInfo(sessionInfo1);
    connection1.send(connectionInfo1);
    connection1.send(sessionInfo1);
    connection1.send(producerInfo);
    destination = createDestinationInfo(connection1, connectionInfo1, destinationType);
    // Start a consumer on a remote broker
    StubConnection connection2 = createRemoteConnection();
    ConnectionInfo connectionInfo2 = createConnectionInfo();
    SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
    connection2.send(connectionInfo2);
    connection2.send(sessionInfo2);
    ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo2, destination);
    connection2.send(consumerInfo);
    Thread.sleep(1000);
    // Give forwarding bridge a chance to finish setting up
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ie) {
        ie.printStackTrace();
    }
    // Send the message to the local boker.
    connection1.send(createMessage(producerInfo, destination, deliveryMode));
    // Make sure the message was delivered via the remote.
    Message m = receiveMessage(connection2);
    assertNotNull(m);
    // Make sure its compressed now
    ActiveMQMessage message = (ActiveMQMessage) m;
    assertTrue(message.isCompressed());
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage) StubConnection(org.apache.activemq.broker.StubConnection) SessionInfo(org.apache.activemq.command.SessionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQMessage(org.apache.activemq.command.ActiveMQMessage)

Aggregations

Message (org.apache.activemq.command.Message)102 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)77 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)71 SessionInfo (org.apache.activemq.command.SessionInfo)71 ProducerInfo (org.apache.activemq.command.ProducerInfo)69 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)46 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)24 MessageAck (org.apache.activemq.command.MessageAck)15 XATransactionId (org.apache.activemq.command.XATransactionId)15 StubConnection (org.apache.activemq.broker.StubConnection)14 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)13 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)11 DataArrayResponse (org.apache.activemq.command.DataArrayResponse)9 TransactionInfo (org.apache.activemq.command.TransactionInfo)9 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)8 LocalTransactionId (org.apache.activemq.command.LocalTransactionId)8 Response (org.apache.activemq.command.Response)7 Test (org.junit.Test)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 DestinationStatistics (org.apache.activemq.broker.region.DestinationStatistics)5