문제

I'm working on a project where we have a high throughput jms messages production (and also consumers, by the way). Some tests made me believe that I'm not working correctly with JMS messages production at it's best. First of all let me explain the scenario: We have a Weblogic cluster (2 nodes) with 13 Queues. The messages are received on a UDP listener (Netty) and it is created a ByteMessage that is alocated on the first Queue and so on. With some profiling I discovered that this first step does not take much long to execute and neither its consumer BUT the messages are still being stuck on the Queue for a long period of time. They are non persistent with 0 (zero) time to delivery. An improvement is to cache de connectionFactory, ConnectionQueue, Queue and QueueSession and use them like forever. But this can't be right. I mean, we should not open those resources and never ever ever close them, right? What should really be cached and when should I release a connection and a session? Should I create a session per message to be send or is it ok reuse it? What I mean is, what's the best way to produce large amount of jms messages on a Queue (300 per second or so) considering the correctly resources handling? I'm stuck here, all sources that I found tell me to always close when the job is done but its never done (it will always receive a large amount of messages).

Regards in advance.

edit: I forgot to say that the MDB's have the default 16 consumers size and, in theory considering the processing time that a single message takes, should be enough to consume all messages without "stocking" them.

도움이 되었습니까?

해결책

You need to cache JMS objects.

If you are using a Java EE server then it should do this for you. I believe this is configurable.

https://community.jboss.org/wiki/ShouldICacheJMSConnectionsAndJMSSessions

JMS objects like connection, session, consumer and producer were designed to be re-used. In most implementations connection and session are pretty heavyweight to setup and consumer usually requires a network round trip to set up. Producer is often more lightweight, although there is often some overhead in creating it.

Spring also offers connection and session caching wrappers.

Tuning WebLogic JMS http://docs.oracle.com/cd/E28280_01/web.1111/e13814/jmstuning.htm

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top