JMS - Connection & Session

Discussions

General J2EE: JMS - Connection & Session

  1. JMS - Connection & Session (2 messages)

    In JMS we have the Connection object that establishes the TCP/IP connection between the JMS Client machine and the JMS Provider. We have session object to create the senders - receivers and publishers - subscribers depending on if we are implementing p2p or publish - subscribe message paradigm.

    Its said that from 1 connection object multiple session objects can be created but am not getting the whole point of having multiple sessions and what was the reason why we have two different objects Connection and Session if the Connection object could provide the services as provided by Session ?

    please answer.
  2. Its to do with threading and consumption.

    If you are using async consumption of messages, the contract is each session will only dispatch in one thread at once. So if you want to consume in 20 threads concurrently using the JMS client API, create 20 sessions.

    (You get much more fine control over things like concurrency, threading, pooling and transactions using JCA)

    James
    LogicBlaze
    Open Source SOA
  3. BTW transactions also happen at the Session level (not the connection level as many threads may be working on different transactions using the same connection)

    James
    LogicBlaze
    Open Source SOA