• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS Performance issue  RSS feed

 
Ghulam Rashid
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • 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
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!