mirror of https://github.com/apache/activemq.git
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:
parent
b64b8ba27e
commit
c5579ff73d
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue