On 18 Apr 2008, at 06:26, Aidan wrote:


Hi,

I am using ActiveMQ 5 and am having an issue with my server (running
embedded broker) hitting a deadlock with in MemoryUsage.waitForMemory. I have read the JIRA defects for this, however I have a question about how I am using Producers in ActiveMQ (the file-system Cursor seems like it would work nicely, but appears to only be configurable from the XML files, whereas
I use ActiveMQ and programatically configure it).

Each time I want to send a message to the server from my client I create a new Producer, send the message and close the producer. One of my co- workers
said that he thinks that this sounds like an anti-pattern. After using
JProfiler and seeing how many ProducerId objects are created (and don't
appear to be garbage collected).

So my question is: Should I be creating one producer per queue/topic and
re-using it, or am I able to create one-per-request?

Cheers,

Aidan
--
View this message in context: 
http://www.nabble.com/What-is-best-practice-for-creating-Producers--tp16760359s2354p16760359.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Say thanks to your co-worker! It is an anti-pattern.

Please re-use your producers - you don't even need one per destination - create a Producer with a null Destination - e.g.

Message producer = session.createProducer(null)




cheers,

Rob

http://open.iona.com/ -Enterprise Open Integration
http://rajdavies.blogspot.com/



Reply via email to