• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JMS Performance issue

 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My application has JMS performance issue, by EOD we run into out of connection. Below is the code, which is called for every request. I definitely have to reuse some piece of code.

try
{
queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();

queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queueSender = queueSession.createSender(queue);
message = queueSession.createTextMessage();
message.setText("This is a sample JMS message.");
System.out.println("Sending message: " + message.getText());
queueSender.send(message);

}
catch (JMSException e)
{
System.out.println("Exception occurred: " + e.toString());
}



Do, we really need to call
queueConnection = queueConnectionFactory.createQueueConnection();
for every request. I am thinking to cache and reuse below line of code.

queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();

Also, I am thinking to reuse JMS Session, rather than creating for every request.

Any thought will be appreciated.

Thanks
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the code you posted, i dont see any place where you are closing the connection after sending the message. Did you miss that out in your post or are you not closing it even in the actual code?
 
Ghulam Rashid
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Off course not. My emphasis was on reusing the below code.
queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

My application has JMS performance issue, by EOD we run into out of connection



The reason why i asked whether you are closing the connection, was based on what you mentioned in your first. You said that you run out of connections - which might be because you are not closing the connection after you send the messages.

My emphasis was on reusing the below code.



And going by what you mentioned in your second post, i am a bit confused.
1) Are you trying to refactor the code to reuse that piece of code?
2) Or are you trying to fix an issue where you are running out of connections?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic