IBM MQ JMS Spring Components
This repository contains code to help to provide Spring developers with easy configuration of the IBM MQ JMS package.
The library contains:
Installation and Usage
The compiled version of this package can be automatically downloaded from Maven Central. For local modifications and building it yourself, see BUILDING.md
Spring Boot Applications
Note This repository and the corresponding Maven Central artifact require Spring Boot 2. For Spring Boot 1 compatibility, you can use the previously-released level of the artifact at version 0.0.4.
The approach taken here is to follow the model for JMS applications shown in the Spring Getting Started Guide for JMS. That in turn is based on using the JmsTemplate Framework
Some simple example programs using Spring Boot and JMS interfaces can be found in the samples directory. The RUNME.sh program in each subdirectory compiles and executes it. The application.properties files in that tree may need modification for your environment.
Essentially what gets configured from this package are a ConnectionFactory which Spring's JmsTemplate implementation exploits to provide a simpler interface, and a MessageListener.
To get started quickly, you can use the default configuration settings in this package along with the IBM MQ for Developers container which runs the server processes.
The default options have been selected to match the MQ Docker container development configuration.
This means that you can run a queue manager using that Docker environment and connect to it. This script will run the container on a Linux system.
The default attributes are
The default userid and password have been chosen for a commonly-used queue manager configuration.
To disable user/password checking entirely, you must set the attribute to an empty value so that the default is not used.
Of course, that level of access must be permitted by your queue manager. The usual CHLAUTH and CONNAUTH rules will apply to assign an identity to the connection.
Configuration of secure connections with TLS are discussed below.
If you already have a running MQ queue manager that you want to use, then you can easily modify the default configuration to match by providing override values.
The queue manager name is given as
For client connections to a queue manager, you must also have either
If both the channel and connName are empty, and the CCDTURL is not supplied, then a local queue manager is assumed. The CCDTURL property is taken in preference to the channel and connName. The channel and connName have non-blank defaults, so must be explicitly set to empty strings if you do not wish them to be used.
Optionally you can provide a client id and application name if required.
You will probably also need to set
to override the default values.
For example in an file:
Spring Boot will then create a ConnectionFactory that can then be used to interact with your queue manager.
|ibm.mq.queueManager||Name of queue manager|
|ibm.mq.channel||Channel Name for SVRCONN|
|ibm.mq.connName||Connection Name, which can be comma-separated list|
|ibm.mq.ccdtUrl||Location of the MQ CCDT file (URL can reference http/ftp location)|
|ibm.mq.user||User Name. Must be set to an empty value to turn off authentication attempts|
|ibm.mq.clientId||ClientId uniquely identifies the app connection for durable subscriptions|
|ibm.mq.applicationName||Application Name used for Uniform Cluster balancing|
|ibm.mq.userAuthenticationMQCSP||Control authentication mechanism for old queue managers (default true)|
|ibm.mq.tempQPrefix||The prefix to be used to form the name of an MQ dynamic queue|
|ibm.mq.tempTopicPrefix||The prefix to be used to form the name of an MQ dynamic topic|
|ibm.mq.tempModel||The name of a model queue for creating temporary destinations.|
|ibm.mq.defaultReconnect||Whether app tries automatic reconnect. Options of YES/NO/QMGR/DISABLED/DEFAULT|
TLS related options
The following options all default to null, but may be used to assist with configuring TLS
|ibm.mq.sslCipherSuite||Cipher Suite, sets connectionFactory property WMQConstants.WMQ_SSL_CIPHER_SUITE|
|ibm.mq.sslCipherSpec||Cipher Spec, sets connectionFactory property WMQConstants.WMQ_SSL_CIPHER_SPEC|
|ibm.mq.sslPeerName||Peer Name, sets connectionFactory property WMQConstants.WMQ_SSL_PEER_NAME|
|ibm.mq.useIBMCipherMappings||Sets System property com.ibm.mq.cfg.useIBMCipherMappings|
|ibm.mq.outboundSNI||Sets property com.ibm.mq.cfg.SSL.OutboundSNI (use HOSTNAME for Openshift qmgrs)|
We also have
|ibm.mq.sslFIPSRequired||Force FIPS-compliant algorithms to be used (default false)|
|ibm.mq.sslKeyResetCount||How many bytes to send before resetting the TLS keys|
Caching connection factory options
You may want to use the default Spring Caching connection factory with the default Spring JMS properties. This is now the preferred method in Spring for holding JMS objects open, rather than the Pooling options described below.
|spring.jms.cache.enabled||Whether to cache sessions|
|spring.jms.cache.consumers||Whether to cache message consumers|
|spring.jms.cache.producers||Whether to cache message producers|
|spring.jms.cache.session-cache-size||Size of the session cache (per JMS Session type)|
Pooled connection factory options
Alternatively you may configure a pooled connection factory by using those properties:
|ibm.mq.pool.enabled||Enabled Pooled connection factory usage|
|ibm.mq.pool.blockIfFull||Blocks a connection request when the pool is full. Default is false|
|ibm.mq.pool.blockIfFullTimeout||Blocking period before throwing an exception if the pool is still full|
|ibm.mq.pool.idleTimeout||Connection idle timeout. Default to 30 seconds|
|ibm.mq.pool.maxConnections||Maximum number of pooled connections. Default is 1|
|ibm.mq.pool.maxSessionsPerConnection||Maximum number of pooled sessions. Default is 500|
|ibm.mq.pool.timeBetweenExpirationCheck||Time to sleep between runs of the idle connection eviction thread. Disable when negative. Default is -1|
|ibm.mq.pool.useAnonymousProducers||Whether to use only one anonymous "MessageProducer" instance. Set it to false to create one "MessageProducer" every time one is required|
These pooling options make use of the PooledJMS implementation. More documentation on the options can be found here.
JMS Polling Listener Timer configuration
The Spring AbstractPollingMessageListenerContainer interface has a default polling timer of 1 second. This can now be configured with the property. If the property is not explicitly set, then this MQ Spring Boot component resets the initial timeout value to 30 seconds which has been shown to be more cost-effective. Application code can still set its own preferred value.
|spring.jms.listener.receiveTimeout||How frequently to poll for received messages. Default is 1s. Given as a Duration string: "1m", "60s", "60000" are equivalent|
Additional properties that are not in the recognised sets listed here can be put onto the Connection Factory via a map in the external properties definitions. Use the format . The CONSTANT_NAME can be either the real string for the property, and will often begin with "XMSC", or it can be the variable as known in the WMQConstants class.
For example, the constant has the value and can be written in the properties file either as or as
There is no error checking on the property name or value. This may help with enabling rarely-used properties and reduce the need for a customizer method in application code. See the KnowledgeCenter for a list of all the currently-recognised properties that may be set on a CF - though note that many are now deprecated.
If the value looks like a number, it is treated as such. You can use hex constants beginning "0X" or decimals for a number. Similarly if the value is TRUE/FALSE then that is processed as a boolean. So you cannot try to set a string property that appears to be an integer. Symbols representing the value of integer attributes cannot be used - the real number must be given.
Spring already has configuration parameters for the use of a JNDI repository with a JMS program. See the Spring documentation for more details.
However this package also enables some simple use of JNDI for Connection definitions (but not Destinations, as they are still always handled by the core Spring classes).
You can set the and attributes to define how the lookup is to be carried out. For example,
If you choose to use this mechanism, all of the other queue manager properties that might be defined in your resource definitions are ignored and not traced in order to avoid confusion. They will instead be picked up from the ConnectionFactory definition in JNDI. The property is then more accurately used as the ConnectionFactory name used as the lookup. If you are using an LDAP JNDI provider, then the CF name will be modified if necessary to always begin with .
The prefix can be used for any other JNDI-related properties that need to be applied to the Context object. The symbolic name of the field from that Java class can be used. For example,
The method is public so you can use it with your own constructed properties object and get access to a JNDI Context object - it might make it easier to work with Destinations if you can reuse the same way of getting directory access.
Logging & Tracing
The package makes use of the logging capabilities within Spring. You can enable tracing of this specific component in your application's properties file by setting . Otherwise it uses the standard inheritance of logging configuration from downwards.
Contributions and Pull requests
Contributions to this package can be accepted under the terms of the IBM Contributor License Agreement, found in the file CLA.md of this repository.
When submitting a pull request, you must include a statement stating you accept the terms in CLA.md.
Using in Other Projects
The preferred approach for using this package in other projects will be to use the Gradle or Maven dependency as described above.
Copyright © 2018, 2021 IBM Corp. All rights reserved.
Licensed under the apache license, version 2.0 (the "license"); you may not use this file except in compliance with the license. You may obtain a copy of the license at
Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. See the license for the specific language governing permissions and limitations under the license.
This package is provided as-is with no guarantees of support or updates. You cannot use IBM formal support channels (Cases/PMRs) for assistance with material in this repository. There are also no guarantees of compatibility with any future versions of the package; the API is subject to change based on any feedback. Versioned releases are made to assist with using stable APIs.
Before opening a new issue please consider the following:
- Please try to reproduce the issue using the latest version.
- Please check the existing issues to see if the problem has already been reported. Note that the default search includes only open issues, but it may already have been closed.
- When opening a new issue here in github please complete the template fully.
The IBM MQ Series JMS Adapter enables you to create an integration in Oracle Integration.
The IBM MQ Series JMS Adapter provides the following support:
- Queue manager with or without Username Password Token authentication
The Queue manager maintains the queues and ensures that the messages in the queues reach their destination. The queue manager also performs other functions associated with message queuing.
- Inbound and outbound operations
- Durable subscriptions for topics
- Headers (standard and custom)
- Message selector filtering for inbound queue operations
- Ability to dequeue messages when they are datagram message types. Only datagram message types are supported. See IBM MQ Series JMS Adapter Restrictions.
The IBM MQ Series JMS Adapter is one of many predefined adapters included with Oracle Integration. You can configure the IBM MQ Series JMS Adapter as a trigger or invoke connection in an integration in Oracle Integration.
The issue here is the requirement that "My boss asked me to use pure java JMS (not ibm.mq lib) to do that." JMS is a specification and each implementation must comply with the API and the semantics, but is free to do whatever they want at a low level. It is always necessary to use the implementation classes provided by the transport vendor. Therefore if you use WebSphere MQ as the transport, you will need to use the IBM MQ JMS classes to write a JMS application.
That said, if you stick with pure JMS API calls you would be able to plug in any transport vendor's classes. This is what is usually intended when you are given requirements such as that mentioned in the original post.
There's an article describing exactly what you are looking to do called Running a standalone Java application on WebSphere MQ V6.0 It uses only the JMS API and it uses JNDI in a local file system (a .bindings file). By swapping out the IBM JMS classes for another vendor and using their JNDI tools you would be able to plug in any JMS transport without changing your code using this approach.
If you want to do the same thing without JNDI, look at the sample programs provided with the MQ client install where you obtained your Java classes. In a UNIX/Linux system these are in and on Windows they are in . The sample has the following code for initializing your connection factory without JNDI:
Because this approach does not use JNDI, you are required to write code that is not transportable across transport vendors. It is IBM WebSphere MQ specific.
If you grabbed the MQ jars from somewhere and do not have the full install (and thus do not have the samples) you can download it as SupportPac MQC7. The download is free. In general you should use the latest client, even with a back-level queue manager. Obviously you do not get V7 functionality from a V6 QMgr but the JMS implementation in the V7 client is much improved, even for V6 functionality. If for some reason you really must use the V6 client, you can download it as SupportPacMQC6. Whichever client version you use, make sure to use the corresponding Infocenter.
Finally, the landing page with an index for all the SupportPacs is here.
What this repo is for
This repo hosts sample code referred to and used as part of tutorials for IBM MQ on IBM Developer.
Where to find code to copy/paste into your app
We have a wealth of messaging patterns, represented in many languages, including Java, .NET, Python, Node.js and Golang. They are available at the mq-dev-patterns repo, here!
Feel free to use code from the mq-dev-patterns repo to create your own messaging applications.
Using the samples with TLS (IBM DDC MQ Badge Lab)
For reference these instructions were built from this tutorial. Check it out for additional hints and tips.
- Clone this repo
- Change directory to the working directory
- Download the jar
- Download the IBM MQ all client (220.127.116.11) jar
- Copy the Queue Manager's public certificate .pem file to the directory
(Linux) or (Windows)
- Use to create a client trust store
- Enter and then re-enter a password for your new truststore file . It's important to remember this password as we'll use it when we run the sample later.
- Type to trust this certificate
Generate application credentials and an API key
Navigate to the "Application Credentials" tab of your cloud MQ service instance.
Click , then create a user called "app". Click , which will bring up your API token. Copy this and save it somewhere as you'll need it in the application you run to authenticate yourself to your MQ instance.
Start coding to put a message with jms
Open the file (Linux) or (Windows) in your favorite editor
Uncomment the following line
Modify the following variables to match your IBM MQ configuration
Compile your jms code
- Change directory to (Linux) or (Windows)
- Compile your modified application
- For Linux
- For Windows
- You should now see a file alongside your source file
Run your application
Execute your Java code, specifying the and you set up earlier
What you should see
Congratuations, you've just sent you're first IBM MQ Message and you should see output similar to the following:
Ibm mq jms
.kafka vs active Mq , IBM MQ ,Rabbit MQ , JMS - Kafka Spark Interview Questions
- Tractor hydraulic filter
- Apex legends reddit
- Roku model 2050x
- Are reverend guitars good
- Meme faces funny
- Kate bilo health