JMS performance

前端 未结 3 1659
生来不讨喜
生来不讨喜 2021-02-18 17:05

I\'m having a bit of trouble with understanding JMS from a performance perspective. We have this very straightforward code in our application:

QueueConnection co         


        
3条回答
  •  野的像风
    2021-02-18 17:46

    Here are some relevant parts of the jms spec:

    section 2.8 Multithreading

    JMS Object          Supports Concurrent Use
    Destination         YES
    ConnectionFactory   YES
    Connection          YES
    Session             NO
    MessageProducer     NO
    MessageConsumer     NO
    

    section 4.4.14 Serial Execution of Client Code

    JMS does not cause concurrent execution of client code unless a client explicitly requests it. One way this is done is to define that a session serializes all asynchronous delivery of messages

    So as already mentioned reuse as much as possible. Reuse the ConnectionFactory, Connection and Destinations for all Threads. For each Thread reuse consumers and producers.

    If you are reusing a JMS connection beware, that the JMS Provider will multiplex different sessions on that connections. So even if it is safe to reuse connections it might be faster to create a connection for every session you need.

提交回复
热议问题