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_HOME environment 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 std::ptr::addr_of_mut;
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::MQCHAR; 48] = [32; 48]; // All spaces = default qmgr
unsafe {
lib::MQCONN(
addr_of_mut!(qmgr).cast(),
addr_of_mut!(hconn),
addr_of_mut!(comp_code),
addr_of_mut!(reason),
);
assert_eq!(reason, lib::MQRC_NONE, "MQRC");
assert_eq!(comp_code, lib::MQCC_OK, "MQCC");
lib::MQDISC(addr_of_mut!(hconn), addr_of_mut!(comp_code), addr_of_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 timemqi_helpers(enabled by default) — Compile the string and stuct 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_2_0— Minimum MQ client version 9.4.2.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
- Constants, types and structures generated by bindgen from the MQ client C library
- link
- Compile time linking of the MQI library
- version