Standalone JMS to Mainframe MQ in EBCDIC

I am new to Websphere MQ (IBM z/OS) technologies. We had a requirement to implement a standalone application that uses JMS technology to connect to an MQ server (on IBM z/OS. This is maintained by a different organization for which we have only limited access) and put a message on the queue.

Here are pieces of my code below.

private void sendMessage(String queue, String msg) {
        JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
        JmsConnectionFactory cf = ff.createConnectionFactory();

        cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, host);
        cf.setIntProperty(WMQConstants.WMQ_PORT, port);
        cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channel);
        cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
        cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManagerName);
        cf.setStringProperty(WMQConstants.USERID, user);
        cf.setStringProperty(WMQConstants.PASSWORD, password);

    Connection connection = null;
    Session session = null;
    Destination destination = null;
    MessageProducer producer = null;

        connection = cf.createConnection(user, password);
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        destination = session.createQueue(queue);
        producer = session.createProducer(destination);

        TextMessage message = session.createTextMessage();
        message.setIntProperty(WMQConstants.JMS_IBM_CHARACTER_SET, 37);
        //message.setIntProperty(WMQConstants.JMS_IBM_ENCODING, 785);

        // Start the connection

        // And, send the message

I was successfully able to connect to the MQ server on the other end and put the messages on the remote server in ASCII format. I was able to consume the message that I have put on the queue from an AIX server.

But since the MQ is running on z/OS and the consumer is also an Mainframe application the message I put appears to be a garbage/unreadable format. After some research I figured out that messages needs to be converted to EBCDIC to be put on z/OS MQ. I expected that this will be taken care of by the IBM MQ libraries.

Please help on how can I put the messages in EBCDIC format.


  • More importantly, if your receiver is not a Java client, you need to disable the JMS header as follows:

    destination = session.createQueue("queue:///" + queue + "?targetClient=1")

    or by invoking the Native MQ implementation :