use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class AnonymousTerminusTest method transferUnsettledToUnknownDestinationWhenRejectedOutcomeNotSupportedBySource.
@SpecificationTest(section = "Using the Anonymous Terminus for Message Routing. 2.2.2 Routing Errors", description = "It is possible that a message sent to a routing node has an address in the to field" + " of properties which, if used in the address field of target of an attach," + " would result in an unsuccessful link establishment (for example," + " if the address cannot be resolved to a node). In this case the routing node" + " MUST communicate the error back to the sender of the message." + " [...]" + " If the source of the link does not support the rejected outcome," + " [...] then the routing node MUST detach the link with an error." + " [...] the info field of error MUST contain an entry with symbolic key delivery-tag" + " and binary value of the delivery-tag of the message which caused the failure.")
@Test
public void transferUnsettledToUnknownDestinationWhenRejectedOutcomeNotSupportedBySource() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = openInteractionWithAnonymousRelayCapability(transport);
interaction.begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(generateMessagePayloadToDestination("Unknown")).transferDeliveryTag(_deliveryTag).transfer();
Detach detach = interaction.consumeResponse().getLatestResponse(Detach.class);
Error error = detach.getError();
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), is(equalTo(AmqpError.NOT_FOUND)));
assertThat(error.getInfo(), is(notNullValue()));
assertThat(error.getInfo().get(DELIVERY_TAG), is(equalTo(_deliveryTag)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach 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.transport.Detach in project qpid-broker-j by apache.
the class TransferTest method transferReceiverSettleModeCannotBeSecondWhenLinkModeIsFirst.
@Test
@SpecificationTest(section = "2.7.5", description = "If the negotiated link value is first, then it is illegal to set this field to second.")
public void transferReceiverSettleModeCannotBeSecondWhenLinkModeIsFirst() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
Detach detach = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayloadData("testData").transferRcvSettleMode(ReceiverSettleMode.SECOND).transfer().consumeResponse().getLatestResponse(Detach.class);
Error error = detach.getError();
assertThat(error, is(notNullValue()));
assertThat(error.getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class TransferTest method durableTransferWithoutRejectedOutcome.
@Test
@SpecificationTest(section = "3.2.1", description = "Durable messages MUST NOT be lost even if an intermediary is unexpectedly terminated and " + "restarted. A target which is not capable of fulfilling this guarantee MUST NOT accept messages " + "where the durable header is set to true: if the source allows the rejected outcome then the " + "message SHOULD be rejected with the precondition-failed error, otherwise the link MUST be " + "detached by the receiver with the same error.")
public void durableTransferWithoutRejectedOutcome() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
MessageEncoder messageEncoder = new MessageEncoder();
final Header header = new Header();
header.setDurable(true);
messageEncoder.setHeader(header);
messageEncoder.addData("foo");
final Response<?> response = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(messageEncoder.getPayload()).transferRcvSettleMode(ReceiverSettleMode.FIRST).transfer().consumeResponse().getLatestResponse();
if (getBrokerAdmin().supportsRestart()) {
assertThat(response, is(notNullValue()));
assertThat(response.getBody(), is(instanceOf(Disposition.class)));
final Disposition receivedDisposition = (Disposition) response.getBody();
assertThat(receivedDisposition.getSettled(), is(true));
assertThat(receivedDisposition.getState(), is(instanceOf(Outcome.class)));
assertThat(((Outcome) receivedDisposition.getState()).getSymbol(), is(Accepted.ACCEPTED_SYMBOL));
} else {
assertThat(response, is(notNullValue()));
assertThat(response.getBody(), is(instanceOf(Detach.class)));
final Detach receivedDetach = (Detach) response.getBody();
assertThat(receivedDetach.getError(), is(notNullValue()));
assertThat(receivedDetach.getError().getCondition(), is(AmqpError.PRECONDITION_FAILED));
}
}
}
use of org.apache.qpid.server.protocol.v1_0.type.transport.Detach in project qpid-broker-j by apache.
the class DischargeTest method dischargeSettledAfterSenderDetach.
@Test
@SpecificationTest(section = "4.4.4.1", description = "Transactional Posting [...]" + " Delivery Sent Unsettled By Controller; Resource Settles [...]" + " The resource MUST determine the outcome of the delivery before committing the" + " transaction, and this MUST be communicated to the controller before the acceptance" + " of a successful discharge. The outcome communicated by the resource MUST be associated" + " with the same transaction with which the transfer from controller to resource" + " was associated.")
public void dischargeSettledAfterSenderDetach() throws Exception {
assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachHandle(UnsignedInteger.ONE).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferTransactionalState(txnState.getCurrentTransactionId()).transferPayloadData("test message").transferHandle(UnsignedInteger.ONE).transfer().consumeResponse(Disposition.class).detachHandle(UnsignedInteger.ONE).detach().consumeResponse(Detach.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
interaction.txnDischarge(txnState, false);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
}
}
Aggregations