You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Peter Steil <pe...@gmx.net> on 2007/04/24 09:59:41 UTC

Connection pooling

Hi,

I am using release 4.1.1 and I am wondering whether or not TopicConnections are pooled automatically somehow. I have quite a lot TopicPublisher who publish to different topics. Should I keep one TopicConnection open and use it for all TopicSessions or should I open and close the connections each time?

Thanks,
Peter 
-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail

Re: Connection pooling

Posted by James Strachan <ja...@gmail.com>.
On 4/24/07, Daniel Gradecak <da...@gradecak.com> wrote:
>
> > BTW thats really intended for folks who are using the JMS API directly
> > rather than JmsTemplate
> >
> So for better performances it is better to use the API directly ?

Yes


> > No you can't. JmsTemplate creates/closes all the JMS resources each
> > time so you're only hope is to use only sending along with
> > PooledConnectionFactory, or Jencks
> I didnt really get. Do you mean that as I configured it, it will be done
> by Jencks out of the box, or should I
> use directly the JcaPooledConnectionFactory without using JmsTemplate ?
>
> Sorry for my not understanding :) It is just that after too much
> readings sometimes I cant see the finger in front of my nose.
> I would just like to be sure I am not doing it wrong.

I totally understand. Unfortunately the JMS API is kinda complex;
particulary when it comes to pooling as there are various options and
issues to consider.

-- 
James
-------
http://macstrac.blogspot.com/

Re: Connection pooling

Posted by Daniel Gradecak <da...@gradecak.com>.
> BTW thats really intended for folks who are using the JMS API directly
> rather than JmsTemplate
>
So for better performances it is better to use the API directly ?

> No you can't. JmsTemplate creates/closes all the JMS resources each
> time so you're only hope is to use only sending along with
> PooledConnectionFactory, or Jencks
I didnt really get. Do you mean that as I configured it, it will be done 
by Jencks out of the box, or should I
use directly the JcaPooledConnectionFactory without using JmsTemplate ?

Sorry for my not understanding :) It is just that after too much 
readings sometimes I cant see the finger in front of my nose.
I would just like to be sure I am not doing it wrong.

Daniel.

Re: Connection pooling

Posted by James Strachan <ja...@gmail.com>.
On 4/24/07, Daniel Gradecak <da...@gradecak.com> wrote:
> I wonder if if this configuration does the pooling correctly?
>
>    <bean id="jmsResourceAdapter"
> class="org.apache.activemq.ra.ActiveMQResourceAdapter">
>        <property
> name="serverUrl"><value>${jms.brokerUrl}</value></property>
>      </bean>
>
>    <bean id="transactionManager"
> class="org.jencks.factory.TransactionManagerFactoryBean">
>        <property
> name="defaultTransactionTimeoutSeconds"><value>${jms.transaction.timeout}</value></property>
>
>    </bean>
>
>    <bean id="connectionFactory"
> class="org.jencks.amqpool.JcaPooledConnectionFactory">
>
> <constructor-arg><value>${jms.brokerUrl}</value></constructor-arg>
>        <property name="transactionManager" ref="transactionManager"/>
>        <property
> name="maxConnections"><value>${jms.pool.maxConnections}</value></property>
>    </bean>
>      <bean id="jmsTemplate"
> class="org.springframework.jms.core.JmsTemplate">
>        <property name="connectionFactory" ref="connectionFactory"/>
>        <property
> name="receiveTimeout"><value>${jms.receive.timeout}</value></property>
>    </bean>
>

Looks fine to me.


