Search in sources :

Example 11 with RemoveInfo

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

the class RemoveInfoTest method createObject.

@Override
public Object createObject() throws Exception {
    RemoveInfo info = new RemoveInfo();
    populateObject(info);
    return info;
}
Also used : RemoveInfo(org.apache.activemq.command.RemoveInfo)

Example 12 with RemoveInfo

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

the class FailoverTransportTest method testResponsesSentWhenRequestForIgnoredCommands.

@Test(timeout = 30000)
public void testResponsesSentWhenRequestForIgnoredCommands() throws Exception {
    this.transport = createTransport();
    assertNotNull(failoverTransport);
    MessageAck ack = new MessageAck();
    assertNotNull("Should have received a Response", this.transport.request(ack));
    RemoveInfo info = new RemoveInfo(new ConnectionId("2"));
    assertNotNull("Should have received a Response", this.transport.request(info));
}
Also used : ConnectionId(org.apache.activemq.command.ConnectionId) RemoveInfo(org.apache.activemq.command.RemoveInfo) MessageAck(org.apache.activemq.command.MessageAck) Test(org.junit.Test)

Example 13 with RemoveInfo

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

the class AdvisoryBrokerTest method testConnectionAdvisories.

public void testConnectionAdvisories() throws Exception {
    ActiveMQDestination destination = AdvisorySupport.getConnectionAdvisoryTopic();
    // Setup a first connection
    StubConnection connection1 = createConnection();
    ConnectionInfo connectionInfo1 = createConnectionInfo();
    SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
    ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
    consumerInfo1.setPrefetchSize(100);
    connection1.send(connectionInfo1);
    connection1.send(sessionInfo1);
    connection1.send(consumerInfo1);
    // We should get an advisory of our own connection.
    Message m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    assertEquals(((ConnectionInfo) m1.getDataStructure()).getConnectionId(), connectionInfo1.getConnectionId());
    // Setup a second connection
    StubConnection connection2 = createConnection();
    ConnectionInfo connectionInfo2 = createConnectionInfo();
    connection2.send(connectionInfo2);
    // We should get an advisory of the second connection.
    m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    assertEquals(((ConnectionInfo) m1.getDataStructure()).getConnectionId(), connectionInfo2.getConnectionId());
    // Close the second connection.
    connection2.send(closeConnectionInfo(connectionInfo2));
    connection2.stop();
    // We should get an advisory of the second connection closing
    m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    RemoveInfo r = (RemoveInfo) m1.getDataStructure();
    assertEquals(r.getObjectId(), connectionInfo2.getConnectionId());
    assertNoMessagesLeft(connection1);
}
Also used : ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) RemoveInfo(org.apache.activemq.command.RemoveInfo) StubConnection(org.apache.activemq.broker.StubConnection) SessionInfo(org.apache.activemq.command.SessionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 14 with RemoveInfo

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

the class AdvisoryBrokerTest method testConsumerAdvisories.

public void testConsumerAdvisories() throws Exception {
    ActiveMQDestination queue = new ActiveMQQueue("test");
    ActiveMQDestination destination = AdvisorySupport.getConsumerAdvisoryTopic(queue);
    // Setup a first connection
    StubConnection connection1 = createConnection();
    ConnectionInfo connectionInfo1 = createConnectionInfo();
    SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
    ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
    consumerInfo1.setPrefetchSize(100);
    connection1.send(connectionInfo1);
    connection1.send(sessionInfo1);
    connection1.send(consumerInfo1);
    // We should not see and advisory for the advisory consumer.
    assertNoMessagesLeft(connection1);
    // Setup a second consumer.
    StubConnection connection2 = createConnection();
    ConnectionInfo connectionInfo2 = createConnectionInfo();
    SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
    ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, queue);
    consumerInfo1.setPrefetchSize(100);
    connection2.send(connectionInfo2);
    connection2.send(sessionInfo2);
    connection2.send(consumerInfo2);
    // We should get an advisory of the new consumer.
    Message m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    assertEquals(((ConsumerInfo) m1.getDataStructure()).getConsumerId(), consumerInfo2.getConsumerId());
    // Close the second connection.
    connection2.request(closeConnectionInfo(connectionInfo2));
    connection2.stop();
    // We should get an advisory of the consumer closing
    m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    RemoveInfo r = (RemoveInfo) m1.getDataStructure();
    assertEquals(r.getObjectId(), consumerInfo2.getConsumerId());
    assertNoMessagesLeft(connection2);
}
Also used : ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) RemoveInfo(org.apache.activemq.command.RemoveInfo) 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)

Example 15 with RemoveInfo

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

the class AdvisoryBrokerTest method testProducerAdvisories.

public void testProducerAdvisories() 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);
    ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
    consumerInfo1.setPrefetchSize(100);
    connection1.send(connectionInfo1);
    connection1.send(sessionInfo1);
    connection1.send(consumerInfo1);
    assertNoMessagesLeft(connection1);
    // 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);
    // We should get an advisory of the new producer.
    Message m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    assertEquals(((ProducerInfo) m1.getDataStructure()).getProducerId(), producerInfo2.getProducerId());
    // Close the second connection.
    connection2.request(closeConnectionInfo(connectionInfo2));
    connection2.stop();
    // We should get an advisory of the producer closing
    m1 = receiveMessage(connection1);
    assertNotNull(m1);
    assertNotNull(m1.getDataStructure());
    RemoveInfo r = (RemoveInfo) m1.getDataStructure();
    assertEquals(r.getObjectId(), producerInfo2.getProducerId());
    assertNoMessagesLeft(connection2);
}
Also used : ConsumerInfo(org.apache.activemq.command.ConsumerInfo) ProducerInfo(org.apache.activemq.command.ProducerInfo) Message(org.apache.activemq.command.Message) RemoveInfo(org.apache.activemq.command.RemoveInfo) 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

RemoveInfo (org.apache.activemq.command.RemoveInfo)28 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)8 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)6 StubConnection (org.apache.activemq.broker.StubConnection)5 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)5 Message (org.apache.activemq.command.Message)5 SessionInfo (org.apache.activemq.command.SessionInfo)5 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)4 MessageAck (org.apache.activemq.command.MessageAck)4 Test (org.junit.Test)4 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)3 ConnectionId (org.apache.activemq.command.ConnectionId)3 ProducerInfo (org.apache.activemq.command.ProducerInfo)2 Response (org.apache.activemq.command.Response)2 FutureResponse (org.apache.activemq.transport.FutureResponse)2 ResponseCallback (org.apache.activemq.transport.ResponseCallback)2 IOException (java.io.IOException)1 BrokerService (org.apache.activemq.broker.BrokerService)1 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)1 BrokerId (org.apache.activemq.command.BrokerId)1