Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What is the best way to pull the messages from MQ queue.

Posted on 2014-04-03
7
Medium Priority
?
468 Views
Last Modified: 2014-04-07
I have written a C# Win service to pull the messages from Websphere MQ queue. I have a question here on the approach to be followed.

1. Open the connection only once to the queue and pull all the messages and keep checking for the messages forever and never close the connection.

2. Establish the connection to queue and then pull the message and then close it immediately. And do the same for every message.

What is the best way? And why?

I have opeted the 2nd one, but one of my friend suggest the 1st one. Please suggest me which is the best way.
0
Comment
Question by:GouthamAnand
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 500 total points
ID: 39975671
I would go with the first option as there is no need to keep connecting and disconnecting, plus the is a lot of additional overhead with doing so. I'd only consider closing the connection each time if there is any chance of hitting the concurrent connection limit.
0
 
LVL 16

Assisted Solution

by:Easwaran Paramasivam
Easwaran Paramasivam earned 500 total points
ID: 39975849
It depends. If your frequency to hit MSMQ is less then go for second option. Otherwise choose first option.

One more point is that if your MSMQ is being modified rarely then better save the result of first hit in a Cache object. So that you no need to read each time the MSMQ.

Analyze based on your requirement and go for it. There is no hard rule to say which one is correct approach.
0
 
LVL 35

Accepted Solution

by:
Gary Patterson earned 800 total points
ID: 39977566
In a high-volume application, option 1 is probably "more right".

Repeatedly opening and closing a connection creates overhead on both the client and the server.

When using this model, you'd MQGET with a relatively long or unlimited timeout interval (read the docs if you use MQ from IMS apps).  MQGET blocks on an empty queue, so you don't burn a lot of CPU while waiting for the next entry.  If you MQGET with a short timeout, you burn a lot of cycles dealing with NO_MSG_AVAILABLE.

Only close if you are shutting the application down or need to disconnect for some reason.

In a low volume application, it doesn't make that much difference, but remember that low-volume applications have a tendency to occasionally and suddenly become high volume applications.
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 5

Assisted Solution

by:lgacs
lgacs earned 200 total points
ID: 39980499
Previous comments are correct, but ...

If the queue manager is remote, you must manage connection failures in case 1 or choose case 2 if performance is not a key issue.
0
 
LVL 35

Expert Comment

by:Gary Patterson
ID: 39980645
Why would you design-in poor performance to an application?
0
 
LVL 5

Expert Comment

by:lgacs
ID: 39983418
Reliability first !
0
 

Author Closing Comment

by:GouthamAnand
ID: 39983648
Thanks a lot to every one for replying to my question.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question