You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Ishitori <Is...@bk.ru> on 2011/07/07 17:07:28 UTC

IMessageProducer and IMessageConsumer lifecycle best practices

Hello everyone.

I use Apache.NMS and its two main interfaces: IMessageProducer and
IMessageConsumer. I have created a wrapper on a IMessageProducer and
IMessageConsumer, so my system wouldn't know that ActiveMQ is used
underneath.

I can implement wrappers using following scenario:

1. I can create IMessageProducer in constuctor of the wrapper. When client
code calls my wrapper SendMessage method I will just redirect it to Send
method of the IMessageProducer.

2. I can create IMessageProducer on the fly when my wrapper SendMessage
method is called. After creating I call IMessageProducer.Send method 

So, basically in the first case I have a connection opened all the time, but
I save some time on creating objects, when in the latter case I open a
connection for a short period of time, but at the same time I have to create
everything from the scratch.

What solution is more preferable? The same quesion is for the
IMessageConsumer and Receive method.

--
View this message in context: http://activemq.2283324.n4.nabble.com/IMessageProducer-and-IMessageConsumer-lifecycle-best-practices-tp3651760p3651760.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.