Search in sources :

Example 61 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_v0_8 method getReplyTo.

private String getReplyTo(final InternalMessage serverMsg, final NamedAddressSpace addressSpace) {
    String replyTo = serverMsg.getMessageHeader().getReplyTo();
    if (replyTo != null) {
        DestinationAddress destinationAddress = new DestinationAddress(addressSpace, replyTo);
        MessageDestination messageDestination = destinationAddress.getMessageDestination();
        final String replyToBindingUrl;
        if (messageDestination instanceof Exchange) {
            Exchange<?> exchange = (Exchange<?>) messageDestination;
            final String routingKeyOption = "".equals(destinationAddress.getRoutingKey()) ? "" : String.format("?routingkey='%s'", destinationAddress.getRoutingKey());
            replyToBindingUrl = String.format("%s://%s//%s", exchange.getType(), exchange.getName(), routingKeyOption);
        } else if (messageDestination instanceof Queue) {
            replyToBindingUrl = String.format("%s:////%s", ExchangeDefaults.DIRECT_EXCHANGE_CLASS, messageDestination.getName());
        } else {
            replyToBindingUrl = String.format("%s:////?routingkey='%s'", ExchangeDefaults.DIRECT_EXCHANGE_CLASS, destinationAddress.getRoutingKey());
        }
        return replyToBindingUrl;
    }
    return null;
}
Also used : Exchange(org.apache.qpid.server.model.Exchange) MessageDestination(org.apache.qpid.server.message.MessageDestination) Queue(org.apache.qpid.server.model.Queue) DestinationAddress(org.apache.qpid.server.model.DestinationAddress)

Example 62 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachTopicDurableWithContainer.

@Test
public void testReceiveAttachTopicDurableWithContainer() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createTopicAttach(true, linkName + "|1", address, false);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
    AMQPConnection_1_0 secondConnection = createAmqpConnection_1_0("testContainerId2");
    Session_1_0 secondSession = createSession_1_0(secondConnection, 0);
    Attach attach2 = createTopicAttach(true, linkName + "|2", address, false);
    secondSession.receiveAttach(attach2);
    assertAttachSent(secondConnection, secondSession, attach2);
    Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after second subscription with the same subscription name but different " + "container id ", (long) 2, (long) queues.size());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue) Test(org.junit.Test)

Example 63 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachSharedTopicNonDurableNoContainer.

@Test
public void testReceiveAttachSharedTopicNonDurableNoContainer() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createSharedTopicAttach(false, linkName, address, true);
    Attach attach2 = createSharedTopicAttach(false, linkName, address, true);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
    AMQPConnection_1_0 secondConnection = createAmqpConnection_1_0();
    Session_1_0 secondSession = createSession_1_0(secondConnection, 0);
    secondSession.receiveAttach(attach2);
    assertAttachSent(secondConnection, secondSession, attach2);
    assertQueues(TOPIC_NAME, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
    final Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after attach", (long) 1, (long) queues.size());
    Queue<?> queue = queues.iterator().next();
    Collection<QueueConsumer<?, ?>> consumers = queue.getConsumers();
    assertEquals("Unexpected number of consumers", (long) 2, (long) consumers.size());
}
Also used : QueueConsumer(org.apache.qpid.server.queue.QueueConsumer) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue) Test(org.junit.Test)

Example 64 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachForInvalidUnsubscribe.

@Test
public void testReceiveAttachForInvalidUnsubscribe() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach unsubscribeAttach = createTopicAttach(true, linkName, address, false);
    unsubscribeAttach.setSource(null);
    _session.receiveAttach(unsubscribeAttach);
    assertAttachFailed(_connection, _session, unsubscribeAttach);
    Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after unsubscribe", (long) 0, (long) queues.size());
}
Also used : Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue) Test(org.junit.Test)

Example 65 with Queue

use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.

the class Session_1_0Test method testReceiveAttachSharedTopicNonDurableWithContainer.

@Test
public void testReceiveAttachSharedTopicNonDurableWithContainer() throws Exception {
    final String linkName = "testLink";
    final String address = "amq.direct/" + TOPIC_NAME;
    Attach attach = createSharedTopicAttach(false, linkName, address, false);
    Attach attach2 = createSharedTopicAttach(false, linkName, address, false);
    _session.receiveAttach(attach);
    assertAttachSent(_connection, _session, attach);
    assertQueues(TOPIC_NAME, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
    AMQPConnection_1_0 secondConnection = createAmqpConnection_1_0("testContainerId2");
    Session_1_0 secondSession = createSession_1_0(secondConnection, 0);
    secondSession.receiveAttach(attach2);
    assertAttachSent(secondConnection, secondSession, attach2);
    final Collection<Queue> queues = _virtualHost.getChildren(Queue.class);
    assertEquals("Unexpected number of queues after attach", (long) 2, (long) queues.size());
    for (Queue<?> queue : queues) {
        Collection<QueueConsumer<?, ?>> consumers = queue.getConsumers();
        assertEquals("Unexpected number of consumers on queue " + queue.getName(), (long) 1, (long) consumers.size());
    }
}
Also used : QueueConsumer(org.apache.qpid.server.queue.QueueConsumer) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Queue(org.apache.qpid.server.model.Queue) Test(org.junit.Test)

Aggregations

Queue (org.apache.qpid.server.model.Queue)66 Test (org.junit.Test)32 HashMap (java.util.HashMap)18 Exchange (org.apache.qpid.server.model.Exchange)13 MessageDestination (org.apache.qpid.server.message.MessageDestination)11 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)9 DestinationAddress (org.apache.qpid.server.model.DestinationAddress)8 MessageSource (org.apache.qpid.server.message.MessageSource)6 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)6 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)6 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)5 AccessControlException (java.security.AccessControlException)4 Map (java.util.Map)4 QmfAgentData (org.apache.qpid.qmf2.agent.QmfAgentData)4 ServerMessage (org.apache.qpid.server.message.ServerMessage)4 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)4 LinkedHashMap (java.util.LinkedHashMap)3 AMQInvalidArgumentException (org.apache.qpid.server.filter.AMQInvalidArgumentException)3