当前位置: 首页>>代码示例>>Java>>正文


Java MessageAck.isInTransaction方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:17,代码来源:TransactionBroker.java

示例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);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:30,代码来源:MemoryTransactionStore.java

示例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);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:27,代码来源:MemoryTransactionStore.java

示例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);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:30,代码来源:KahaDBTransactionStore.java

示例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);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:KahaDBTransactionStore.java

示例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);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:24,代码来源:KahaDBTransactionStore.java

示例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
                + ")");
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:45,代码来源:PrefetchSubscription.java

示例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);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:31,代码来源:KahaDBStore.java

示例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);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:46,代码来源:TopicSubscription.java


注:本文中的org.apache.activemq.command.MessageAck.isInTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。