感觉作用不是很大,但还是记到这里。均属转载。
- Start the consumer before you start the producer so that the initial messages do not need to queue.
- Use a ConnectionConsumer to process messages concurrently with a ServerSessionPool.
- Close resources (e.g. connections, session objects, producers, consumers) when finished with them.
- DUPS_OK_ACKNOWLEDGE and AUTO_ACKNOWLEDGE perform better than CLIENT_ACKNOWLEDGE.
- Use separate transactional sessions and non-transactional sessions for transactional and non-transactional messages.
- Tune the Destination parameters: a smaller capacity increases message throughput; a higher redelivery delay and lower redelivery limit reduces the overhead.
- Choose non-durable (NON_PERSISTENT) messages wherever appropriate to avoid the persistency overhead.
- Set the TimeToLive value as low as feasible (default is for messages to never expire).
- Receive messages asynchronously with a MessageListener implementation.
- Choose the message type that minimizes memory overheads.
- Use 'transient' variables to reduce serialization overheads.
- 在消费/生产一条消息时,均创建一个全新Consumer/Producer,工作完毕即可关闭,此工作方式的好处是不产生死连接,但是同时带来了性能的大幅下降,Consumer/Producer的创建,是一个非常耗时的过程,需要连接JMS中间件,注册监听器,确认,关闭过程需要通知中间件卸载监听器。
-
频繁的”短连接“将对JMS中间件稳定性的影响。很多JMS中间件经受不住高并发”短连接“操作,会造成队列假死,消息丢失、消息脏读等问题,特别是在进行select操作过程中更为明显。