use of org.apache.activemq.command.Response in project activemq-artemis by apache.
the class ResponseTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
Response info = (Response) object;
info.setCorrelationId(1);
}
use of org.apache.activemq.command.Response in project activemq-artemis by apache.
the class ResponseTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
Response info = (Response) object;
info.setCorrelationId(1);
}
use of org.apache.activemq.command.Response in project activemq-artemis by apache.
the class ResponseTest method createObject.
@Override
public Object createObject() throws Exception {
Response info = new Response();
populateObject(info);
return info;
}
use of org.apache.activemq.command.Response in project activemq-artemis by apache.
the class ResponseTest method populateObject.
@Override
protected void populateObject(Object object) throws Exception {
super.populateObject(object);
Response info = (Response) object;
info.setCorrelationId(1);
}
use of org.apache.activemq.command.Response in project activemq-artemis by apache.
the class XARecoveryBrokerTest method testPreparedInterleavedTransactionRecoveredOnRestart.
public void testPreparedInterleavedTransactionRecoveredOnRestart() 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);
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
connection.send(consumerInfo);
// Prepare 4 message sends.
for (int i = 0; i < 4; i++) {
// Begin the transaction.
XATransactionId txid = createXATransaction(sessionInfo);
connection.send(createBeginTransaction(connectionInfo, txid));
Message message = createMessage(producerInfo, destination);
message.setPersistent(true);
message.setTransactionId(txid);
connection.send(message);
// Prepare
connection.send(createPrepareTransaction(connectionInfo, txid));
}
// Since prepared but not committed.. they should not get delivered.
assertNull(receiveMessage(connection));
assertNoMessagesLeft(connection);
// send non tx message
Message message = createMessage(producerInfo, destination);
message.setPersistent(true);
connection.request(message);
connection.request(closeConnectionInfo(connectionInfo));
// restart the broker.
restartBroker();
// Setup the consumer and try receive the message.
connection = createConnection();
connectionInfo = createConnectionInfo();
sessionInfo = createSessionInfo(connectionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
consumerInfo = createConsumerInfo(sessionInfo, destination);
connection.send(consumerInfo);
// consume non transacted message, but don't ack
int countToReceive = expectedMessageCount(1, destination);
for (int i = 0; i < countToReceive; i++) {
Message m = receiveMessage(connection, TimeUnit.SECONDS.toMillis(10));
LOG.info("received: " + m);
assertNotNull("got non tx message after prepared", m);
}
// Since prepared but not committed.. they should not get delivered.
assertNull(receiveMessage(connection));
assertNoMessagesLeft(connection);
Response response = connection.request(new TransactionInfo(connectionInfo.getConnectionId(), null, TransactionInfo.RECOVER));
assertNotNull(response);
DataArrayResponse dar = (DataArrayResponse) response;
assertEquals(4, dar.getData().length);
// ensure we can close a connection with prepared transactions
connection.request(closeConnectionInfo(connectionInfo));
// open again to deliver outcome
connection = createConnection();
connectionInfo = createConnectionInfo();
sessionInfo = createSessionInfo(connectionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
// Commit the prepared transactions.
for (int i = 0; i < dar.getData().length; i++) {
TransactionId transactionId = (TransactionId) dar.getData()[i];
LOG.info("commit: " + transactionId);
connection.request(createCommitTransaction2Phase(connectionInfo, transactionId));
}
consumerInfo = createConsumerInfo(sessionInfo, destination);
connection.send(consumerInfo);
// We should get the committed transactions and the non tx message
countToReceive = expectedMessageCount(5, destination);
for (int i = 0; i < countToReceive; i++) {
Message m = receiveMessage(connection, TimeUnit.SECONDS.toMillis(10));
LOG.info("received: " + m);
assertNotNull("Got non null message: " + i, m);
}
assertNoMessagesLeft(connection);
assertEmptyDLQ();
}
Aggregations