> Here (http://activemq.apache.org/how-do-i-use-jms-efficiently.html) it
> is suggested that "you can reuse the same MessageProducer for sending
> messages to different destinations" which seems ok.

BTW thats really intended for folks who are using the JMS API directly
rather than JmsTemplate


> But I wonder if JmsTemplate is doing that correctly with the
> org.jencks.amqpool.JcaPooledConnectionFactory? I thought that
> JmsTemplate was creating a new producer/receiver each time

it does

> , please
> tell me I am wrong. If so, could I somehow configure that with JmsTemplate?

No you can't. JmsTemplate creates/closes all the JMS resources each
time so you're only hope is to use only sending along with
PooledConnectionFactory, or Jencks


-- 
James
-------
http://macstrac.blogspot.com/

Re: Connection pooling

Posted by Daniel Gradecak <da...@gradecak.com>.
I wonder if if this configuration does the pooling correctly?

   <bean id="jmsResourceAdapter" 
class="org.apache.activemq.ra.ActiveMQResourceAdapter">
       <property 
name="serverUrl"><value>${jms.brokerUrl}</value></property>
     </bean>

   <bean id="transactionManager" 
class="org.jencks.factory.TransactionManagerFactoryBean">
       <property 
name="defaultTransactionTimeoutSeconds"><value>${jms.transaction.timeout}</value></property> 

   </bean>
 
   <bean id="connectionFactory" 
class="org.jencks.amqpool.JcaPooledConnectionFactory">
       
<constructor-arg><value>${jms.brokerUrl}</value></constructor-arg>   
       <property name="transactionManager" ref="transactionManager"/>
       <property 
name="maxConnections"><value>${jms.pool.maxConnections}</value></property>
   </bean>
     <bean id="jmsTemplate" 
class="org.springframework.jms.core.JmsTemplate">
       <property name="connectionFactory" ref="connectionFactory"/>
       <property 
name="receiveTimeout"><value>${jms.receive.timeout}</value></property>
   </bean>

Here (http://activemq.apache.org/how-do-i-use-jms-efficiently.html) it 
is suggested that "you can reuse the same MessageProducer for sending 
messages to different destinations" which seems ok.
But I wonder if JmsTemplate is doing that correctly with the 
org.jencks.amqpool.JcaPooledConnectionFactory? I thought that 
JmsTemplate was creating a new producer/receiver each time, please
tell me I am wrong. If so, could I somehow configure that with JmsTemplate?

Regards,
Daniel

James Strachan wrote:
> On 4/24/07, Peter Steil <pe...@gmx.net> wrote:
>> Hi,
>>
>> I am using release 4.1.1 and I am wondering whether or not 
>> TopicConnections are pooled automatically somehow.
>
> No.
>
>> I have quite a lot TopicPublisher who publish to different topics. 
>> Should I keep one TopicConnection open and use it for all 
>> TopicSessions or should I open and close the connections each time?
>
> http://activemq.apache.org/how-do-i-use-jms-efficiently.html
>
> so typically use 1 connection and have a pool of consumers (maybe via
> MDBs or Jencks or Springs MessageListenerContainers) then use a pool
> of session/producers either through ActiveMQ's PooledConnectionFactory
> with Spring's JmsTemplate or just use one producer and synchronize on
> it
>
> http://cwiki.apache.org/ACTIVEMQ/how-do-i-send-messages-to-different-destinations-from-a-single-messageproducer.html 
>
>
>

Re: Connection pooling

Posted by James Strachan <ja...@gmail.com>.
On 4/24/07, Peter Steil <pe...@gmx.net> wrote:
> Hi,
>
> I am using release 4.1.1 and I am wondering whether or not TopicConnections are pooled automatically somehow.

No.

> I have quite a lot TopicPublisher who publish to different topics. Should I keep one TopicConnection open and use it for all TopicSessions or should I open and close the connections each time?

http://activemq.apache.org/how-do-i-use-jms-efficiently.html

so typically use 1 connection and have a pool of consumers (maybe via
MDBs or Jencks or Springs MessageListenerContainers) then use a pool
of session/producers either through ActiveMQ's PooledConnectionFactory
with Spring's JmsTemplate or just use one producer and synchronize on
it

http://cwiki.apache.org/ACTIVEMQ/how-do-i-send-messages-to-different-destinations-from-a-single-messageproducer.html


-- 
James
-------
http://macstrac.blogspot.com/