Message Brokers
Message Broker configuration
We'll configure testing message brokers. We'll be testing:
ActiveMQ 6(Artemis)
IBM MQ 9
Docker based IBM MQ 9 installation
We can use official image available at docker hub.
The sources for Dockerfile are stored in github project.
1. Start IBM MQ 9 docker container:
$ docker run -d --name pax-webspheremq9 --env LICENSE=accept --env MQ_QMGR_NAME=PAXQM --publish 1414:1414 --publish 19443:9443 ibmcom/mq:9
833984b2be9aa31043806b25caf2250e5548b5811e355a251e3c4947e537272a
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
833984b2be9a ibmcom/mq:9 "runmqdevserver" 5 seconds ago Up 4 seconds 0.0.0.0:1414->1414/tcp, 0.0.0.0:19443->9443/tcp pax-webspheremq9
2. Check if web console works
With the above port mapping, we can access web console at https://localhost:19443/ibmmq/console/ using admin/passw0rd credentials (see details here).
3. Check if MQ Explorer works
We can install IBM MQ Explorer downloaded from https://developer.ibm.com/messaging/mq-downloads/ (check MQ Explorer standalone download link).
After installing, we can add broker connection with these properties:
Queue manager name:
PAXQM, connect directlyHost name or IP address:
localhostServer connection channel:
DEV.ADMIN.SRVCONNCheck Enable user identification and use user:
admin, password:passw0rd.
Then, under Queues node we should see DEV.QUEUE.[1-3] and DEV.DEAD.LETTER.QUEUE.
Authentication configuration
In order to test the examples, we have to configure proper channel security. Github page points us to article about security configuration. There's also another article here.
We need to override security configuration for DEV.APP.SVRCONN channel which we'll use for client connections.
Connect to docker container and run runmqsc command as mqm user:
$ docker exec -ti pax-webspheremq9 /bin/bash
(mq:9.0.5.0)root@833984b2be9a:/# su - mqm
No directory, logging in with HOME=/
$ runmqsc
5724-H72 (C) Copyright IBM Corp. 1994, 2018.
Starting MQSC for queue manager PAXQM.Check current configuration of the channel
display channel (DEV.APP.SVRCONN)
1 : display channel (DEV.APP.SVRCONN)
AMQ8414I: Display Channel details.
CHANNEL(DEV.APP.SVRCONN) CHLTYPE(SVRCONN)
ALTDATE(2018-04-26) ALTTIME(13.53.42)
CERTLABL( ) COMPHDR(NONE)
COMPMSG(NONE) DESCR( )
DISCINT(0) HBINT(300)
KAINT(AUTO) MAXINST(999999999)
MAXINSTC(999999999) MAXMSGL(4194304)
MCAUSER( ) MONCHL(QMGR)
RCVDATA( ) RCVEXIT( )
SCYDATA( ) SCYEXIT( )
SENDDATA( ) SENDEXIT( )
SHARECNV(10) SSLCAUTH(REQUIRED)
SSLCIPH( ) SSLPEER( )
TRPTYPE(TCP)
:
display chlauth('*')
2 : display chlauth('*')
AMQ8878I: Display channel authentication record details.
CHLAUTH(DEV.ADMIN.SVRCONN) TYPE(USERMAP)
CLNTUSER(admin) USERSRC(CHANNEL)
AMQ8878I: Display channel authentication record details.
CHLAUTH(DEV.ADMIN.SVRCONN) TYPE(BLOCKUSER)
USERLIST(nobody)
AMQ8878I: Display channel authentication record details.
CHLAUTH(DEV.APP.SVRCONN) TYPE(ADDRESSMAP)
ADDRESS(*) USERSRC(CHANNEL)
AMQ8878I: Display channel authentication record details.
CHLAUTH(SYSTEM.ADMIN.SVRCONN) TYPE(ADDRESSMAP)
ADDRESS(*) USERSRC(CHANNEL)
AMQ8878I: Display channel authentication record details.
CHLAUTH(SYSTEM.*) TYPE(ADDRESSMAP)
ADDRESS(*) USERSRC(NOACCESS)
AMQ8878I: Display channel authentication record details.
CHLAUTH(*) TYPE(ADDRESSMAP)
ADDRESS(*) USERSRC(NOACCESS)
AMQ8878I: Display channel authentication record details.
CHLAUTH(*) TYPE(BLOCKUSER)
USERLIST(*MQADMIN) Default auth configuration blocks authenticated users by default.
Override blocking by specifying different list of blocked users
SET CHLAUTH(DEV.APP.SVRCONN) TYPE(BLOCKUSER) USERLIST('nobody') DESCR('Allow privileged users on this channel')
3 : SET CHLAUTH(DEV.APP.SVRCONN) TYPE(BLOCKUSER) USERLIST('nobody') DESCR('Allow privileged users on this channel')
AMQ8877I: IBM MQ channel authentication record set.Enable client connection on DEV.APP.SVRCONN channel
SET CHLAUTH('*') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(NOACCESS) DESCR('BackStop rule')
4 : SET CHLAUTH('*') TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(NOACCESS) DESCR('BackStop rule')
AMQ8883E: Channel authentication record already exists.
SET CHLAUTH(DEV.APP.SVRCONN) TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(CHANNEL) CHCKCLNT(REQUIRED)
5 : SET CHLAUTH(DEV.APP.SVRCONN) TYPE(ADDRESSMAP) ADDRESS('*') USERSRC(CHANNEL) CHCKCLNT(REQUIRED)
AMQ8883E: Channel authentication record already exists.Enable password authentication (instead of runas authentication)
ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) ADOPTCTX(YES)
6 : ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) ADOPTCTX(YES)
AMQ8567I: IBM MQ authentication information changed.
REFRESH SECURITY TYPE(CONNAUTH)
7 : REFRESH SECURITY TYPE(CONNAUTH)
AMQ8560I: IBM MQ security cache refreshed.
exit
8 : exit
...Change password of app user
After exiting runmqsc we have to again become root user in bash shell.
(mq:9.0.5.0)root@833984b2be9a:/# id
uid=0(root) gid=0(root) groups=0(root),999(mqm)
(mq:9.0.5.0)root@833984b2be9a:/# passwd app
Enter new UNIX password: pax
Retype new UNIX password: pax
passwd: password updated successfully
(mq:9.0.5.0)root@833984b2be9a:/# Our testing IBM MQ 9 server is ready to use.
Client libraries
For completeness, here's the list of libraries that should be used with IBM MQ 9.
If we go to https://developer.ibm.com/messaging/mq-downloads/ → http://www-01.ibm.com/support/docview.wss?uid=swg24042176, we can download 9.0.5.0-IBM-MQC-Redist-Java package, but it doesn't contain everything we need.
However, we can change criteria in Change your selection box in strange way:
click in Product selector and don't change anything - accept existing WebSphere MQ
without changing product, we actually change lower box from Upgrades to version to Applies to version
select 9.0.4, Platform = all and click Submit
then we can find the official client library package:
9.0.5.0-IBM-MQ-Install-Java-All.jar
To be precise, here are the checksums:
$ sha1sum 9.0.5.0-IBM*
4e6548956756c87c579d17a739416c59b736c145 9.0.5.0-IBM-MQC-Redist-Java.zip
c38a55118059221677240d507ae6c9b3b6923439 9.0.5.0-IBM-MQ-Install-Java-All.jarAdditionally, after downloading developer version of IBM MQ 9 (mqadv_dev905_linux_x86-64.tar.gz), we can find additional library package: MQSeriesJava-9.0.5-0.x86_64.rpm → MQSeriesJava-9.0.5-0.x86_64.cpio.lzma → MQSeriesJava-9.0.5-0.x86_64.cpio.
After unpacking cpio package, we can see even more complete set of libraries.
Even if it seems that 9.0.5.0-IBM-MQ-Install-Java-All package should be used, there are some OSGi issues described below. There are three subdirectories in this package:
JavaEEcontains resource adapter archive (wmq.jmsra.rar)JavaSEcontainscom.ibm.mq.allclient.jarlibrary and dependenciesOSGicontains respectivecom.ibm.mq.osgi.allclient_9.0.5.0.jarand dependencies
MQSeriesJava-9.0.5-0.x86_64.cpio contains (in java/lib/OSGi):
com.ibm.mq.osgi.allclientprereqs_9.0.5.0.jar- should not be used, because it embedsjms.jarcom.ibm.mq.osgi.allclient_9.0.5.0.jar- depends on the above, so should not be usedcom.ibm.mq.osgi.java_9.0.5.0.jarcom.ibm.msg.client.osgi.commonservices.j2se_9.0.5.0.jarcom.ibm.msg.client.osgi.jms_9.0.5.0.jar- should not be usedcom.ibm.msg.client.osgi.jms.prereq_9.0.5.0.jarcom.ibm.msg.client.osgi.nls_9.0.5.0.jarcom.ibm.msg.client.osgi.wmq_9.0.5.0.jarcom.ibm.msg.client.osgi.wmq.nls_9.0.5.0.jarcom.ibm.msg.client.osgi.wmq.prereq_9.0.5.0.jar
OSGi directory of 9.0.5.0-IBM-MQ-Install-Java-All.jar package contains only two bundles:
com.ibm.mq.osgi.allclient_9.0.5.0.jar- actual drivercom.ibm.mq.osgi.allclientprereqs_9.0.5.0.jar- preprequisites
While the prerequisites JAR contain required fscontext.jar and providerutil.jar libraries, it also contains:
bcprov-jdk15on-157.jarandbcpkix-jdk15on-157.jar, while usually Karaf distro ships those in$KARAF_HOME/lib/ext- that's however not that problematicjms.jarwhich is exactly the same jar which is available usingmvn:javax.jms/javax.jms-api/2.0
We can't rely on the embedded jms.jar, otherwise we'd get ClassCastExceptions when working with this driver, because Karaf and pax-jms rely on own version of JMS API from mvn:javax.jms/javax.jms-api/2.0.
Unfortunately, com.ibm.mq.osgi.allclient_9.0.5.0.jar bundle contains this manifest header:
Require-Bundle =
com.ibm.mq.osgi.allclientprereqs;visibility:=reexportSo without a hack with installing an empty bundle with com.ibm.mq.osgi.allclientprereqs symbolic name, we actually can't use com.ibm.mq.osgi.allclient_9.0.5.0.jar bundle.
So the method I used is:
add
bcpkix-jdk15on-1.59.jarandbcprov-jdk15on-1.59.jarfrom Maven Central or Bouncy Castle release page to$KARAF_HOME/lib/ext(Java 8)add
org.bouncycastleandorg.bouncycastle.*packages toorg.osgi.framework.bootdelegationproperty in$KARAF_HOME/etc/config.propertiesunpack
fscontext.jarandproviderutil.jarfromcom.ibm.mq.osgi.allclientprereqs_9.0.5.0.jar, or copy them from9.0.5.0-IBM-MQ-Install-Java-All/JavaSEcopy these 2 libraries to
$KARAF_HOME/lib/extstart Karaf (I used 4.2.0)
install
jmsfeature which installsmvn:javax.jms/javax.jms-api/2.0bundleinstall 6 bundles from
MQSeriesJava-9.0.5-0.x86_64.cpiopackage (you can also create feature that contains these bundles):
karaf@root()> install 'file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.commonservices.j2se_9.0.5.0.jar'
Bundle ID: 43
karaf@root()> install 'file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.jms_9.0.5.0.jar'
Bundle ID: 44
karaf@root()> install 'file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.nls_9.0.5.0.jar'
Bundle ID: 45
karaf@root()> install 'file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.wmq.nls_9.0.5.0.jar'
Bundle ID: 46
karaf@root()> install 'file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.wmq.prereq_9.0.5.0.jar'
Bundle ID: 47
karaf@root()> install 'file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.wmq_9.0.5.0.jar'
Bundle ID: 48
karaf@root()> resolve
karaf@root()> # start non-fragment bundles
karaf@root()> la -l|grep ibm.msg
43 │ Active │ 80 │ 9.0.5.0 │ file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.commonservices.j2se_9.0.5.0.jar
44 │ Active │ 80 │ 9.0.5.0 │ file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.jms_9.0.5.0.jar
45 │ Active │ 80 │ 9.0.5.0 │ file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.nls_9.0.5.0.jar
46 │ Resolved │ 80 │ 9.0.5.0 │ file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.wmq.nls_9.0.5.0.jar
47 │ Active │ 80 │ 9.0.5.0 │ file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.wmq.prereq_9.0.5.0.jar
48 │ Active │ 80 │ 9.0.5.0 │ file:///data/downloads/ibm.com/IBM%20MQ/MQSeriesJava-9.0.5-0.x86_64/java/lib/OSGi/com.ibm.msg.client.osgi.wmq_9.0.5.0.jarIBM MQ 9 should be available after proper configuration described in Configuration page.
A-MQ 7 installation (Artemis)
This time we'll run standalone (no docker) version of apache-artemis-2.5.0-bin.zip available from ASF Archive.
$ pwd
/data/servers/apache-artemis-2.5.0
$ bin/artemis create --user pax --password pax --require-login artemis-broker
Creating ActiveMQ Artemis instance at: /data/servers/apache-artemis-2.5.0/artemis-broker
Auto tuning journal ...
done! Your system can make 41.67 writes per millisecond, your journal-buffer-timeout will be 24000
You can now start the broker by executing:
"/data/servers/apache-artemis-2.5.0/artemis-broker/bin/artemis" run
Or you can run the broker in the background using:
"/data/servers/apache-artemis-2.5.0/artemis-broker/bin/artemis-service" start
$ artemis-broker/bin/artemis run
_ _ _
/ \ ____| |_ ___ __ __(_) _____
/ _ \| _ \ __|/ _ \ \/ | |/ __/
/ ___ \ | \/ |_/ __/ |\/| | |\___ \
/_/ \_\| \__\____|_| |_|_|/___ /
Apache ActiveMQ Artemis 2.5.0
2018-04-26 16:46:32,376 INFO [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server
...Client libraries
Artemis libraries are available in Maven Central. These are also installed in Karaf when using pax-jms-artemis feature.
karaf@root()> feature:repo-add mvn:org.apache.activemq/artemis-features/2.5.0/xml/features
Adding feature url mvn:org.apache.activemq/artemis-features/2.5.0/xml/features
karaf@root()> feature:repo-add mvn:org.ops4j.pax.jms/pax-jms-features/1.0.0/xml/features
Adding feature url mvn:org.ops4j.pax.jms/pax-jms-features/1.0.0/xml/features
karaf@root()> feature:info pax-jms-artemis
Feature pax-jms-artemis 1.0.0
Feature has no configuration
Feature has no configuration files
Feature depends on:
pax-jms-config 0.0.0
artemis-core-client 0.0.0
artemis-jms-client 0.0.0
artemis-amqp-client 0.0.0
Feature contains followed bundles:
mvn:org.ops4j.pax.jms/pax-jms-artemis/1.0.0
Feature has no conditionals.After installing pax-jms-artemis feature, we have the bundles:
karaf@root()> la -l|grep client
75 │ Active │ 80 │ 2.5.0 │ mvn:org.apache.activemq/artemis-core-client-osgi/2.5.0
76 │ Active │ 80 │ 2.5.0 │ mvn:org.apache.activemq/artemis-jms-client-osgi/2.5.0
81 │ Active │ 80 │ 0.30.0 │ mvn:org.apache.qpid/qpid-jms-client/0.30.0