DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Code and Connect: MCP + MuleSoft
  • Generic and Dynamic API: MuleSoft
  • Releasing MuleSoft API
  • API-Led Example: MuleSoft

Trending

  • Member Spotlight: Shai Almong
  • New York City Taxi Trips: Putting Neo4j and DuckDB to Work
  • Why AI Agents Need a Shared Enterprise Ontology
  • Google Cloud KMS vs. AWS KMS: Java Encryption Guide

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Mulesoft Synchronous API With IBM MQ

Mulesoft Synchronous API With IBM MQ

The purpose of this article is to provide a concrete example of working with IBM MQ and export API synchronously.

By 
Gary Liu
·
Feb. 24, 21 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
9.5K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Introduction

The purpose of this article is to provide a concrete example of working with IBM MQ and export API synchronously. By nature, IBM MQ or other JMS Queue is asynchronous communication. The customers require the API to be synchronous. 

Also, in this case, the backend IBM MQ application is NOT JMS compliant. This creates a challenging situation for encoding messages and correlation ID.

Use Cases

As shown in the diagram below. The requirement is to expose an experienced API to customers. The REST API will provide data from the backend, which is IBM MQ Serius exposing MainFrame data.

REST API providing data from the backend graphic

  • Customers will invoke the API in synchronous mode
  • Response data should be in JSON format
  • Mulesoft API need to send message to IBM MQ using non-JMS compliance mode
  • Both correlation ID and payload must be encoded in EBCDIC format

Key Challenges

  • The backend implementation for messaging is not JMS compliant
  • JMS by nature is Asynchronous, but REST API is synchronous

Technical Solution

Given the requirement, we must use the Mulesoft IBM Connector. The current version is 1.6.3. The IBM MQ connector provides an operation namely Publish-Consume.

Encoding of EBCDIC in the term of connector attribute is CP1047 per IBM MQ document.

The Mulesoft flow takes the following form:

Mulesoft flow

The complete code can be found at GitHub here.

Connector Configuration

The IBM MQ connector configuration is standard. The only attention is the targetClient, which is NO_JMS_COMPLIANT

targetClient is NO_JMS_COMPLIANT

Global Element Properties


Publish-Consume Configuration

The configuration for the operation of Publish consume is shown below. Please note two things:

  • Request-Reply Pattern: CORRELATION_ID
  • Encoding for both publisher and consumer is set to CP1047

Correlation ID and Encoding examples

Encode Correlation ID

For simplicity's sake, I encoded the correlation ID using a JAVA class. This can be done using Dataweave. But I recommend using the JAVA class and eventually create a connector for reusability.

For the complete JAVA Code, please refer to my GitHub project.

GitHub Project Screenshot


A few notes for encoding correlation ID:

  1. It is encoded by CP1047
  2. Its format is ID: + 48 HEX Digits

Key Takeaways

  • Use trials and errors approach for this kind of integration, particularly if the backend implementation is done via 3rd party
  • The EBCDIC encoding is CP1047 in terms of Mulesoft configuration
  • Make sure to encode the correlation ID in the format of EBCDIC
API MuleSoft

Opinions expressed by DZone contributors are their own.

Related

  • Code and Connect: MCP + MuleSoft
  • Generic and Dynamic API: MuleSoft
  • Releasing MuleSoft API
  • API-Led Example: MuleSoft

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook