Expand description
Bindings to the IBM® MQ Interface (MQI), Programmable Command Format (PCF) and MQ Administration Interface (MQAI) C libraries.
§Overview
You can use libmqm_sys to:
- Connect to an IBM MQ server to send and receive MQ messages through the MQI functions
- Administer IBM MQ server through the PCF structures and MQAI functions
Compile time dynamic linking and run-time dynamic linking is supported.
Developers must download the MQI library directly from IBM. Refer to the Usage instructions.
§Safety
Functions provided in this crate are the raw unsafe functions exposed from the
IBM provided library. Developers should build safe rust API wrappers over these functions.
Developers who do not want to use the unsafe API should use the
mqi crate for a safe API over the MQI.
§Usage
-
Download and install the redistributable client from IBM: https://ibm.biz/mq94redistclients
-
Install the client in
/opt/mqmor another location. -
Set the
MQ_HOMEenvironment variable to the installed location.MQ_HOME=/opt/mqm -
Add the
libmqm_syscrate to your project:cargo add libmqm_sys -
Use the crate in your source code:
use libmqm_sys as mqsys;
§Example
use libmqm_sys::lib;
let mut hconn = lib::MQHC_DEF_HCONN;
let mut comp_code = lib::MQCC_UNKNOWN;
let mut reason = lib::MQRC_NONE;
let mut qmgr: lib::MQCHAR48 = [32; 48]; // All spaces = default qmgr
unsafe {
lib::MQCONN(
&qmgr,
&mut hconn,
&mut comp_code,
&mut reason,
);
assert_eq!(reason, lib::MQRC_NONE, "MQRC");
assert_eq!(comp_code, lib::MQCC_OK, "MQCC");
lib::MQDISC(&mut hconn, &mut comp_code, &mut reason);
};§Features
pregen— Generate the bindings and save them in the src folderdlopen2— Enable runtime loading of the MQI library usingdlopen2link(enabled by default) —Linkthe MQI library at compile timeconstant_lookup— Compile the string lookup functions from the MQI C headersstruct_defaults— Compile the struct initialisers from the MQI C headerspcf— Enable structures for PCFexits— Enable structures for exitsmqai— Enable structures and constants for MQAIbindgen— Usebindgento generate bindingsversiongen— Generate version file from MQC librarymqc_9_2_0_0(enabled by default) — Minimum MQ client version 9.2.0.0mqc_9_4_3_0— Minimum MQ client version 9.4.3.0mqc_latest— Minimum MQ client version to the latest released
Minimum MQ client can be set using the mqc_* features
Modules§
- dlopen2
- Dynamic loading of the MQI library using dlopen2
- lib
- link
- Compile time linking of the MQI library