Search in sources :

Example 1 with DeleteOnClose

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));
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open)

Example 2 with DeleteOnClose

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();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 3 with DeleteOnClose

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));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Target(org.apache.qpid.server.protocol.v1_0.type.messaging.Target) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 4 with DeleteOnClose

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));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 5 with DeleteOnClose

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;
}
Also used : LifetimePolicy(org.apache.qpid.server.protocol.v1_0.type.LifetimePolicy) CreatingLinkInfoImpl(org.apache.qpid.server.queue.CreatingLinkInfoImpl) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DeleteOnNoMessages(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoMessages) DeleteOnNoLinksOrMessages(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoLinksOrMessages) DeleteOnClose(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) DeleteOnNoLinks(org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoLinks) CreatingLinkInfo(org.apache.qpid.server.queue.CreatingLinkInfo)

Aggregations

DeleteOnClose (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnClose)7 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)6 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)6 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)6 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)6 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)6 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)5 Test (org.junit.Test)5 Source (org.apache.qpid.server.protocol.v1_0.type.messaging.Source)3 Target (org.apache.qpid.server.protocol.v1_0.type.messaging.Target)3 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 LifetimePolicy (org.apache.qpid.server.protocol.v1_0.type.LifetimePolicy)1 DeleteOnNoLinks (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoLinks)1 DeleteOnNoLinksOrMessages (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoLinksOrMessages)1 DeleteOnNoMessages (org.apache.qpid.server.protocol.v1_0.type.messaging.DeleteOnNoMessages)1 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)1 CreatingLinkInfo (org.apache.qpid.server.queue.CreatingLinkInfo)1