當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageAck類代碼示例

本文整理匯總了Java中org.apache.activemq.command.MessageAck的典型用法代碼示例。如果您正苦於以下問題:Java MessageAck類的具體用法?Java MessageAck怎麽用?Java MessageAck使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MessageAck類屬於org.apache.activemq.command包,在下文中一共展示了MessageAck類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertToNonRangedAck

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
protected MessageAck convertToNonRangedAck(MessageAck ack, MessageReference node) {
    // the original ack may be a ranged ack, but we are trying to delete
    // a specific
    // message store here so we need to convert to a non ranged ack.
    if (ack.getMessageCount() > 0) {
        // Dup the ack
        MessageAck a = new MessageAck();
        ack.copy(a);
        ack = a;
        // Convert to non-ranged.
        ack.setFirstMessageId(node.getMessageId());
        ack.setLastMessageId(node.getMessageId());
        ack.setMessageCount(1);
    }
    return ack;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:17,代碼來源:BaseDestination.java

示例2: consumeExpected

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
private void consumeExpected() throws Exception {
   // Setup the consumer and receive the message.
   StubConnection connection = createConnection();
   ConnectionInfo connectionInfo = createConnectionInfo();
   SessionInfo sessionInfo = createSessionInfo(connectionInfo);
   connection.send(connectionInfo);
   connection.send(sessionInfo);
   ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
   connection.send(consumerInfo);

   Message m = receiveMessage(connection);
   assertNotNull("Should have received message " + expected.get(0) + " by now!", m);
   assertEquals(expected.get(0), m.getMessageId().toString());
   MessageAck ack = createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE);
   connection.send(ack);

   assertNoMessagesLeft(connection);
   connection.request(closeConnectionInfo(connectionInfo));
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:20,代碼來源:RecoverExpiredMessagesTest.java

示例3: 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

示例4: onStompMessageNack

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
public MessageAck onStompMessageNack(String messageId, TransactionId transactionId) throws ProtocolException {

        MessageId msgId = new MessageId(messageId);

        if (!dispatchedMessage.containsKey(msgId)) {
            return null;
        }

        MessageAck ack = new MessageAck();
        ack.setDestination(consumerInfo.getDestination());
        ack.setConsumerId(consumerInfo.getConsumerId());
        ack.setAckType(MessageAck.POSION_ACK_TYPE);
        ack.setMessageID(msgId);
        if (transactionId != null) {
            unconsumedMessage.add(dispatchedMessage.get(msgId));
            ack.setTransactionId(transactionId);
        }
        dispatchedMessage.remove(msgId);

        return ack;
    }
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:22,代碼來源:StompSubscription.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: removeMessage

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException {

    	long seq = persistenceAdapter.getStoreSequenceIdForMessageId(ack.getLastMessageId(), destination)[0];

        // Get a connection and remove the message from the DB
        TransactionContext c = persistenceAdapter.getTransactionContext(context);
        try {
            adapter.doRemoveMessage(c, seq, context != null ? context.getXid() : null);
        } catch (SQLException e) {
            JDBCPersistenceAdapter.log("JDBC Failure: ", e);
            throw IOExceptionSupport.create("Failed to broker message: " + ack.getLastMessageId() + " in container: " + e, e);
        } finally {
            c.close();
        }
        if (context != null && context.getXid() != null) {
            ack.getLastMessageId().setEntryLocator(seq);
        }
    }
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:19,代碼來源:JDBCMessageStore.java

示例7: acknowledge

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException {
    if (ack != null && ack.isUnmatchedAck()) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("ignoring unmatched selector ack for: " + messageId + ", cleanup will get to this message after subsequent acks.");
        }
        return;
    }
    TransactionContext c = persistenceAdapter.getTransactionContext(context);
    try {
        long[] res = getCachedStoreSequenceId(c, destination, messageId);
        if (this.isPrioritizedMessages()) {
            adapter.doSetLastAckWithPriority(c, destination, context != null ? context.getXid() : null, clientId, subscriptionName, res[0], res[1]);
        } else {
            adapter.doSetLastAck(c, destination, context != null ? context.getXid() : null, clientId, subscriptionName, res[0], res[1]);
        }
        if (LOG.isTraceEnabled()) {
            LOG.trace(clientId + ":" + subscriptionName + " ack, seq: " + res[0] + ", priority: " + res[1] + " mid:" + messageId);
        }
    } catch (SQLException e) {
        JDBCPersistenceAdapter.log("JDBC Failure: ", e);
        throw IOExceptionSupport.create("Failed to store acknowledgment for: " + clientId + " on message " + messageId + " in container: " + e, e);
    } finally {
        c.close();
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:26,代碼來源:JDBCTopicMessageStore.java

示例8: close

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
@Override
public void close() throws IOException {
    if (!unconsumedMessages.isClosed()) {
        try {
            if (lastDelivered != null) {
                MessageAck ack = new MessageAck(lastDelivered, MessageAck.STANDARD_ACK_TYPE, deliveredCounter);
                connection.asyncSendPacket(ack);
            }
            dispose();
            this.connection.syncSendPacket(info.createRemoveCommand());
        } catch (JMSException e) {
            throw IOExceptionSupport.create(e);
        }
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:16,代碼來源:ActiveMQInputStream.java

示例9: populateObject

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
@Override
protected void populateObject(Object object) throws Exception {
   super.populateObject(object);
   MessageAck info = (MessageAck) object;
   info.setDestination(createActiveMQDestination("Destination:1"));
   info.setTransactionId(createTransactionId("TransactionId:2"));
   info.setConsumerId(createConsumerId("ConsumerId:3"));
   info.setAckType((byte) 1);
   info.setFirstMessageId(createMessageId("FirstMessageId:4"));
   info.setLastMessageId(createMessageId("LastMessageId:5"));
   info.setMessageCount(1);

}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:14,代碼來源:MessageAckTest.java

示例10: trackRecoveredAcks

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
public void trackRecoveredAcks(ArrayList<MessageAck> acks) {
    this.indexLock.writeLock().lock();
    try {
        for (MessageAck ack : acks) {
            ackedAndPrepared.add(ack.getLastMessageId().toProducerKey());
        }
    } finally {
        this.indexLock.writeLock().unlock();
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:11,代碼來源:MessageDatabase.java

示例11: sendAck

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
protected void sendAck(MessageAck ack, boolean lazy) throws JMSException {
    if (lazy || connection.isSendAcksAsync() || getTransacted()) {
        asyncSendPacket(ack);
    } else {
        syncSendPacket(ack);
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:8,代碼來源:ActiveMQSession.java

示例12: testQueueBrowseMessages

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
public void testQueueBrowseMessages() throws Exception {

      // Start a producer and consumer
      StubConnection connection = createConnection();
      ConnectionInfo connectionInfo = createConnectionInfo();
      SessionInfo sessionInfo = createSessionInfo(connectionInfo);
      ProducerInfo producerInfo = createProducerInfo(sessionInfo);
      connection.send(connectionInfo);
      connection.send(sessionInfo);
      connection.send(producerInfo);

      destination = createDestinationInfo(connection, connectionInfo, destinationType);

      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.send(createMessage(producerInfo, destination, deliveryMode));
      connection.send(createMessage(producerInfo, destination, deliveryMode));

      // Use selector to skip first message.
      ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
      consumerInfo.setBrowser(true);
      connection.send(consumerInfo);

      for (int i = 0; i < 4; i++) {
         Message m = receiveMessage(connection);
         assertNotNull(m);
         connection.send(createAck(consumerInfo, m, 1, MessageAck.DELIVERED_ACK_TYPE));
      }

      assertNoMessagesLeft(connection);
   }
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:32,代碼來源:BrokerTest.java

示例13: immediateIndividualTransactedAck

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
private void immediateIndividualTransactedAck(MessageDispatch md) throws JMSException {
    // acks accumulate on the broker pending transaction completion to indicate
    // delivery status
    registerSync();
    MessageAck ack = new MessageAck(md, MessageAck.INDIVIDUAL_ACK_TYPE, 1);
    ack.setTransactionId(session.getTransactionContext().getTransactionId());
    session.syncSendPacket(ack);
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:9,代碼來源:ActiveMQMessageConsumer.java

示例14: acknowledge

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
/**
 * Acknowledge all the messages that have been delivered to the client up to
 * this point.
 *
 * @throws JMSException
 */
public void acknowledge() throws JMSException {
    clearDeliveredList();
    waitForRedeliveries();
    synchronized(deliveredMessages) {
        // Acknowledge all messages so far.
        MessageAck ack = makeAckForAllDeliveredMessages(MessageAck.STANDARD_ACK_TYPE);
        if (ack == null)
            return; // no msgs

        if (session.getTransacted()) {
            rollbackOnFailedRecoveryRedelivery();
            session.doStartTransaction();
            ack.setTransactionId(session.getTransactionContext().getTransactionId());
        }

        pendingAck = null;
        session.sendAck(ack);

        // Adjust the counters
        deliveredCounter = Math.max(0, deliveredCounter - deliveredMessages.size());
        additionalWindowSize = Math.max(0, additionalWindowSize - deliveredMessages.size());

        if (!session.getTransacted()) {
            deliveredMessages.clear();
        }
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:34,代碼來源:ActiveMQMessageConsumer.java

示例15: populateObject

import org.apache.activemq.command.MessageAck; //導入依賴的package包/類
@Override
protected void populateObject(Object object) throws Exception {
   super.populateObject(object);
   MessageAck info = (MessageAck) object;

   info.setDestination(createActiveMQDestination("Destination:1"));
   info.setTransactionId(createTransactionId("TransactionId:2"));
   info.setConsumerId(createConsumerId("ConsumerId:3"));
   info.setAckType((byte) 1);
   info.setFirstMessageId(createMessageId("FirstMessageId:4"));
   info.setLastMessageId(createMessageId("LastMessageId:5"));
   info.setMessageCount(1);
   info.setPoisonCause(createThrowable("PoisonCause:6"));
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:15,代碼來源:MessageAckTest.java


注:本文中的org.apache.activemq.command.MessageAck類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。