use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.
the class Session_1_0Test method testLinkStealing.
public void testLinkStealing() {
_virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, QUEUE_NAME));
Attach attach = createQueueAttach(true, getTestName(), QUEUE_NAME);
AMQPConnection_1_0 connection1 = _connection;
Session_1_0 session1 = _session;
session1.receiveAttach(attach);
Link_1_0<?, ?> link = _virtualHost.getSendingLink(connection1.getRemoteContainerId(), attach.getName());
assertNotNull("Link is not created", link);
assertAttachSent(connection1, session1, attach);
AMQPConnection_1_0 connection2 = createAmqpConnection_1_0(connection1.getRemoteContainerId());
Session_1_0 session2 = createSession_1_0(connection2, 0);
session2.receiveAttach(attach);
assertDetachSent(connection1, session1, LinkError.STOLEN, 1);
assertAttachSent(connection2, session2, attach);
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.
the class Session_1_0Test method testReceiveAttachForInvalidUnsubscribe.
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", 0, queues.size());
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.
the class Session_1_0Test method testReceiveReattachRebindingQueueNoActiveLinks.
public void testReceiveReattachRebindingQueueNoActiveLinks() {
final String linkName = "testLink";
final String address = "amq.direct/" + TOPIC_NAME;
Attach attach = createSharedTopicAttach(true, linkName, address, true);
_session.receiveAttach(attach);
assertAttachSent(_connection, _session, attach);
assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
sendDetach(_session, attach.getHandle(), false);
ArgumentCaptor<FrameBody> frameCapture = ArgumentCaptor.forClass(FrameBody.class);
verify(_connection, times(2)).sendFrame(eq(_session.getChannelId()), frameCapture.capture());
assertTrue(frameCapture.getAllValues().get(1) instanceof Detach);
assertQueues(TOPIC_NAME, LifetimePolicy.PERMANENT);
String topicName2 = TOPIC_NAME + "2";
final String address2 = "amq.direct/" + topicName2;
Attach attach2 = createSharedTopicAttach(true, linkName, address2, true);
_session.receiveAttach(attach2);
assertAttachSent(_connection, _session, attach2, 2);
assertQueues(topicName2, LifetimePolicy.PERMANENT);
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.
the class Session_1_0Test method testReceiveAttachSharedTopicNonDurableWithContainer.
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", 2, queues.size());
for (Queue<?> queue : queues) {
Collection<QueueConsumer<?, ?>> consumers = queue.getConsumers();
assertEquals("Unexpected number of consumers on queue " + queue.getName(), 1, consumers.size());
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Attach in project qpid-broker-j by apache.
the class SendingLinkEndpoint method reattachLink.
@Override
protected void reattachLink(final Attach attach) throws AmqpErrorException {
if (getSource() == null) {
throw new IllegalStateException("Terminus should be set when resuming a Link.");
}
if (attach.getSource() == null) {
throw new IllegalStateException("Attach.getSource should not be null when resuming a Link. That would be recovering the Link.");
}
Source newSource = (Source) attach.getSource();
Source oldSource = getSource();
final SendingDestination destination = getSession().getSendingDestination(getLink(), oldSource);
prepareConsumerOptionsAndFilters(destination);
if (getDestination() instanceof ExchangeSendingDestination && !Boolean.TRUE.equals(newSource.getDynamic())) {
final SendingDestination newDestination = getSession().getSendingDestination(getLink(), newSource);
if (getSession().updateSourceForSubscription(this, newSource, newDestination)) {
setDestination(newDestination);
}
}
attachReceived(attach);
}
Aggregations