use of org.apache.activemq.command.MessageAck in project activemq-artemis by apache.
the class BrokerTest method testTransactedAckWithPrefetchOfOne.
public void testTransactedAckWithPrefetchOfOne() throws Exception {
// Setup a first connection
StubConnection connection1 = createConnection();
ConnectionInfo connectionInfo1 = createConnectionInfo();
SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
connection1.send(connectionInfo1);
connection1.send(sessionInfo1);
connection1.send(producerInfo1);
destination = createDestinationInfo(connection1, connectionInfo1, destinationType);
ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
consumerInfo1.setPrefetchSize(1);
connection1.send(consumerInfo1);
// Send the messages
for (int i = 0; i < 4; i++) {
Message message = createMessage(producerInfo1, destination, deliveryMode);
connection1.send(message);
}
// Now get the messages.
for (int i = 0; i < 4; i++) {
// Begin the transaction.
LocalTransactionId txid = createLocalTransaction(sessionInfo1);
connection1.send(createBeginTransaction(connectionInfo1, txid));
Message m1 = receiveMessage(connection1);
assertNotNull(m1);
MessageAck ack = createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE);
ack.setTransactionId(txid);
connection1.send(ack);
// Commit the transaction.
connection1.send(createCommitTransaction1Phase(connectionInfo1, txid));
}
assertNoMessagesLeft(connection1);
}
use of org.apache.activemq.command.MessageAck in project activemq-artemis by apache.
the class ClientTestSupport method createAck.
protected MessageAck createAck(ConsumerInfo consumerInfo, Message msg, int count, byte ackType) {
MessageAck ack = new MessageAck();
ack.setAckType(ackType);
ack.setConsumerId(consumerInfo.getConsumerId());
ack.setDestination(msg.getDestination());
ack.setLastMessageId(msg.getMessageId());
ack.setMessageCount(count);
return ack;
}
use of org.apache.activemq.command.MessageAck in project activemq-artemis by apache.
the class MessageAckTest method populateObject.
@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"));
}
use of org.apache.activemq.command.MessageAck in project activemq-artemis by apache.
the class MessageAckTest method createObject.
@Override
public Object createObject() throws Exception {
MessageAck info = new MessageAck();
populateObject(info);
return info;
}
use of org.apache.activemq.command.MessageAck in project activemq-artemis by apache.
the class MessageAckTest method createObject.
@Override
public Object createObject() throws Exception {
MessageAck info = new MessageAck();
populateObject(info);
return info;
}
Aggregations