Search in sources :

Example 26 with MessageAck

use of org.apache.activemq.command.MessageAck in project activemq-artemis by apache.

the class XARecoveryBrokerTest method testQueuePersistentUncommittedAcksLostOnRestart.

public void testQueuePersistentUncommittedAcksLostOnRestart() throws Exception {
    ActiveMQDestination destination = createDestination();
    // Setup the producer and send the message.
    StubConnection connection = createConnection();
    ConnectionInfo connectionInfo = createConnectionInfo();
    SessionInfo sessionInfo = createSessionInfo(connectionInfo);
    ProducerInfo producerInfo = createProducerInfo(sessionInfo);
    connection.send(connectionInfo);
    connection.send(sessionInfo);
    connection.send(producerInfo);
    for (int i = 0; i < 4; i++) {
        Message message = createMessage(producerInfo, destination);
        message.setPersistent(true);
        connection.send(message);
    }
    // Begin the transaction.
    XATransactionId txid = createXATransaction(sessionInfo);
    connection.send(createBeginTransaction(connectionInfo, txid));
    Message message = null;
    for (ActiveMQDestination dest : destinationList(destination)) {
        // Setup the consumer and receive the message.
        ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, dest);
        connection.send(consumerInfo);
        for (int i = 0; i < 4; i++) {
            message = receiveMessage(connection);
            assertNotNull(message);
        }
        MessageAck ack = createAck(consumerInfo, message, 4, MessageAck.STANDARD_ACK_TYPE);
        ack.setTransactionId(txid);
        connection.request(ack);
    }
    // Don't commit
    // restart the broker.
    restartBroker();
    // Setup the consumer and receive the message.
    connection = createConnection();
    connectionInfo = createConnectionInfo();
    sessionInfo = createSessionInfo(connectionInfo);
    connection.send(connectionInfo);
    connection.send(sessionInfo);
    for (ActiveMQDestination dest : destinationList(destination)) {
        // Setup the consumer and receive the message.
        ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, dest);
        connection.send(consumerInfo);
        for (int i = 0; i < 4; i++) {
            message = receiveMessage(connection);
            assertNotNull(message);
        }
    }
    assertNoMessagesLeft(connection);
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo) XATransactionId(org.apache.activemq.command.XATransactionId) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) SessionInfo(org.apache.activemq.command.SessionInfo) MessageAck(org.apache.activemq.command.MessageAck) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

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

Example 28 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 29 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 30 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)

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