Search in sources :

Example 6 with TransactionId

use of com.swiftmq.amqp.v100.generated.transactions.coordination.TransactionId in project swiftmq-ce by iitsoftware.

the class TransactionRegistry method addToTransaction.

public void addToTransaction(TxnIdIF btxnId, SourceLink sourceLink, long deliveryId, MessageIndex messageIndex, long size) throws EndWithErrorException {
    String txnId = new String(((TransactionId) btxnId).getValue());
    String linkName = sourceLink.getName();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/addToTransaction, txnId=" + txnId + ", linkName=" + linkName + ", messageIndex=" + messageIndex);
    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));
        }
        sourceLink.increaseActiveTransactions();
        if (activeTxEntry.outboundTxEntryMap == null)
            activeTxEntry.outboundTxEntryMap = new HashMap();
        OutboundTxEntry outboundTxEntry = (OutboundTxEntry) activeTxEntry.outboundTxEntryMap.get(deliveryId);
        if (outboundTxEntry == null) {
            outboundTxEntry = new OutboundTxEntry(sourceLink, messageIndex, null);
            activeTxEntry.outboundTxEntryMap.put(deliveryId, outboundTxEntry);
        } else {
            outboundTxEntry.sourceLink = sourceLink;
            outboundTxEntry.messageIndex = messageIndex;
        }
    } finally {
        lock.unlock();
    }
}
Also used : HashMap(java.util.HashMap) AMQPString(com.swiftmq.amqp.v100.types.AMQPString) AMQPString(com.swiftmq.amqp.v100.types.AMQPString)

Aggregations

AMQPString (com.swiftmq.amqp.v100.types.AMQPString)6 HashMap (java.util.HashMap)4 QueueException (com.swiftmq.swiftlet.queue.QueueException)3 TransactionId (com.swiftmq.amqp.v100.generated.transactions.coordination.TransactionId)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 DeliveryStateIF (com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF)1 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)1