ibm-messaging / mq-golang

Calling IBM MQ from Go applications
Apache License 2.0
168 stars 60 forks source link

Add IsValid() method to MQQueueManager #158

Closed ravellan closed 3 years ago

ravellan commented 3 years ago

Please ensure all items are complete before opening.

What

Added an IsValid method to the MQQueueManager type

How

Since the underlying hConn in MQQueueManager is not exported a convenience method is added to check if the hConn is still valid or has been set to MQHC_UNUSABLE_HCONN

Testing

Test is added in package test suite.

Issues

N/A

ibmmqmet commented 3 years ago

I have to ask where you think this might be used? The hconn is only ever changed after a connect or disconnect. So it can't be used, for example, to check that a client connection is still alive just before an MQPUT.

ravellan commented 3 years ago

It goes along the lines that a connection is shared by multiple goroutines and one of them might respond to a connection broken with a disconnect and then create a new one. This could of course be handled in different ways but I thought it would be convenient to check if a conn has been disconnected and if so get a new one in the other routine before using it. If this doesn't sound like a good practice I'm fine with rejecting this.

ibmmqmet commented 3 years ago

I think I am going to decline this one. It's not how MQ apps are normally expected to work - it would be more normal to set the variable to nil (or something like that) after doing a disconnect in the application.