Search in sources :

Example 1 with AmqpFrameValidator

use of org.apache.activemq.transport.amqp.client.AmqpFrameValidator in project activemq-artemis by apache.

the class AmqpDurableReceiverTest method testDetachedDurableReceiverRemainsActive.

@Test(timeout = 60000)
public void testDetachedDurableReceiverRemainsActive() throws Exception {
    AmqpClient client = createAmqpClient();
    AmqpConnection connection = addConnection(client.createConnection());
    connection.setContainerId(getContainerID());
    connection.connect();
    connection.setReceivedFrameInspector(new AmqpFrameValidator() {

        @Override
        public void inspectDetach(Detach detach, Binary encoded) {
            if (detach.getClosed()) {
                markAsInvalid("Remote should have detached but closed instead.");
            }
        }
    });
    connection.setSentFrameInspector(new AmqpFrameValidator() {

        @Override
        public void inspectDetach(Detach detach, Binary encoded) {
            if (detach.getClosed()) {
                markAsInvalid("Client should have detached but closed instead.");
            }
        }
    });
    AmqpSession session = connection.createSession();
    AmqpReceiver receiver = session.createDurableReceiver(getTopicName(), getSubscriptionName());
    assertEquals(getTopicName(), lookupSubscription());
    receiver.detach();
    assertEquals(getTopicName(), lookupSubscription());
    connection.getSentFrameInspector().assertValid();
    connection.getReceivedFrameInspector().assertValid();
    connection.close();
}
Also used : AmqpConnection(org.apache.activemq.transport.amqp.client.AmqpConnection) AmqpFrameValidator(org.apache.activemq.transport.amqp.client.AmqpFrameValidator) AmqpSession(org.apache.activemq.transport.amqp.client.AmqpSession) AmqpReceiver(org.apache.activemq.transport.amqp.client.AmqpReceiver) AmqpClient(org.apache.activemq.transport.amqp.client.AmqpClient) Binary(org.apache.qpid.proton.amqp.Binary) Detach(org.apache.qpid.proton.amqp.transport.Detach) Test(org.junit.Test)

Aggregations

AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)1 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)1 AmqpFrameValidator (org.apache.activemq.transport.amqp.client.AmqpFrameValidator)1 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)1 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)1 Binary (org.apache.qpid.proton.amqp.Binary)1 Detach (org.apache.qpid.proton.amqp.transport.Detach)1 Test (org.junit.Test)1