-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback #70
Conversation
@@ -248,7 +252,7 @@ func (x *MQQueueManager) Open(good *MQOD, goOpenOptions int32) (MQObject, error) | |||
} | |||
|
|||
copyODtoC(&mqod, good) | |||
mqOpenOptions = C.MQLONG(goOpenOptions) | |||
mqOpenOptions = C.MQLONG(goOpenOptions) | C.MQOO_FAIL_IF_QUIESCING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we always setting MQOO_FAIL_IF_QUIESCING
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FAIL_IF_QUIESCING should always be set - it's one of the big complaints about it not being a default. There's no good reason not to use it in applications. So forcing it here makes user applications - and the sample programs - simpler as they don't need to think about it (assuming they ever did, and then wondered why qmgrs didn't end cleanly or restart). I did similar in the Node.js implementation based on user feedback.
Yes, the code could return "key" directly but setting a variable made it easier to insert Printfs during debug.
mqcbd.Version = C.MQCBD_VERSION_1 | ||
|
||
mqcbd.CallbackType = C.MQLONG(gocbd.CallbackType) | ||
mqcbd.Options = C.MQLONG(gocbd.Options) | C.MQCBDO_FAIL_IF_QUIESCING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Always setting MQCBDO_FAIL_IF_QUIESCING
// Functions below here manage the map of objects and control information so that | ||
// the Go variables can be saved/restored from invocations to the C layer | ||
func makeKey(hConn C.MQHCONN, hObj C.MQHOBJ) string { | ||
key := fmt.Sprintf("%d/%d", hConn, hObj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could just do: return fmt.Sprintf("%d/%d", hConn, hObj)
instead of setting variable to return it.
} | ||
|
||
func makePartialKey(hConn C.MQHCONN) string { | ||
key := fmt.Sprintf("%d/", hConn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Please ensure all items are complete before opening.
What
Added MQCB/MQCTL implementation
Added MQBEGIN to complete the set
Modified sample programs for more appropriate coding.
How
Follow usual pattern for new structures. Wrap the user-supplied callback function with a Go function which in turn is wrapped by a C function. Go callbacks from C are not very well documented, but this works.
Sample programs updated to use "defer" instead of simply suggesting them, to encourage better design. FAIL_IF_QUIESCING no longer needed in user apps as it will get set automatically.
Testing
New sample amqscb demonstrates the callback mechanism
How to test your changes work, not required for documentation changes.
Issues
Links to the github issue(s) (if present) that this pull request is resolving.