Crates.io | mqi |
lib.rs | mqi |
version | 0.3.0 |
created_at | 2024-09-10 02:36:25.548843+00 |
updated_at | 2025-07-23 12:57:45.619891+00 |
description | Idiomatic IBM® MQ Interface (MQI) and MQ Administration Interface (MQAI) APIs |
homepage | |
repository | https://github.com/advantic-au/mqi |
max_upload_size | |
id | 1369996 |
size | 616,925 |
The mqi
crate provides idiomatic Rust APIs for the IBM® MQ Interface (MQI) and MQ Administration Interface (MQAI). IBM MQ is an enterprise-grade message queuing system that enables reliable, secure, and asynchronous data exchange between applications, systems, and services.
This crate enables Rust developers to interact with IBM MQ servers, leveraging the powerful and stable IBM MQ libraries.
Download and install the client from IBM:
Extract and install the MQ client in any location.
Set the MQ_HOME environment variable to the installed location.
Add the mqi
crate to your project:
cargo add mqi
Ensure the MQ libraries are in the library search path. On Linux, this can
be achieved by setting the LD_LIBRARY_PATH
environment variable.
An easy way of running an MQ server for development and testing is to run the IBM supplied docker container:
docker run -d --publish 1414:1414 icr.io/ibm-messaging/mq:latest
Refer to https://github.com/ibm-messaging/mq-container/blob/master/docs/usage.md
Connect to the default queue manager using the MQSERVER
environment variable with username and password authentication.
use std::error::Error;
use mqi::{
connection::{Credentials, ThreadNone},
prelude::*,
types::{ApplName, QueueName},
};
fn main() -> Result<(), Box<dyn Error>> {
const TARGET: QueueName = QueueName(mqstr!("DEV.QUEUE.1"));
// User credentials and application name.
// MQI will use the C API defaults, referring to MQSERVER environment variable if set.
let connect_options = (
ApplName(mqstr!("readme_example")),
Credentials::User("user", "password".into()),
);
// Connect to the queue manager. Make all MQ warnings as a rust Result::Err
let queue_manager = mqi::connect::<ThreadNone>(&connect_options).warn_as_error()?;
// Put a single string message on the target queue. Discard any warnings.
queue_manager.put_message(&TARGET, &(), "Hello").discard_warning()?;
// Queue manager disconnect - this also happens automatically on Drop.
queue_manager.disconnect().discard_warning()?;
Ok(())
}
Refer to the examples folder for comprehensive examples that cover reading and putting messages to a queue, using transactions and working with topics.
Feature | Default | Description |
---|---|---|
link | ✔ | Support linking the MQ library at compile-time |
dlopen2 | Support loading the MQ library at run-time using dlopen2 |
|
tracing | Add tracing to the MQI and MQAI calls using the tracing crate | |
mqai | Expose functions and structures related to MQAI | |
exits | Expose functions and structures related to MQ exits | |
mqc_* | mqc_9_2_0_0 | Enable features of a specific MQI library version eg mqc_9_4_1_0 |
mqc_*
feature flags.This library is under heavy development. The velocity of change to the API is high and is likely to evolve. See the progress page for the progress on the list of MQI functions exposed.
There are no guarantees of compatibility with any future versions of the crate; the API is subject to change based on feedback and enhancements. Relentless refactoring may occur before a stable crate is released.
This crate is provided as-is with no guarantees of support or updates.
This crate is not approved, endorsed, acknowledged, or supported by IBM. You cannot use IBM formal support channels (Cases/PMRs) for assistance on the use of this crate.
All feedback, suggestions, contributions and enhancements are welcome.
Licensed under