本文整理汇总了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;
}
示例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));
}
示例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);
}
}
示例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;
}
示例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: 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);
}
}
示例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();
}
}
示例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);
}
}
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
}
}
示例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"));
}