ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Coding Automatic Reconnect Logic

Post new topic  Reply to topic
 Coding Automatic Reconnect Logic « View previous topic :: View next topic » 
Author Message
PeterPotkay
PostPosted: Thu Sep 16, 2004 3:44 pm    Post subject: Coding Automatic Reconnect Logic Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu Sep 16, 2004 5:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
PeterPotkay
PostPosted: Thu Sep 16, 2004 6:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
kevinf2349
PostPosted: Fri Sep 17, 2004 5:21 am    Post subject: Reply with quote

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
View user's profile Send private message
PeterPotkay
PostPosted: Fri Sep 17, 2004 5:28 am    Post subject: Reply with quote

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
View user's profile Send private message
kevinf2349
PostPosted: Tue Sep 21, 2004 9:31 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Coding Automatic Reconnect Logic
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.