Search in sources :

Example 11 with DeliveryStateIF

use of com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF in project swiftmq-ce by iitsoftware.

the class TransactionRegistry method addToTransaction.

private void addToTransaction(String txnId, long deliveryId, DeliveryStateIF deliveryStateIF) throws EndWithErrorException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/addToTransaction, txnId=" + txnId + ", deliveryId=" + deliveryId + ", deliveryStateIF=" + deliveryStateIF);
    lock.lock();
    try {
        ActiveTxEntry activeTxEntry = (ActiveTxEntry) activeTx.get(txnId);
        if (activeTxEntry == null) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/addToTransaction, txnId=" + txnId + ", not found!");
            throw new SessionEndException(TransactionError.UNKNOWN_ID, new AMQPString("Transaction id not found: " + txnId));
        }
        if (activeTxEntry.outboundTxEntryMap == null)
            activeTxEntry.outboundTxEntryMap = new HashMap();
        OutboundTxEntry outboundTxEntry = (OutboundTxEntry) activeTxEntry.outboundTxEntryMap.get(deliveryId);
        if (outboundTxEntry == null) {
            outboundTxEntry = new OutboundTxEntry(null, null, deliveryStateIF);
            activeTxEntry.outboundTxEntryMap.put(deliveryId, outboundTxEntry);
        } else
            outboundTxEntry.deliveryStateIF = deliveryStateIF;
    } finally {
        lock.unlock();
    }
}
Also used : HashMap(java.util.HashMap) AMQPString(com.swiftmq.amqp.v100.types.AMQPString)

Example 12 with DeliveryStateIF

use of com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF in project swiftmq-client by iitsoftware.

the class TransactionController method discharge.

private synchronized void discharge(TxnIdIF txnId, boolean fail) throws AMQPException {
    AMQPMessage msg = new AMQPMessage();
    Discharge discharge = new Discharge();
    discharge.setTxnId(txnId);
    discharge.setFail(new AMQPBoolean(fail));
    msg.setAmqpValue(new AmqpValue(discharge));
    DeliveryStateIF deliveryState = producer.send(msg);
    if (deliveryState instanceof Rejected) {
        Rejected rejected = (Rejected) deliveryState;
        com.swiftmq.amqp.v100.generated.transport.definitions.Error error = rejected.getError();
        if (error != null)
            throw new AMQPException(error.getValueString());
        else
            throw new AMQPException(("Unknown transactiom error"));
    }
}
Also used : DeliveryStateIF(com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF) Rejected(com.swiftmq.amqp.v100.generated.messaging.delivery_state.Rejected) AMQPBoolean(com.swiftmq.amqp.v100.types.AMQPBoolean) AMQPMessage(com.swiftmq.amqp.v100.messaging.AMQPMessage) AmqpValue(com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)

Aggregations

DeliveryStateIF (com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF)7 IOException (java.io.IOException)4 Accepted (com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted)3 TransactionalState (com.swiftmq.amqp.v100.generated.transactions.coordination.TransactionalState)3 InvalidStateException (com.swiftmq.amqp.v100.client.InvalidStateException)2 Rejected (com.swiftmq.amqp.v100.generated.messaging.delivery_state.Rejected)2 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)2 AMQPString (com.swiftmq.amqp.v100.types.AMQPString)2 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)2 TopicException (com.swiftmq.swiftlet.topic.TopicException)2 HashMap (java.util.HashMap)2 InvalidSelectorException (javax.jms.InvalidSelectorException)2 POSendMessage (com.swiftmq.amqp.v100.client.po.POSendMessage)1 AmqpValue (com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)1 Header (com.swiftmq.amqp.v100.generated.messaging.message_format.Header)1 MessageIdString (com.swiftmq.amqp.v100.generated.messaging.message_format.MessageIdString)1 Properties (com.swiftmq.amqp.v100.generated.messaging.message_format.Properties)1 Declared (com.swiftmq.amqp.v100.generated.transactions.coordination.Declared)1 Milliseconds (com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds)1 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)1