當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。