Crate libmqm_sys

Source
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

  1. Download and install the redistributable client from IBM: https://ibm.biz/mq94redistclients

  2. Install the client in /opt/mqm or another location.

  3. Set the MQ_HOME environment variable to the installed location.

    MQ_HOME=/opt/mqm
  4. Add the libmqm_sys crate to your project:

    cargo add libmqm_sys
  5. 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 folder
  • dlopen2 — Enable runtime loading of the MQI library using dlopen2
  • link (enabled by default)Link the MQI library at compile time
  • mqi_helpers (enabled by default) — Compile the string and stuct initialisers from the MQI C headers
  • pcf — Enable structures for PCF
  • exits — Enable structures for exits
  • mqai — Enable structures and constants for MQAI
  • bindgen — Use bindgen to generate bindings
  • versiongen — Generate version file from MQC library
  • mqc_9_2_0_0 (enabled by default) — Minimum MQ client version 9.2.0.0
  • mqc_9_4_2_0 — Minimum MQ client version 9.4.2.0
  • mqc_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

Traits§

Exits
Mqai
IBM® MQ Administration Interface (MQAI) function calls
Mqi
IBM® MQ Interface (MQI) function calls