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));
}
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;
}
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);
}
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);
}
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());
}
Aggregations