On Wed, Apr 7, 2010 at 5:12 AM, mattcodes <m...@mattfreeman.co.uk> wrote:
>
> In a (ASP.Net/c#) web-app I want to pump messages to an ActiveMQ queue
> (nothing complicated - no native transactions etc..). Reading various FAQs
> etc.. I figure I should create a pool of say 50 message producers, each with
> their own session and own connection for the best performance. i.e. a 1 to 1
> relation between producer --> session and session --> connection. Is this
> the optimal setup? When would this be problematic?  Obviously Id have to
> implement the pooling myself since there's no ActiveMQ pool lib for .Net?
>
> Alternatively I thought about pooling Session (with 1to1 with connection)
> and then creating the producer on each request? The overhead of this is
> about 9ms I tested, which isnt that far off pulling from a pool,

The problem with what you are proposing is that it won't scale very
well. Creating connections, sessions and producers in a 1:1 ratio is
inappropriate because the overhead of both is rather high. It's
actually better to use one connection to create many sessions and only
increasing the number of connections if it is deemed necessary. This
is the model used by most JMS pooling connection factories and most
messaging middleware works very well with this model.

Here is an example of what I recommend to folks for sending messages:

http://bsnyderblog.blogspot.com/2010/02/using-spring-jmstemplate-to-send-jms.html

This example uses the Spring Framework to send JMS messages. Let me
know if you have any questions.

Bruce
-- 
perl -e 'print 
unpack("u30","D0G)u8...@4vyy9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Reply via email to