You'd need some sort of stale connection checking. If you combined commons-pool2 with the JMS API, you could make a simple connection pool that uses ConnectionFactory to create new connection objects. This library has a bunch of pooling concepts already coded in (like activating/passivating, borrowing from the pool, returning to the pool, abandoned object timeouts, etc.), so it shouldn't be too hard to implement, really. I tried it out myself and it seems almost *too* straightforward!
On 22 July 2014 06:50, Ali, Mohammad <[email protected]> wrote: > Thanks for your reply Matt. I have tried using CachingConnectionFactory > and now it creates only one connection. But the issue with this is when I > stop the camel route, I can see the connection is still open in the IBM MQ > explorer. Also when I restart the camel route again it creates a new > connection again and with every restart the connection count increases. To > release the connection I have to restart my application. > Is there a way where I can explicitly close the session when I am stopping > the camel route? > > > Regards, > Shadab > > > -----Original Message----- > From: Matt Sicker [mailto:[email protected]] > Sent: Monday, July 21, 2014 8:09 PM > To: Camel Users > Subject: Re: JMS producer creating connection for every message causing > performance issue > > The CachingConnectionFactory should keep a single Connection open that is > returned by that factory. I'm not sure on the specifics, but it should do > at least what you were originally asking about maintaining a single > Connection. > > > On 21 July 2014 02:18, Ali, Mohammad <[email protected]> wrote: > > > Hi, > > > > Mine is a standalone application, it's not EJB managed. I am using IBM > > Websphere MQ as JMS provider, and read in IBM forum that from WAS-7 > > IBM has removed its connection pooling classes. > > Will wrapping the IBM connection factory class in spring provided > > CachingConnectionFactory will do connection pooling? > > > > Regards, > > Shadab > > > > -----Original Message----- > > From: Matt Sicker [mailto:[email protected]] > > Sent: Saturday, July 19, 2014 1:22 AM > > To: Camel Users > > Subject: Re: JMS producer creating connection for every message > > causing performance issue > > > > There's a bunch of info on this page about that: > > http://activemq.apache.org/jmstemplate-gotchas.html > > > > In short, unless the javax.jms.ConnectionFactory object you're using > > is using connection pooling, you need to do something special. > > > > Is your ConnectionFactory an EJB-managed implementation? If you're on > > WebSphere, it should be. > > > > > > On 18 July 2014 12:12, Ali, Mohammad <[email protected]> wrote: > > > > > Hi Matt, > > > > > > I am using camel-jms. > > > > > > Regards, > > > Shadab > > > > > > -----Original Message----- > > > From: Matt Sicker [mailto:[email protected]] > > > Sent: Friday, July 18, 2014 10:17 PM > > > To: Camel Users > > > Subject: Re: JMS producer creating connection for every message > > > causing performance issue > > > > > > Are you using camel-jms or camel-sjms? > > > > > > > > > On 18 July 2014 08:39, Ali, Mohammad <[email protected]> > wrote: > > > > > > > Hi, > > > > > > > > We are using camel JMS component(producer) to send message to IBM > > > > MQ and using camel 2.9.0 version. We observe that JMS producer is > > > > creating connection with every message which is hitting the > > > > performance badly. Is there any option to set so that same > > > > connection will be used for evary message? > > > > > > > > > > > > Thanks & Regards, > > > > Shadab > > > > > > > > This e-mail (and any attachments), is confidential and may be > > privileged. > > > > It may be read, copied and used only by intended recipients. > > > > Unauthorized access to this e-mail (or > > > > attachments) and disclosure or copying of its contents or any > > > > action taken in reliance on it is unlawful. Unintended recipients > > > > must notify the sender immediately by e-mail/phone & delete it > > > > from their system without making any copies or disclosing it to a > third person. > > > > > > > > > > > > > > > > > -- > > > Matt Sicker <[email protected]> > > > > > > This e-mail (and any attachments), is confidential and may be > privileged. > > > It may be read, copied and used only by intended recipients. > > > Unauthorized access to this e-mail (or > > > attachments) and disclosure or copying of its contents or any action > > > taken in reliance on it is unlawful. Unintended recipients must > > > notify the sender immediately by e-mail/phone & delete it from their > > > system without making any copies or disclosing it to a third person. > > > > > > > > > > > > -- > > Matt Sicker <[email protected]> > > > > This e-mail (and any attachments), is confidential and may be privileged. > > It may be read, copied and used only > > by intended recipients. Unauthorized access to this e-mail (or > > attachments) and disclosure or copying of its contents or any action > > taken in reliance on it is unlawful. Unintended recipients must notify > > the sender immediately by e-mail/phone & delete it from their system > > without making any copies or disclosing it to a third person. > > > > > > > -- > Matt Sicker <[email protected]> > > This e-mail (and any attachments), is confidential and may be privileged. > It may be read, copied and used only > by intended recipients. Unauthorized access to this e-mail (or > attachments) and disclosure or copying of its > contents or any action taken in reliance on it is unlawful. Unintended > recipients must notify the sender immediately > by e-mail/phone & delete it from their system without making any copies or > disclosing it to a third person. > > -- Matt Sicker <[email protected]>
