• Stars
    star
    181
  • Rank 212,110 (Top 5 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Code samples and messaging patterns for IBM MQ developers

Issue Support

The code in this repository, is provided and maintained on a community basis, and is not covered by any IBM commercial support agreement or warranty.

For issues and fixes please just raise an issue against this repository.

IBM MQ samples and patterns

When your application needs messaging, you don't want to spend countless hours learning the basics, you want to jump straight in and play, see how things work.

We have taken parts that make up the current set of our IBM MQ samples and built applications that you can use to do just that.

You'll find put/get, pub/sub, request/response samples that you can run in the same language or you can try mixing things up and do a put in Java, get with Go etc.

There is a README for each language that helps you with the initial setup.

You need an MQ server with a queue or topic to run these samples against. To find out more about what MQ is and how it works, start from LearnMQ.

To get your MQ server set up, check out Ready, Set, Connect.

You can use your own MQ server, you'll just have to adjust the MQ objects accordingly so they match on both the server and the client side.

  • HOST - Host name or IP address of your queue manager
  • PORT - Listener port for your queue manager
  • CHANNEL - MQ channel name
  • QMGR - Queue manager name
  • APP_USER - User name that application uses to connect to MQ
  • APP_PASSWORD - Password that the application uses to connect to MQ
  • QUEUE_NAME - Queue name for put/get, request/response
  • TOPIC_NAME - Topic for publish/subscribe
  • MODEL_QUEUE_NAME - Model Queue used as template to base dynamic queues on for request/response
  • DYNAMIC_QUEUE_PREFIX - Prefix for dynamically created reply queue - you don't need to create this
  • CIPHER_SPEC - If present in the env,json, TLS Cipher specification to use
  • KEY_REPOSITORY - Path to the keystore .kbd and .sth files. If running on Apple Silicon then this will the path to the queue manager's exported .pem. If present in the env.json, TLS is enabled - this is on the app side.

If instead you choose to provide a client channel definition table (CCDT) file, then the Host, PORT, Channel and Cipher are provided by the CCDT and you can leave them out of the env.json. All the samples check if the environment variable MQCCDTURL is set and that the file it is pointing at exists. If it does then the logic sets the connection definition or connection factory to for CCDT processing. For example

export MQCCDTURL=file:///Users/xyz/Documents/dev/mqsamples/mq-dev-patterns/ccdt.json

We give you a sample ccdt.json from which you can base your own.

If you use our MQ server for developers in Docker, Linux or Windows, with the default config, you'll have the following MQ objects on the MQ server;

Host - localhost
Port - 1414 - Non TLS
Channel - DEV.APP.SVRCONN
Queue manager - QM1
App user - app (member of mqclient group)
App password - passw0rd (you can set your own when running the Docker container, MQ_APP_PASSWORD)
Queue - DEV.QUEUE.1
Topic - dev/
Cipher suite - TLS_RSA_WITH_AES_128_CBC_SHA256

Model queue and MQ container image

The default configuration for MQ objects that you get with our Docker container does not include a model queue.

We use a model queue in the request/response pattern as a template for the request application to create a temporary reply queue.

You can use the MQ Web Console to create the model queue. Access the MQ Web Console for your MQ running as a container at https://localhost:9443/ibmmq/console/. You can log in with the default admin details or your own, if you made changes.

Environment variables

All the samples make use of the same environment variables to define MQ connection settings - these match the default developer config objects on the MQ server.

We've tried to make this easier by providing one env.json file in the main samples directory;

{
  "MQ_ENDPOINTS": [{
    "HOST":"localhost",
    "PORT":"1414",
    "CHANNEL":"DEV.APP.SVRCONN",
    "QMGR":"QM1",
    "APP_USER":"app",
    "APP_PASSWORD":"passw0rd",
    "QUEUE_NAME":"DEV.QUEUE.1",
    "MODEL_QUEUE_NAME":"DEV.APP.MODEL.QUEUE",
    "TOPIC_NAME":"dev/",
    "CIPHER_SUITE":"TLS_RSA_WITH_AES_128_CBC_SHA256",
    "KEY_REPOSITORY": "./keys/clientkey"
    }]
}

IBM Z Xplore

If you are running these samples on IBM Z Xplore then you can use the env-zbindings.json file. Simply rename the env-zbindings.json to env.json

You can use the env.json file to 'switch on' or 'switch off' parts of the code.

Endpoints Array

Having the endpoints defined as an array allows us to define multiple endpoints for the sample applications to use.

TLS

For example, removing the CIPHER_SUITE and KEY_REPOSITORY lines (don't forget to remove the comma from the last line in the json) will mean the sample will connect without using TLS.

If you have two docker containers, one with TLS and one without, changing the port number in the env.json allows you to switch between them.

Apple Silicon

The IBM MQ Client Toolkit on Apple Silicon (ARM64) makes use of OpenSSL libraries for TLS. For the MQI based samples in this repository, this means that KEY_REPOSITORY in the env.json file or environment variable KEY_REPOSITORY be set to the path for the queue manager's exported .pem file. eg. If you have exported the qmgrcert.pem file to the root directory of this repository, then set KEY_REPOSITORY to ../qmgrcert.pem .

Using port forwarding to run a multiple containers

Let's say you're already running MQ in a Docker container without TLS having set it up by following the Ready, Set, Connect tutorial.

Now you want to run the second Docker container to try the samples with TLS switched on.

You can have the same MQ objects set up in both, and switch between them by using the host port forwarding to make the non TLS queue manager available on port 1414 and the TLS one on port 1415.

Creating self signed certificates by using openssl

Do this in a directory you'll easily remember as you'll have to copy the server certificates over into a temporary folder each time you need to run MQ with TLS in a Docker container.

You'll also have to point to the client keystore location from the env.json file so that if you want to run samples with TLS, the sample knows where to look.

  1. Create a new directory. Navigate inside this and generate a self-signed server key and certificate

    openssl req -newkey rsa:2048 -nodes -keyout key.key -x509 -days 365 -out key.crt

    An RSA private key will be generated and you'll need to complete information that will go inside the self signed certificate.

    IMPORTANT: this directory should initially be empty.

  2. Verify that the certificate has been created successfully

    openssl x509 -text -noout -in key.crt

    When done, you'll see the certificate data output.

  3. Create a client keystore.

  • For JMS and XMS based clients, create a .jks client keystore and create and verify a keystore password:

    keytool -keystore clientkey.jks -storetype jks -importcert -file key.crt -alias server-certificate

  • For MQI based Clients (Node, Python, Go)

    Create a key database, a stash file. You will need to have installed the MQI client, so that you can run the runmqakm tool:

    runmqakm -keydb -create -db clientkey.kdb -pw tru5tpassw0rd -type pkcs12 -expire 1000 -stash

    Import the server's public key certificate into the client key database

    runmqakm -cert -add -label QM1.cert -db clientkey.kdb -pw tru5tpassw0rd -trust enable -file key.crt

  1. Move the client keystore
  • Move the client keystore somewhere you will remember. Ensure the only files in the current directory are the key.key and key.crt files, as IBM MQ will use the contents of this directory to configure security inside the container.
  1. Run the new docker container

    Give it a name, for example mqtls so you can differentiate it from your other MQ container when you docker ps, and point it at the location where you copied the server certificate.

    docker run --name mqtls --env LICENSE=accept --env MQ_QMGR_NAME=QM1 --volume ___PATH TO SERVER_KEY/CERTIFICATE DIRECTORY___:/etc/mqm/pki/keys/mykey --publish 1415:1414 --publish 9444:9443 --detach --env MQ_APP_PASSWORD=passw0rd icr.io/ibm-messaging/mq:latest

    Remember to use a secure password for MQ_APP_PASSWORD.

You should be able to open the MQ Web console for this TLS container on https://localhost:9444/ibmmq/console.

If you choose to stop the container, check the ID or name of the TLS container that was running previously with:

docker ps -a

then run

docker start <container id or name>

to start the container again.

MQI Paths

The MQI samples; Node.js, Python, Go, require the MQI Client Toolkit to have been installed and the paths

MQ_INSTALLATION_PATH and

DYLD_LIBRARY_PATH (MacOS) or LD_LIBRARY_PATH (Windows or Linux) set.

If you have installed the MQI client manually, ensure that

MQ_INSTALLATION_PATH is set to the root directory of your MQI Client installation and

DYLD_LIBRARY_PATH or LD_LIBRARY_PATH is set to $MQ_INSTALLATION_PATH\lib64.

Do not install any application requirements until

MQ_INSTALLATION_PATH and

DYLD_LIBRARY_PATH or LD_LIBRARY_PATH are set and exported (see language README docs for more info).

README docs

Language based MQI / JMS / XMS samples

Node.js

JMS

Python

C# .Net

Go

REST samples

Rust

Swift

react.js

AMQP samples

QPID

Transaction samples

JMS

Spring

Framework samples

Spring

Transactions on Spring

Quarkus

Reactive samples

Vert.x

Serverless samples

AWS Lambda

Azure Functions

Code Engine

OpenWhisk Cloud Functions

Showcase app

Showcase

Kubernetes samples

Scaling with Keda

MQ container deployment examples

compose

More Repositories

1

mq-container

Container images for IBM® MQ
Go
212
star
2

mq-jms-spring

Components to assist MQ JMS integration with Spring frameworks
Java
177
star
3

mq-golang

Calling IBM MQ from Go applications
Go
157
star
4

mq-docker

[DEPRECATED] Sample Docker image for IBM® MQ
Shell
125
star
5

event-streams-samples

Java
91
star
6

kafka-connect-mq-source

This repository contains a Kafka Connect source connector for copying data from IBM MQ into Apache Kafka.
Java
86
star
7

mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
JavaScript
74
star
8

mq-dev-samples

Samples for getting started with IBM MQ
Java
62
star
9

mq-metric-samples

IBM® MQ metric gathering client samples
Go
58
star
10

kafka-java-vertx-starter

Starter Java app for testing connection to Apache Kafka with Vert.x
JavaScript
44
star
11

mq-rfhutil

Message creation, editing and replay to help test MQ and IIB/ACE applications. Previously released as IH03 RFHUTIL SupportPac
C++
42
star
12

kafka-connect-jdbc-sink

This repository contains a Kafka Connect sink connector for copying data from Apache Kafka into databases using JDBC.
Java
34
star
13

mqtt-ios-sample

Sample iOS app using MQTT
Objective-C
34
star
14

mq-ansible

Ansible roles for IBM MQ
Python
30
star
15

mq-helm

Smarty
28
star
16

kafka-connect-mq-sink

This repository contains a Kafka Connect sink connector for copying data from Apache Kafka into IBM MQ.
Java
28
star
17

mq-golang-jms20

JMS style messaging interface for Golang applications connecting to IBM MQ
Go
26
star
18

mqperf

Repository for MQ related performance documents
22
star
19

mqlight-docker

Docker image for IBM MQ Light
Shell
22
star
20

mq-aws

Sample code for running IBM® MQ on Amazon Web Services (AWS)
Shell
21
star
21

kafka-connect-rabbitmq-source

This repository contains a Kafka Connect source connector for copying data from RabbitMQ into Apache Kafka.
Java
19
star
22

message-hub-rest

JavaScript
17
star
23

mq-q-qload

This repository contains the code from IBM MQ SupportPacs MA01 (q) and MO03 (qload)
C
17
star
24

mqtt-PickMeUp

Objective-C
16
star
25

mq-dev-badge-sample

Sample code of the MQ developer essentials badge
HTML
13
star
26

mq-chef

Chef cookbook for installing and configuring IBM® MQ
Ruby
13
star
27

mq-container-mft

Samples for integrating MQ MFT in Cloud scenarios
Go
13
star
28

mq-azure

This repository contains information and samples etc. relating to using IBM MQ on Microsoft Azure
Shell
12
star
29

mq-rdqm

Repository for the Replicated Data Queue Manager feature of IBM MQ
PowerShell
11
star
30

mq-tls-ssl-wizard

A wizard to help configure your MQ SSL/TLS connections
Java
11
star
31

mq-cph

The IBM MQ C Performance Harness
C++
10
star
32

mq-rexx-api

A REXX interface to issue MQ API calls - previously known as Supportpac MA95
C
9
star
33

mq-mqsc-editor-plugin

A plug-in for the MQ Explorer to help edit and execute MQSC scripts
HTML
8
star
34

mq-exits

A collection of sample IBM MQ exits
C
8
star
35

mqldt

IBM MQ Log Disk Tester
C
8
star
36

mq-appliance

This repository contains information and samples relating to the IBM MQ Appliance
Perl
7
star
37

mq-camel

A place for samples that describes IBM MQ and Apache Camel integration
Java
7
star
38

mq-openstack

Sample code for running IBM® MQ on OpenStack
Shell
6
star
39

kafka-connect-ibmcos-sink

This repository contains a Kafka Connect sink connector for copying data from Apache Kafka into IBM Cloud Object Storage
Java
6
star
40

mqlight-fishalive-node

Node.js MQ Light fishalive sample
JavaScript
6
star
41

jmstestp

Environment for creating a docker image running jms performance tests for Persistent and Non Persistent messaging.
Shell
6
star
42

mq-mft

Repository for IBM MQ Managed File Transfer documents, samples etc
Java
6
star
43

mq-event-display

Java
6
star
44

mq-cloud-demo

Sample scenario and applications for demonstrating the IBM MQ on Cloud service
JavaScript
6
star
45

mq-dotnet-administration-with-mqrestapi

This repository provides .NET samples which help in doing basic IBM MQ Queue/Channel Administration using IBM MQ REST API's
C#
6
star
46

cphtestp

Environment for creating a docker image running cph performance tests for Persistent and Non-Persistent messaging against an MQ Queue Manager.
Shell
6
star
47

mq-smf-csv

Simple formatter for MQ's SMF records to assist with import to spreadsheets and databases
C
6
star
48

mq-dotnet-samples

C#
5
star
49

cp4i-mq-samples

Samples to showcase connecting to a queue manager running as part of IBM Cloud Pak for Integration
Shell
5
star
50

macaque

Flask style library for microservices with MQ Light
Python
5
star
51

mq-cluster-tool

A tool to query and visualize your IBM MQ Clusters using a graph
Java
5
star
52

mq-atom-mqsc

Repository for the MQSC syntax hightlighting code used in the Atom text editor
5
star
53

kafka-connect-xml-converter

A Kafka Connect plugin to make it easier to work with XML data in Kafka Connect pipelines
Java
5
star
54

kafka-connect-elastic-sink

Kafka Connector to deliver events into Elasticsearch
Java
4
star
55

mq-wlm-client

Java
4
star
56

seneca-mqlight-transport

DEPRECATED: Implementation of a transport layer for using MQ Light with the Seneca microservices framework
JavaScript
4
star
57

mft-sample-web-ui

IBM MQ Managed File Transfer REST API
JavaScript
4
star
58

mq-python-json

Repo showing example(s) of how to consume and parse MQ event messages in Python
Python
4
star
59

mqlight-worker-thread

This repository contains a lab based on the worker thread use case for MQ Light
JavaScript
4
star
60

mq-sample-web-ui

A sample web page that uses the MQ administrative REST API
JavaScript
4
star
61

event-streams-docs

4
star
62

mq-asyncapi-java-template

This repository is no longer used and the project is now hosted within the ASyncAPI organisation.
JavaScript
4
star
63

ms03.saveqmgr

ms03-saveqmgr
C
3
star
64

mqlight-sentiment-sample

Files for MQ Light Lab at Impact
PHP
3
star
65

mqtt-smartboard

Java
3
star
66

mq-rexx-utils

This tool provides rexx execs to take output from CSQUTIL or runmqsc and create HTML pages so you can compare and contrast the differences on MQ object and their attributes. Differences are highlighted. You can display all attributes, or just different attributes.
HTML
3
star
67

mqlight-python-bluemix

MQ Light Python sample for Bluemix
HTML
3
star
68

mq-ansible-yaml-commands

IBM MQ Ansible Collection to issue YAML form commands to MQ queue managers
2
star
69

mq-ssl

This repository will contain a Wiki describing how to configure SSL with MQ in a couple of scenarios.
2
star
70

mq-pvc-tool

A tool for inspecting the Persistent Volume Claims associated with Queue Manager pods on OpenShift
Shell
2
star
71

mq-mi

Repository for information, samples etc. relating to IBM MQ Multi Instance queue manager support
C
2
star
72

mq-sfbridge-demo

IBM MQ Salesforce bridge demo in Docker
Shell
2
star
73

mqlight-fishalive-ruby

Ruby MQ Light fishalive sample
HTML
2
star
74

mqldt-c

Containerized version of mqldt
Dockerfile
2
star
75

mqtt-home-automation

This repository will contain an example of using MQTT to publish information about a house and controlling some aspects by publishing MQTT messages
2
star
76

iperf3-client

Configuration to build and run iperf3 client images
Dockerfile
2
star
77

ibm-messaging.github.io

WebSite for IBM Messaging
CSS
2
star
78

mq-ibmcloud

Sample code for running IBM® MQ on IBM Cloud (e.g. Bluemix / SoftLayer)
Java
2
star
79

mq-scratch-extension

Repo hosting the ScratchX.org extension for IBM MQ using the IBM MQ REST API
JavaScript
2
star
80

mq-mqfts

IBM MQ Managed File Transfer Log Capture Utility
Go
2
star
81

mqtt-status-pattern

This repository contains an example showing a pattern of usage of MQTT that makes available the status of MQTT clients.
C
2
star
82

kafka-connect-weather-source

This repository contains a Kafka Connect source connector for importing data from the IBM Weather Service into Apache Kafka.
Java
2
star
83

MFT-REST-java-sample

Java
2
star
84

homebrew-ibmmq

Homebrew tap for IBM MQ formulae and casks
Ruby
2
star
85

mq-mft-file-ordering

File Ordering MQMFT Exit
Java
1
star
86

mq-mft-REST-Samples

Go
1
star
87

iperf3-server

Configuration to build iperf3 images
Dockerfile
1
star
88

mq-raspberry-pi-developers

1
star
89

event-streams-operator-resources

1
star
90

mqtt-android-helper

Java
1
star
91

mqlight-fishalive-java

Java MQ Light fishalive sample
Java
1
star
92

mqlight-interconnect-2015-lab

Materials for the MQ Light Interconnect 2015 lab
HTML
1
star
93

messagesight-oauth-sample

Java
1
star
94

mqlight-conference-lab

Materials for demonstrating the use of the MQ Light API at conferences
HTML
1
star
95

mq-uniform-clusters

MQ Uniform Clusters bring a set of queue managers together to work as a single unit to intelligently distribute the applications across them. This repository provides simple scripts and setup to get going quickly
C
1
star
96

messagesight-message-expiry

This repository contains an example of using JMS to publish a message to MessageSight with a time to live and seeing that applied when there is an MQTT subscriber.
Java
1
star