Maninder Reddy
Maninder Reddy

Reputation: 107

Can a single QueueConnection be used in multithreaded environment.?

I have a IBM QM that is configured in IBM WAS. A single QueueConnection is created from QCF and is loaded into memory, so that multiple threads can access the same connection(each thread will create a session out this conn) to send and receive messages from Queue. I have a performance issue with this approach.

  1. While first thread is using the connection, will other threads wait until the first send and receive.?
  2. If this is the case can I create a connection for each thread.? Will this affect performance.?

I have an application where no.of concurrent requests will be 50 per sec. So I have to deal with the performance issue.

Any help will be appreciated.

Upvotes: 1

Views: 680

Answers (2)

Nicholas
Nicholas

Reputation: 16056

JMS connections (i.e. QueueConnections and TopicConnections) are thread safe and can be used by multiple threads. All JMS constructs "below" a connection (i.e. Sessions, QueueSessions, TopicSessions) are not, and one should be allocated per thread.

Upvotes: 3

Steve C
Steve C

Reputation: 19445

Each thread should be sharing a QueueConnectionFactory rather than a QueueConnection.

Threads will then create their own QueueConnection from the factory.

Upvotes: 1

Related Questions