Search in sources :

Example 6 with MessageAck

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);
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) LocalTransactionId(org.apache.activemq.command.LocalTransactionId) SessionInfo(org.apache.activemq.command.SessionInfo) MessageAck(org.apache.activemq.command.MessageAck) ConnectionInfo(org.apache.activemq.command.ConnectionInfo)

Example 7 with MessageAck

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;
}
Also used : MessageAck(org.apache.activemq.command.MessageAck)

Example 8 with MessageAck

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"));
}
Also used : MessageAck(org.apache.activemq.command.MessageAck)

Example 9 with MessageAck

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;
}
Also used : MessageAck(org.apache.activemq.command.MessageAck)

Example 10 with MessageAck

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;
}
Also used : MessageAck(org.apache.activemq.command.MessageAck)

Aggregations

MessageAck (org.apache.activemq.command.MessageAck)38 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)15 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)15 Message (org.apache.activemq.command.Message)15 ProducerInfo (org.apache.activemq.command.ProducerInfo)14 SessionInfo (org.apache.activemq.command.SessionInfo)14 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)12 XATransactionId (org.apache.activemq.command.XATransactionId)9 DataArrayResponse (org.apache.activemq.command.DataArrayResponse)5 TransactionInfo (org.apache.activemq.command.TransactionInfo)5 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)4 LocalTransactionId (org.apache.activemq.command.LocalTransactionId)4 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)3 ConnectionId (org.apache.activemq.command.ConnectionId)2 RemoveInfo (org.apache.activemq.command.RemoveInfo)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Vector (java.util.Vector)1 CountDownLatch (java.util.concurrent.CountDownLatch)1