本文整理汇总了Java中org.apache.activemq.command.MessageAck.isInTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java MessageAck.isInTransaction方法的具体用法?Java MessageAck.isInTransaction怎么用?Java MessageAck.isInTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.command.MessageAck
的用法示例。
在下文中一共展示了MessageAck.isInTransaction方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: acknowledge
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception {
// This method may be invoked recursively.
// Track original tx so that it can be restored.
final ConnectionContext context = consumerExchange.getConnectionContext();
Transaction originalTx = context.getTransaction();
Transaction transaction = null;
if (ack.isInTransaction()) {
transaction = getTransaction(context, ack.getTransactionId(), false);
}
context.setTransaction(transaction);
try {
next.acknowledge(consumerExchange, ack);
} finally {
context.setTransaction(originalTx);
}
}
示例2: removeMessage
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
/**
* @param ack
* @throws IOException
*/
final void removeMessage(final MessageStore destination, final MessageAck ack) throws IOException {
if (doingRecover) {
return;
}
if (ack.isInTransaction()) {
Tx tx = getTx(ack.getTransactionId());
tx.add(new RemoveMessageCommand() {
public MessageAck getMessageAck() {
return ack;
}
public void run(ConnectionContext ctx) throws IOException {
destination.removeMessage(ctx, ack);
}
@Override
public MessageStore getMessageStore() {
return destination;
}
});
} else {
destination.removeMessage(null, ack);
}
}
示例3: acknowledge
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
public void acknowledge(final TopicMessageStore destination, final String clientId, final String subscriptionName,
final MessageId messageId, final MessageAck ack) throws IOException {
if (doingRecover) {
return;
}
if (ack.isInTransaction()) {
Tx tx = getTx(ack.getTransactionId());
tx.add(new RemoveMessageCommand() {
public MessageAck getMessageAck() {
return ack;
}
public void run(ConnectionContext ctx) throws IOException {
destination.acknowledge(ctx, clientId, subscriptionName, messageId, ack);
}
@Override
public MessageStore getMessageStore() {
return destination;
}
});
} else {
destination.acknowledge(null, clientId, subscriptionName, messageId, ack);
}
}
示例4: removeMessage
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
/**
* @param ack
* @throws IOException
*/
final void removeMessage(ConnectionContext context, final MessageStore destination, final MessageAck ack)
throws IOException {
if (ack.isInTransaction()) {
if (ack.getTransactionId().isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions()== false) {
destination.removeMessage(context, ack);
} else {
Tx tx = getTx(ack.getTransactionId());
tx.add(new RemoveMessageCommand(context) {
@Override
public MessageAck getMessageAck() {
return ack;
}
@Override
public Future<Object> run(ConnectionContext ctx) throws IOException {
destination.removeMessage(ctx, ack);
return AbstractMessageStore.FUTURE;
}
});
}
} else {
destination.removeMessage(context, ack);
}
}
示例5: removeAsyncMessage
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
final void removeAsyncMessage(ConnectionContext context, final MessageStore destination, final MessageAck ack)
throws IOException {
if (ack.isInTransaction()) {
if (ack.getTransactionId().isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions()==false) {
destination.removeAsyncMessage(context, ack);
} else {
Tx tx = getTx(ack.getTransactionId());
tx.add(new RemoveMessageCommand(context) {
@Override
public MessageAck getMessageAck() {
return ack;
}
@Override
public Future<Object> run(ConnectionContext ctx) throws IOException {
destination.removeMessage(ctx, ack);
return AbstractMessageStore.FUTURE;
}
});
}
} else {
destination.removeAsyncMessage(context, ack);
}
}
示例6: acknowledge
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
final void acknowledge(ConnectionContext context, final TopicMessageStore destination, final String clientId, final String subscriptionName,
final MessageId messageId, final MessageAck ack) throws IOException {
if (ack.isInTransaction()) {
if (ack.getTransactionId().isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions()== false) {
destination.acknowledge(context, clientId, subscriptionName, messageId, ack);
} else {
Tx tx = getTx(ack.getTransactionId());
tx.add(new RemoveMessageCommand(context) {
public MessageAck getMessageAck() {
return ack;
}
public Future<Object> run(ConnectionContext ctx) throws IOException {
destination.acknowledge(ctx, clientId, subscriptionName, messageId, ack);
return AbstractMessageStore.FUTURE;
}
});
}
} else {
destination.acknowledge(context, clientId, subscriptionName, messageId, ack);
}
}
示例7: assertAckMatchesDispatched
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
/**
* Checks an ack versus the contents of the dispatched list.
* called with dispatchLock held
* @param ack
* @throws JMSException if it does not match
*/
protected void assertAckMatchesDispatched(MessageAck ack) throws JMSException {
MessageId firstAckedMsg = ack.getFirstMessageId();
MessageId lastAckedMsg = ack.getLastMessageId();
int checkCount = 0;
boolean checkFoundStart = false;
boolean checkFoundEnd = false;
for (MessageReference node : dispatched) {
if (firstAckedMsg == null) {
checkFoundStart = true;
} else if (!checkFoundStart && firstAckedMsg.equals(node.getMessageId())) {
checkFoundStart = true;
}
if (checkFoundStart) {
checkCount++;
}
if (lastAckedMsg != null && lastAckedMsg.equals(node.getMessageId())) {
checkFoundEnd = true;
break;
}
}
if (!checkFoundStart && firstAckedMsg != null)
throw new JMSException("Unmatched acknowledge: " + ack
+ "; Could not find Message-ID " + firstAckedMsg
+ " in dispatched-list (start of ack)");
if (!checkFoundEnd && lastAckedMsg != null)
throw new JMSException("Unmatched acknowledge: " + ack
+ "; Could not find Message-ID " + lastAckedMsg
+ " in dispatched-list (end of ack)");
if (ack.getMessageCount() != checkCount && !ack.isInTransaction()) {
throw new JMSException("Unmatched acknowledge: " + ack
+ "; Expected message count (" + ack.getMessageCount()
+ ") differs from count in dispatched-list (" + checkCount
+ ")");
}
}
示例8: removeAsyncMessage
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
@Override
public void removeAsyncMessage(ConnectionContext context, MessageAck ack) throws IOException {
if (isConcurrentStoreAndDispatchQueues()) {
AsyncJobKey key = new AsyncJobKey(ack.getLastMessageId(), getDestination());
StoreQueueTask task = null;
synchronized (asyncTaskMap) {
task = (StoreQueueTask) asyncTaskMap.get(key);
}
if (task != null) {
if (ack.isInTransaction() || !task.cancel()) {
try {
task.future.get();
} catch (InterruptedException e) {
throw new InterruptedIOException(e.toString());
} catch (Exception ignored) {
LOG.debug("removeAsync: cannot cancel, waiting for add resulted in ex", ignored);
}
removeMessage(context, ack);
} else {
synchronized (asyncTaskMap) {
asyncTaskMap.remove(key);
}
}
} else {
removeMessage(context, ack);
}
} else {
removeMessage(context, ack);
}
}
示例9: acknowledge
import org.apache.activemq.command.MessageAck; //导入方法依赖的package包/类
@Override
public synchronized void acknowledge(final ConnectionContext context, final MessageAck ack) throws Exception {
super.acknowledge(context, ack);
// Handle the standard acknowledgment case.
if (ack.isStandardAck() || ack.isPoisonAck() || ack.isIndividualAck()) {
if (context.isInTransaction()) {
context.getTransaction().addSynchronization(new Synchronization() {
@Override
public void afterCommit() throws Exception {
synchronized (TopicSubscription.this) {
if (singleDestination && destination != null) {
destination.getDestinationStatistics().getDequeues().add(ack.getMessageCount());
}
}
dequeueCounter.addAndGet(ack.getMessageCount());
dispatchMatched();
}
});
} else {
if (singleDestination && destination != null) {
destination.getDestinationStatistics().getDequeues().add(ack.getMessageCount());
destination.getDestinationStatistics().getInflight().subtract(ack.getMessageCount());
}
dequeueCounter.addAndGet(ack.getMessageCount());
}
dispatchMatched();
return;
} else if (ack.isDeliveredAck()) {
// Message was delivered but not acknowledged: update pre-fetch counters.
// also. get these for a consumer expired message.
if (destination != null && !ack.isInTransaction()) {
destination.getDestinationStatistics().getDequeues().add(ack.getMessageCount());
destination.getDestinationStatistics().getInflight().subtract(ack.getMessageCount());
}
dequeueCounter.addAndGet(ack.getMessageCount());
dispatchMatched();
return;
} else if (ack.isRedeliveredAck()) {
// nothing to do atm
return;
}
throw new JMSException("Invalid acknowledgment: " + ack);
}