use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.
the class TopicBroker method rollback.
/**
* Rolls back the transaction with the given transaction id. If
* the flag <code>setRedelivered</code> is set then the JMS properties for
* redelivery and delivery count of messages pulled within this transaction
* are updated
*
* @param transactionId transaction id
* @param setRedelivered specifies JMS redelivery setting
* @throws QueueException on error
*/
public void rollback(Object transactionId, boolean setRedelivered) throws QueueException {
lockAndWaitAsyncFinished();
try {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "rollback");
TopicTransaction transaction = (TopicTransaction) transactionId;
transaction.rollback();
transactions.set(transaction.getTransactionId(), null);
} catch (Exception e) {
throw new QueueException(e.getMessage());
} finally {
lock.unlock();
}
}
use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.
the class TopicBroker method commit.
/**
* Commit the transaction with the given transaction id
*
* @param transactionId transaction id
* @throws QueueException on error
*/
public void commit(Object transactionId) throws QueueException {
lockAndWaitAsyncFinished();
try {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "commit");
TopicTransaction transaction = (TopicTransaction) transactionId;
long delay = transaction.commit();
TopicFlowController fc = (TopicFlowController) getFlowController();
if (fc != null)
fc.setLastDelay(delay);
transactions.set(transaction.getTransactionId(), null);
} catch (Exception e) {
throw new QueueException(e.getMessage());
} finally {
lock.unlock();
}
}
use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.
the class TopicBroker method commit.
public void commit(Object localTransactionId, XidImpl globalTransactionId) throws QueueException {
lockAndWaitAsyncFinished();
try {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "commit, globalTxId=" + globalTransactionId);
TopicTransaction transaction = (TopicTransaction) localTransactionId;
long delay = transaction.commit(globalTransactionId);
TopicFlowController fc = (TopicFlowController) getFlowController();
if (fc != null)
fc.setLastDelay(delay);
transactions.set(transaction.getTransactionId(), null);
} catch (Exception e) {
throw new QueueException(e.getMessage());
} finally {
lock.unlock();
}
}
use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-client by iitsoftware.
the class ReplyNE method createException.
private void createException(String className, String msg) throws Exception {
if (className.equals("com.swiftmq.swiftlet.queue.QueueException"))
exception = new QueueException(msg);
else if (className.equals("com.swiftmq.swiftlet.queue.QueueLimitException"))
exception = new QueueLimitException(msg);
else if (className.equals("com.swiftmq.swiftlet.queue.UnknownQueueException"))
exception = new InvalidDestinationException(msg);
else if (className.equals("com.swiftmq.swiftlet.auth.ResourceLimitException"))
exception = new ResourceLimitException(msg);
else if (className.equals("com.swiftmq.swiftlet.auth.AuthenticationException"))
exception = new AuthenticationException(msg);
else if (className.equals("javax.jms.InvalidDestinationException"))
exception = new InvalidDestinationException(msg);
else
exception = new Exception(className + ": " + msg);
}
use of com.swiftmq.swiftlet.queue.QueueException in project swiftmq-ce by iitsoftware.
the class TransactionRegistry method discharge.
public void discharge(TxnIdIF btxnId, boolean rollback) throws EndWithErrorException {
String txnId = new String(((TransactionId) btxnId).getValue());
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge, txnId=" + txnId + ", rollback=" + rollback);
lock.lock();
try {
ActiveTxEntry activeTxEntry = (ActiveTxEntry) activeTx.remove(txnId);
if (activeTxEntry == null) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge, txnId=" + txnId + ", not found!");
throw new SessionEndException(TransactionError.UNKNOWN_ID, new AMQPString("Transaction id not found: " + txnId));
}
if (activeTxEntry.inboundTxEntryMap != null) {
for (Iterator iter = activeTxEntry.inboundTxEntryMap.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
InboundTxEntry inboundTxEntry = (InboundTxEntry) entry.getValue();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge txnid=" + txnId + ", linkName=" + entry.getKey());
if (rollback)
inboundTxEntry.tx.rollback();
else
inboundTxEntry.tx.commit();
inboundTxEntry.targetLink.setFlowcontrolDelay(inboundTxEntry.tx.getFlowControlDelay());
inboundTxEntry.targetLink.decreaseActiveTransactions();
inboundTxEntry.targetLink.closeResource();
}
activeTxEntry.inboundTxEntryMap.clear();
}
if (activeTxEntry.outboundTxEntryMap != null) {
for (Iterator iter = activeTxEntry.outboundTxEntryMap.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
long deliveryId = ((Long) entry.getKey()).longValue();
OutboundTxEntry outboundTxEntry = (OutboundTxEntry) entry.getValue();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/discharge txnid=" + txnId + ", deliveryId=" + deliveryId);
if (rollback) {
if (outboundTxEntry.sourceLink != null)
sessionHandler.settleOutbound(deliveryId, RELEASED);
} else
sessionHandler.settleOutbound(deliveryId, outboundTxEntry.deliveryStateIF);
if (outboundTxEntry.sourceLink != null) {
outboundTxEntry.sourceLink.decreaseActiveTransactions();
outboundTxEntry.sourceLink.closeResource();
}
}
activeTxEntry.outboundTxEntryMap.clear();
sessionHandler.sendOutboundDeliveries();
}
} catch (QueueException e) {
throw new ConnectionEndException(AmqpError.INTERNAL_ERROR, new AMQPString(e.toString()));
} finally {
lock.unlock();
}
}
Aggregations