Search in sources :

Example 21 with StubConnection

use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.

the class BrokerNetworkWithStuckMessagesTest method createSecondRemoteConnection.

protected StubConnection createSecondRemoteConnection() throws Exception {
    Transport transport = TransportFactory.connect(secondRemoteConnector.getServer().getConnectURI());
    StubConnection connection = new StubConnection(transport);
    connections.add(connection);
    return connection;
}
Also used : StubConnection(org.apache.activemq.broker.StubConnection) Transport(org.apache.activemq.transport.Transport)

Example 22 with StubConnection

use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.

the class BrokerNetworkWithStuckMessagesTest method createConnection.

protected StubConnection createConnection() throws Exception {
    Transport transport = TransportFactory.connect(connector.getServer().getConnectURI());
    StubConnection connection = new StubConnection(transport);
    connections.add(connection);
    return connection;
}
Also used : StubConnection(org.apache.activemq.broker.StubConnection) Transport(org.apache.activemq.transport.Transport)

Example 23 with StubConnection

use of org.apache.activemq.broker.StubConnection 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)

Example 24 with StubConnection

use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.

the class ForwardingBridgeTest method testAddConsumerThenSend.

public void testAddConsumerThenSend() throws Exception {
    // 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);
}
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)

Example 25 with StubConnection

use of org.apache.activemq.broker.StubConnection in project activemq-artemis by apache.

the class AdvisoryBrokerTest method testProducerAdvisoriesReplayedOnlyTargetNewConsumer.

public void testProducerAdvisoriesReplayedOnlyTargetNewConsumer() throws Exception {
    ActiveMQDestination queue = new ActiveMQQueue("test");
    ActiveMQDestination destination = AdvisorySupport.getProducerAdvisoryTopic(queue);
    // Setup a first connection
    StubConnection connection1 = createConnection();
    ConnectionInfo connectionInfo1 = createConnectionInfo();
    SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
    connection1.send(connectionInfo1);
    connection1.send(sessionInfo1);
    // Create the first consumer..
    ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
    consumerInfo1.setPrefetchSize(100);
    connection1.send(consumerInfo1);
    // Setup a producer.
    StubConnection connection2 = createConnection();
    ConnectionInfo connectionInfo2 = createConnectionInfo();
    SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
    ProducerInfo producerInfo2 = createProducerInfo(sessionInfo2);
    producerInfo2.setDestination(queue);
    connection2.send(connectionInfo2);
    connection2.send(sessionInfo2);
    connection2.send(producerInfo2);
    Message m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    assertEquals(((ProducerInfo) m1.getDataStructure()).getProducerId(), producerInfo2.getProducerId());
    // Create the 2nd consumer..
    ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
    consumerInfo2.setPrefetchSize(100);
    connection2.send(consumerInfo2);
    // The second consumer should se a replay
    m1 = receiveMessage(connection2);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    assertEquals(((ProducerInfo) m1.getDataStructure()).getProducerId(), producerInfo2.getProducerId());
    // But the first consumer should not see the replay.
    assertNoMessagesLeft(connection1);
}
Also used : ConsumerInfo(org.apache.activemq.command.ConsumerInfo) ProducerInfo(org.apache.activemq.command.ProducerInfo) Message(org.apache.activemq.command.Message) StubConnection(org.apache.activemq.broker.StubConnection) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) SessionInfo(org.apache.activemq.command.SessionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Aggregations

StubConnection (org.apache.activemq.broker.StubConnection)39 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)18 SessionInfo (org.apache.activemq.command.SessionInfo)18 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)17 Transport (org.apache.activemq.transport.Transport)16 ProducerInfo (org.apache.activemq.command.ProducerInfo)14 Message (org.apache.activemq.command.Message)13 URI (java.net.URI)9 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)8 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)6 RemoveInfo (org.apache.activemq.command.RemoveInfo)5 MockTransport (org.apache.activemq.transport.mock.MockTransport)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 OpenwireArtemisBaseTest (org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest)3 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)3 FailoverTransport (org.apache.activemq.transport.failover.FailoverTransport)2 URISyntaxException (java.net.URISyntaxException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 MessageNotWriteableException (javax.jms.MessageNotWriteableException)1