g-mqs provides a Groovy DSL wrapper around WebSphere MQS client API.
(See full standalone Groovy script including @Grape)
new Mqs().hostname('localhost').port(1414).channel('TEST_CHANNEL').withQueueManager('test_qm') {
String correlationId = 'some.correlation.id'
withQueue('myQueue', Mqs.QueueOptions.SEND) {
sendToQueue('My message', correlationId)
...
}
withQueue('myQueue', Mqs.QueueOptions.RECEIVE) {
timeout(2000)
String response = receiveMessageByCorrelationId(correlationId)
println('Received: ' + response)
...
}
withQueue('myQueue', Mqs.QueueOptions.RECEIVE) {
purgeQueue()
...
}
}
The project requires Gradle for building from source. If you do not have Gradle installed yet, have a look at the Gradle homepage.
The required WebSphere MQS JARs are commercially licensed by IBM and are therefore not available by public Maven repos.
Tip: There's an evaluation version available!
You'll have to spawn these to your (local) Maven repo using the Gradle helper:
-
Go to the helper directory:
cd mqs-repo-spawning
-
Copy the following list of MQS JARs into this directory:
com.ibm.mq.commonservices.jar com.ibm.mq.connector.jar com.ibm.mq.headers.jar com.ibm.mq.jar com.ibm.mq.jmqi.jar com.ibm.mq.jmqi.local.jar com.ibm.mq.jmqi.remote.jar com.ibm.mq.jmqi.system.jar com.ibm.mq.jms.admin.jar com.ibm.mq.pcf.jar com.ibm.mqetclient.jar com.ibm.mqjms.jar com.ibm.msg.client.commonservices.j2se.jar com.ibm.msg.client.commonservices.jar com.ibm.msg.client.jms.internal.jar com.ibm.msg.client.jms.jar com.ibm.msg.client.matchspace.jar com.ibm.msg.client.provider.jar com.ibm.msg.client.ref.jar com.ibm.msg.client.wmq.common.jar com.ibm.msg.client.wmq.factories.jar com.ibm.msg.client.wmq.jar com.ibm.msg.client.wmq.v6.jar dhbcore.jar
3. Update the *build.gradle*
You probably want to set the correct MQS version for your JARs, and maybe the local or remote repo.
Note that for the MQS version, you will also have to update the MQS dependency version in the top level *build.gradle*.
4. Run Gradle
By default this will spawn the JARs to your local repo.
```gradle uploadArchives```
### Compiling and creating JARs
To compile and create the JARs, run
```gradle clean install```