During the Code Reviews we had past couple of weeks I got a chance to look back at how we've done JMS development. I’d like to share what I’ve learnt with u guys.
- Lookup JMS connection factory
- Create connection & session
- Lookup destination (Queue or Topic)
- Create producers or consumers
- Create Msg
- Send or Receive Msgs
- Close Resources (Connections, Sessions, Producers, Consumers) in a finally block
- Start Connections after starting producer/consumer
- Always start consumers before the producers to stop initial messages getting queued
- Choose DUPS_OK_ACKNOWLEDGE or AUTO_ACKNOWLEDGE unless it’s really necessary to use CLIENT_ACKNOWLEDGE
- Choose Non-durable messages wherever possible to avoid persistency overhead
- Process messages concurrently through a ConnectionConsumer using server session pool where each session in the pool would execute separate message concurrently (I think the implementation of this is Vendor specific. Any ideas?)
- Set the TimeToLive value as low as feasible (default is for messages to never expire).
- Configure number of message driven beans by specifying instance pool size in jboss.xml file.
- Use separate transactional sessions and non-transactional sessions for transactional and non-transactional messages.
