Search in sources :

Example 21 with Outcome

use of org.apache.qpid.server.protocol.v1_0.type.Outcome in project qpid-broker-j by apache.

the class DischargeTest method dischargeUnknownTransactionIdWhenSourceDoesNotSupportRejectedOutcome.

@Test
@SpecificationTest(section = "4.3", description = "If the coordinator is unable to complete the discharge, the coordinator MUST convey the error to the controller " + "as a transaction-error. [...] If the source does not support " + "the rejected outcome, the transactional resource MUST detach the link to the coordinator, with the detach " + "performative carrying the transaction-error.")
public void dischargeUnknownTransactionIdWhenSourceDoesNotSupportRejectedOutcome() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final Disposition disposition = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attachTarget(new Coordinator()).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayloadData(new Declare()).transfer().consumeResponse().getLatestResponse(Disposition.class);
        assertThat(disposition.getSettled(), is(equalTo(true)));
        assertThat(disposition.getState(), is(instanceOf(Declared.class)));
        assertThat(((Declared) disposition.getState()).getTxnId(), is(notNullValue()));
        interaction.consumeResponse(Flow.class);
        final Discharge discharge = new Discharge();
        discharge.setTxnId(new Binary("nonExistingTransaction".getBytes(UTF_8)));
        final Detach detachResponse = interaction.transferDeliveryId(UnsignedInteger.ONE).transferDeliveryTag(new Binary("discharge".getBytes(UTF_8))).transferPayloadData(discharge).transfer().consumeResponse(Detach.class).getLatestResponse(Detach.class);
        Error error = detachResponse.getError();
        assertThat(error, is(notNullValue()));
        assertThat(error.getCondition(), is(equalTo(TransactionError.UNKNOWN_ID)));
    }
}
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) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Coordinator(org.apache.qpid.server.protocol.v1_0.type.transaction.Coordinator) Declare(org.apache.qpid.server.protocol.v1_0.type.transaction.Declare) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Discharge(org.apache.qpid.server.protocol.v1_0.type.transaction.Discharge) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 22 with Outcome

use of org.apache.qpid.server.protocol.v1_0.type.Outcome in project qpid-broker-j by apache.

the class TransactionalTransferTest method receiveTransactionalRetirementReceiverSettleSecond.

@Ignore("TODO disposition is currently not being sent by Broker")
@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement[...] The transaction controller might" + "wish to associate the outcome of a delivery with a transaction.")
public void receiveTransactionalRetirementReceiverSettleSecond() throws Exception {
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
    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.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().decodeLatestDelivery();
        Object data = interaction.getDecodedLatestDelivery();
        assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
        Disposition settledDisposition = interaction.dispositionSettled(false).dispositionRole(Role.RECEIVER).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition().consumeResponse(Disposition.class).getLatestResponse(Disposition.class);
        assertThat(settledDisposition.getSettled(), is(true));
        assertThat(settledDisposition.getState(), is(instanceOf(TransactionalState.class)));
        assertThat(((TransactionalState) settledDisposition.getState()).getOutcome(), is(instanceOf(Accepted.class)));
        interaction.txnDischarge(txnState, false);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Ignore(org.junit.Ignore) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 23 with Outcome

use of org.apache.qpid.server.protocol.v1_0.type.Outcome in project qpid-broker-j by apache.

the class Interaction method dispositionTransactionalState.

public Interaction dispositionTransactionalState(final Binary transactionId, final Outcome outcome) {
    TransactionalState state = new TransactionalState();
    state.setTxnId(transactionId);
    state.setOutcome(outcome);
    return dispositionState(state);
}
Also used : TransactionalState(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionalState)

Example 24 with Outcome

use of org.apache.qpid.server.protocol.v1_0.type.Outcome in project qpid-broker-j by apache.

the class Interaction method attachSourceDefaultOutcome.

public Interaction attachSourceDefaultOutcome(final Outcome defaultOutcome) {
    Source source = ((Source) _attach.getSource());
    source.setDefaultOutcome(defaultOutcome);
    _attach.setSource(source);
    return this;
}
Also used : BaseSource(org.apache.qpid.server.protocol.v1_0.type.BaseSource) Source(org.apache.qpid.server.protocol.v1_0.type.messaging.Source)

Aggregations

SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)15 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)15 Test (org.junit.Test)15 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)13 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)9 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)9 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)8 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)8 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)8 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)7 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)6 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)6 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)6 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)5 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)5 Rejected (org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected)5 Discharge (org.apache.qpid.server.protocol.v1_0.type.transaction.Discharge)5 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)5 Outcome (org.apache.qpid.server.protocol.v1_0.type.Outcome)4