当前位置: 首页>>代码示例>>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;未经允许,请勿转载。