Search in sources :

Example 1 with ProducerInfo

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

the class OpenWireConnection method getProducerBrokerExchange.

private AMQProducerBrokerExchange getProducerBrokerExchange(ProducerId id) throws IOException {
    AMQProducerBrokerExchange result = producerExchanges.get(id);
    if (result == null) {
        synchronized (producerExchanges) {
            result = new AMQProducerBrokerExchange();
            result.setConnectionContext(context);
            // todo: this used to check for  && this.acceptorUsed.isAuditNetworkProducers()
            if (context.isReconnect() || (context.isNetworkConnection())) {
                // once implemented ARTEMIS-194, we need to set the storedSequenceID here somehow
                // We have different semantics on Artemis Journal, but we could adapt something for this
                // TBD during the implementation of ARTEMIS-194
                result.setLastStoredSequenceId(0);
            }
            SessionState ss = state.getSessionState(id.getParentId());
            if (ss != null) {
                result.setProducerState(ss.getProducerState(id));
                ProducerState producerState = ss.getProducerState(id);
                if (producerState != null && producerState.getInfo() != null) {
                    ProducerInfo info = producerState.getInfo();
                }
            }
            producerExchanges.put(id, result);
        }
    }
    return result;
}
Also used : SessionState(org.apache.activemq.state.SessionState) ProducerInfo(org.apache.activemq.command.ProducerInfo) ProducerState(org.apache.activemq.state.ProducerState) AMQProducerBrokerExchange(org.apache.activemq.artemis.core.protocol.openwire.amq.AMQProducerBrokerExchange)

Example 2 with ProducerInfo

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

the class RecoveryBrokerTest method testQueuePersistentMessagesNotLostOnRestart.

