Skip to content
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

Merged
merged 7 commits into from
Dec 10, 2018
Merged

Callback #70

merged 7 commits into from
Dec 10, 2018

Conversation

ibmmqmet
Copy link
Collaborator

@ibmmqmet ibmmqmet commented Dec 4, 2018

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.

@ibmmqmet ibmmqmet requested a review from parrobe December 4, 2018 09:03
@@ -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
Copy link
Member

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?

Copy link
Collaborator Author

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
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@parrobe parrobe merged commit f9bbbef into master Dec 10, 2018
@parrobe parrobe deleted the callback branch December 10, 2018 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants