use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose in project qpid-broker-j by apache.
the class TemporaryDestinationTest method deleteOnCloseWithConnectionClose.
private void deleteOnCloseWithConnectionClose(final Symbol[] targetCapabilities) throws Exception {
String newTemporaryNodeAddress = null;
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Target target = new Target();
target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
target.setDynamic(true);
target.setCapabilities(targetCapabilities);
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
assertThat(attachResponse.getTarget(), is(notNullValue()));
newTemporaryNodeAddress = ((Target) attachResponse.getTarget()).getAddress();
assertThat(newTemporaryNodeAddress, is(notNullValue()));
assertThat(Utils.doesNodeExist(_brokerAddress, newTemporaryNodeAddress), is(true));
interaction.consumeResponse().getLatestResponse(Flow.class);
interaction.doCloseConnection();
}
assertThat(Utils.doesNodeExist(_brokerAddress, newTemporaryNodeAddress), is(false));
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose in project qpid-broker-j by apache.
the class ManagementTest method drainTemporaryMessageSource.
@Test
@SpecificationTest(section = "2.6.7", description = "The drain flag indicates how the sender SHOULD behave when insufficient messages" + " are available to consume the current link-credit. If set, the sender will" + " (after sending all available messages) advance the delivery-count as much as possible," + " consuming all link-credit, and send the flow state to the receiver.")
public void drainTemporaryMessageSource() throws Exception {
assumeThat(getBrokerAdmin().isManagementSupported(), is(equalTo(true)));
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Target target = new Target();
target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
target.setDynamic(true);
target.setCapabilities(new Symbol[] { Symbol.valueOf("temporary-queue") });
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().openHostname("$management").open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
assertThat(attachResponse.getTarget(), is(notNullValue()));
String newTemporaryNodeAddress = ((Target) attachResponse.getTarget()).getAddress();
assertThat(newTemporaryNodeAddress, is(notNullValue()));
interaction.consumeResponse().getLatestResponse(Flow.class);
final Attach receiverResponse = interaction.attachHandle(UnsignedInteger.ONE).attachRole(Role.RECEIVER).attachSourceAddress(newTemporaryNodeAddress).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(receiverResponse.getSource(), is(instanceOf(Source.class)));
assertThat(((Source) receiverResponse.getSource()).getAddress(), is(equalTo(newTemporaryNodeAddress)));
// 2.6.8 Synchronous Get
// grant credit of 1
interaction.flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow();
// send drain to ensure the sender promptly advances the delivery-count until link-credit is consumed
interaction.flowDrain(true).flow();
Flow flow = interaction.consumeResponse().getLatestResponse(Flow.class);
assertThat(flow.getLinkCredit(), is(equalTo(UnsignedInteger.ZERO)));
assertThat(flow.getHandle(), is(equalTo(receiverResponse.getHandle())));
interaction.doCloseConnection();
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose in project qpid-broker-j by apache.
the class DeleteOnCloseTest method deleteOnCloseOnTarget.
@Test
@SpecificationTest(section = "3.5.10", description = "A node dynamically created with this lifetime policy will be deleted at the point that the link which caused its\n" + "creation ceases to exist.")
public void deleteOnCloseOnTarget() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Target target = new Target();
target.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
target.setDynamic(true);
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTarget(target).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getTarget(), is(notNullValue()));
final String newTempQueueAddress = ((Target) attachResponse.getTarget()).getAddress();
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
interaction.consumeResponse().getLatestResponse(Flow.class);
interaction.detachClose(true).detach().consumeResponse().getLatestResponse(Detach.class);
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(false));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose in project qpid-broker-j by apache.
the class DeleteOnCloseTest method doesNotDeleteOnDetach.
@Test
@SpecificationTest(section = "3.5.10", description = "A node dynamically created with this lifetime policy will be deleted at the point that the link which caused its\n" + "creation ceases to exist.")
public void doesNotDeleteOnDetach() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Source source = new Source();
source.setDynamicNodeProperties(Collections.singletonMap(Session_1_0.LIFETIME_POLICY, new DeleteOnClose()));
source.setDynamic(true);
final Interaction interaction = transport.newInteraction();
final Attach attachResponse = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.RECEIVER).attachSource(source).attach().consumeResponse().getLatestResponse(Attach.class);
assertThat(attachResponse.getSource(), is(notNullValue()));
final String newTempQueueAddress = ((Source) attachResponse.getSource()).getAddress();
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
interaction.detach().consumeResponse().getLatestResponse(Detach.class);
assertThat(Utils.doesNodeExist(_brokerAddress, newTempQueueAddress), is(true));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose in project qpid-broker-j by apache.
the class Session_1_0 method convertDynamicNodePropertiesToAttributes.
private Map<String, Object> convertDynamicNodePropertiesToAttributes(final Link_1_0<?, ?> link, final Map properties, final String nodeName) {
// TODO convert AMQP 1-0 node properties to queue attributes
LifetimePolicy lifetimePolicy = properties == null ? null : (LifetimePolicy) properties.get(LIFETIME_POLICY);
Map<String, Object> attributes = new HashMap<>();
attributes.put(ConfiguredObject.ID, UUID.randomUUID());
attributes.put(ConfiguredObject.NAME, nodeName);
attributes.put(ConfiguredObject.DURABLE, true);
if (lifetimePolicy instanceof DeleteOnNoLinks) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.DELETE_ON_NO_LINKS);
} else if (lifetimePolicy instanceof DeleteOnNoLinksOrMessages) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.IN_USE);
} else if (lifetimePolicy instanceof DeleteOnClose) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.DELETE_ON_CREATING_LINK_CLOSE);
final CreatingLinkInfo linkInfo = new CreatingLinkInfoImpl(link.getRole() == Role.SENDER, link.getRemoteContainerId(), link.getName());
attributes.put("creatingLinkInfo", linkInfo);
} else if (lifetimePolicy instanceof DeleteOnNoMessages) {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.IN_USE);
} else {
attributes.put(ConfiguredObject.LIFETIME_POLICY, org.apache.qpid.server.model.LifetimePolicy.DELETE_ON_CONNECTION_CLOSE);
}
return attributes;
}
Aggregations