Author |
Message
|
PeterPotkay |
Posted: Thu Sep 16, 2004 3:44 pm Post subject: Coding Automatic Reconnect Logic |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
Since my coding days began by learning COBOL, I am little dense here on the best way to code robust reconnect logic for an MQClient app. I want to code it in VB.NET.
I am thinking the below psuedo code well get me what I need. Comments?
Code: |
Do Until App is Closed
Try
Create QM Object
Create Q Object
Do While Errors Flag not set and app is up
Try
Issue MQGET with 30 second wait
Proccess the message
End Try
Catch
Set Error Flag if not 2033
End Catch
End Do
End Try
Catch
Display MQ Error
Close Queue
Disconnect from QM
End Catch
End Do
|
_________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Sep 16, 2004 5:14 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What happens when you try it?
I'd put the Create QM Object in it's own try/catch block. If that doesn't work, you don't want to try and close the queue or disconnect from the queue manager...
Likewise with the Create Queue Object.
In fact, you may want to put those outside the "while application is up" loop, or at least make sure you have the option of closing the application in a case where you are reasonably sure that you have reached a situation where the QM or Q can't be opened without manual intervention... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Thu Sep 16, 2004 6:37 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
Quote: |
What happens when you try it?
|
cuz I'm a procrastinator and since I am not sure of the design, I use it as an excuse to do it tomorrow. Ive been saying this for the past month. I code about once a year when I come up with an idea for something, and then spend most of that time trying to figure my syntax errors. I figured I'd get a good design to start.
Quote: |
In fact, you may want to put those outside the "while application is up" loop,
|
But if I move the QM create and the Q create outside of the loop, then what will cause the code to retry the connection (start all over) on error?
Quote: |
I'd put the Create QM Object in it's own try/catch block. If that doesn't work, you don't want to try and close the queue or disconnect from the queue manager...
|
How 'bout this?
Code: |
Do Until App is Closed
Try
Create QM Object
Try
Create Q Object
Do While Errors Flag not set and app is up
Try
Issue MQGET with 30 second wait
Proccess the message
End Try
Catch
If not 2033
Set Error Flag
Close the Queue
EndIf
End Catch
End Do
EndTry
Catch
Disconnect from the QM
End Catch
End Try
Catch
Display MQ Error
End Catch
End Do |
_________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
kevinf2349 |
Posted: Fri Sep 17, 2004 5:21 am Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Peter,
Just an idea......Couldn't you catch the 'break in communciations error' on the GET and then attempt the reconnect from there? |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Sep 17, 2004 5:28 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
You mean also put the QM and Q creation logic in the catch of the MQGET, and don't set the error flag? _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
kevinf2349 |
Posted: Tue Sep 21, 2004 9:31 am Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Hi Peter
Sorry for the delay in replying....I had a work interrupt...which is fair enough as they are generous enough to pay me to have this much fun!
That was the sort of thing I meant, but thinking a little more about it you would still have to re-open the queue anyway so there would appear to be little benefit in doing how I suggested....other than being able to be more specific on the cause of the error.
As your pseudo-code stands it looks like you are going process the error in the same manner regardless of what it is (other than the 2033). Is that the intention? |
|
Back to top |
|
 |
|