https://issues.apache.org/jira/browse/AMQ-5558 change on producer / consumer - One session per thread

I'm backporting a change I have made into Artemis for this. Each thread should have its own JMS Session
This commit is contained in:
Clebert Suconic 2015-06-26 10:19:21 -04:00
parent b64b8ba27e
commit c5579ff73d
2 changed files with 12 additions and 14 deletions

View File

@ -60,17 +60,16 @@ public class ConsumerCommand extends AbstractCommand {
}
conn.start();
Session sess;
if (transacted) {
sess = conn.createSession(true, Session.SESSION_TRANSACTED);
} else {
sess = conn.createSession(false, ackMode);
}
CountDownLatch active = new CountDownLatch(parallelThreads);
for (int i = 1; i <= parallelThreads; i++) {
Session sess;
if (transacted) {
sess = conn.createSession(true, Session.SESSION_TRANSACTED);
} else {
sess = conn.createSession(false, ackMode);
}
ConsumerThread consumer = new ConsumerThread(sess, ActiveMQDestination.createDestination(destination, ActiveMQDestination.QUEUE_TYPE));
consumer.setName("consumer-" + i);
consumer.setDurable(durable);

View File

@ -60,16 +60,15 @@ public class ProducerCommand extends AbstractCommand {
conn = factory.createConnection(user, password);
conn.start();
Session sess;
if (transactionBatchSize != 0) {
sess = conn.createSession(true, Session.SESSION_TRANSACTED);
} else {
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
CountDownLatch active = new CountDownLatch(parallelThreads);
for (int i = 1; i <= parallelThreads; i++) {
Session sess;
if (transactionBatchSize != 0) {
sess = conn.createSession(true, Session.SESSION_TRANSACTED);
} else {
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
ProducerThread producer = new ProducerThread(sess, ActiveMQDestination.createDestination(destination, ActiveMQDestination.QUEUE_TYPE));
producer.setName("producer-" + i);
producer.setMessageCount(messageCount);