public void testQueuePersistentMessagesNotLostOnRestart() throws Exception {
    ActiveMQDestination destination = new ActiveMQQueue("TEST");
    // 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);
    Message message = createMessage(producerInfo, destination);
    message.setPersistent(true);
    connection.send(message);
    connection.request(closeConnectionInfo(connectionInfo));
    // restart the broker.
    restartBroker();
    // Setup the consumer and receive the message.
    connection = createConnection();
    connectionInfo = createConnectionInfo();
    sessionInfo = createSessionInfo(connectionInfo);
    connection.send(connectionInfo);
    connection.send(sessionInfo);
    ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
    connection.send(consumerInfo);
    // Message should have been dropped due to broker restart.
    Message m = receiveMessage(connection);
    assertNotNull("Should have received a message by now!", m);
    assertEquals(m.getMessageId(), message.getMessageId());
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) SessionInfo(org.apache.activemq.command.SessionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 3 with ProducerInfo

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

the class RecoveryBrokerTest method testQueuePersistentCommittedMessagesNotLostOnRestart.

public void testQueuePersistentCommittedMessagesNotLostOnRestart() throws Exception {
    ActiveMQDestination destination = new ActiveMQQueue("TEST");
    // 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);
    // Begin the transaction.
    LocalTransactionId txid = createLocalTransaction(sessionInfo);
    connection.send(createBeginTransaction(connectionInfo, txid));
    for (int i = 0; i < 4; i++) {
        Message message = createMessage(producerInfo, destination);
        message.setPersistent(true);
        message.setTransactionId(txid);
        connection.send(message);
    }
    // Commit
    connection.send(createCommitTransaction1Phase(connectionInfo, txid));
    connection.request(closeConnectionInfo(connectionInfo));
    // restart the broker.
    restartBroker();
    // Setup the consumer and receive the message.
    connection = createConnection();
    connectionInfo = createConnectionInfo();
    sessionInfo = createSessionInfo(connectionInfo);
    connection.send(connectionInfo);
    connection.send(sessionInfo);
    ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
    connection.send(consumerInfo);
    for (int i = 0; i < 4; i++) {
        Message m = receiveMessage(connection);
        assertNotNull(m);
    }
    assertNoMessagesLeft(connection);
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) LocalTransactionId(org.apache.activemq.command.LocalTransactionId) Message(org.apache.activemq.command.Message) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) SessionInfo(org.apache.activemq.command.SessionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 4 with ProducerInfo

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

the class RecoveryBrokerTest method testQueuePersistentUncommitedMessagesLostOnRestart.

public void testQueuePersistentUncommitedMessagesLostOnRestart() throws Exception {
    ActiveMQDestination destination = new ActiveMQQueue("TEST");
    // 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);
    // Begin the transaction.
    LocalTransactionId txid = createLocalTransaction(sessionInfo);
    connection.send(createBeginTransaction(connectionInfo, txid));
    for (int i = 0; i < 4; i++) {
        Message message = createMessage(producerInfo, destination);
        message.setPersistent(true);
        message.setTransactionId(txid);
        connection.send(message);
    }
    // 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);
    ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
    connection.send(consumerInfo);
    // No messages should be delivered.
    Message m = receiveMessage(connection);
    assertNull(m);
}
Also used : ProducerInfo(org.apache.activemq.command.ProducerInfo) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) LocalTransactionId(org.apache.activemq.command.LocalTransactionId) Message(org.apache.activemq.command.Message) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) SessionInfo(org.apache.activemq.command.SessionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 5 with ProducerInfo

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

the class RecoveryBrokerTest method testTopicDurableConsumerHoldsPersistentMessageAfterRestart.

public void testTopicDurableConsumerHoldsPersistentMessageAfterRestart() throws Exception {
    ActiveMQDestination destination = new ActiveMQTopic("TEST");
    // Setup a first connection
    StubConnection connection1 = createConnection();
    ConnectionInfo connectionInfo1 = createConnectionInfo();
    connectionInfo1.setClientId("A");
    SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
    ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
    connection1.send(connectionInfo1);
    connection1.send(sessionInfo1);
    connection1.send(producerInfo1);
    // Create the durable subscription.
    ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
    consumerInfo1.setSubscriptionName("test");
    consumerInfo1.setPrefetchSize(100);
    connection1.send(consumerInfo1);
    // Close the subscription.
    connection1.send(closeConsumerInfo(consumerInfo1));
    // Send the messages
    connection1.send(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));
    connection1.send(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));
    connection1.send(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));
    connection1.send(createMessage(producerInfo1, destination, DeliveryMode.PERSISTENT));
    connection1.request(closeConnectionInfo(connectionInfo1));
    // Restart the broker.
    restartBroker();
    // Get a connection to the new broker.
    StubConnection connection2 = createConnection();
    ConnectionInfo connectionInfo2 = createConnectionInfo();
    connectionInfo2.setClientId("A");
    SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
    connection2.send(connectionInfo2);
    connection2.send(sessionInfo2);
    // Re-open the subscription.
    ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
    consumerInfo2.setSubscriptionName("test");
    consumerInfo2.setPrefetchSize(100);
    connection2.send(consumerInfo2);
    // The we should get the messages.
    for (int i = 0; i < 4; i++) {
        Message m2 = receiveMessage(connection2);
        assertNotNull("Did not get message " + i, m2);
    }
    assertNoMessagesLeft(connection2);
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ProducerInfo(org.apache.activemq.command.ProducerInfo) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) Message(org.apache.activemq.command.Message) SessionInfo(org.apache.activemq.command.SessionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Aggregations

ProducerInfo (org.apache.activemq.command.ProducerInfo)95 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)72 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)72 SessionInfo (org.apache.activemq.command.SessionInfo)72 Message (org.apache.activemq.command.Message)69 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)42 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)18 XATransactionId (org.apache.activemq.command.XATransactionId)15 StubConnection (org.apache.activemq.broker.StubConnection)14 MessageAck (org.apache.activemq.command.MessageAck)14 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)11 DataArrayResponse (org.apache.activemq.command.DataArrayResponse)9 TransactionInfo (org.apache.activemq.command.TransactionInfo)9 LocalTransactionId (org.apache.activemq.command.LocalTransactionId)8 Response (org.apache.activemq.command.Response)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)4 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)4 TransactionId (org.apache.activemq.command.TransactionId)4