MQ Visual Edit V3.2.0 Released

Capitalware Inc. would like to announce the official release of MQ Visual Edit v3.2.0. This is a FREE upgrade for ALL licensed users of MQ Visual Edit V2/V3. MQ Visual Edit allows users to view, manipulate and manage messages in a queue and/or topic of an IBM MQ queue manager and presents the data in a simplified format similar to a database utility or spreadsheet program.

For more information about MQ Visual Edit go to:
https://www.capitalware.com/mqve_overview.html

    Changes for MQ Visual Edit v3.2.0:

  • Added support for importing COBOL Copybook into the ‘Fixed Width’ configuration window for User Format.
  • Added ‘Number of threads’ for the following MQ Tools: Put Server, SIM Server, SIM Client & Publish Server.
  • Added 12 replaceable tokens for the following MQ Tools: Put Server, SIM Server, SIM Client & Publish Server.
  • Added right-click menu for selecting the replaceable tokens on the text box for: Put Server, SIM Server, SIM Client & Publish Server.
  • Added ‘Show Temporary Queues’ checkbox on the Open Queue and MQ Monitoring Tools’ Open Queue dialog
  • Added the ability to sort the columns by clicking on the column header of List Of Queues and List Of Topics popup windows.
  • Added support for user defined date and time fields in the Preferences window.
  • Added the product version number to the Registration window.
  • Added code to convert Event messages as they are retrieved from the queue rather when the user opens the Message Edit window.
  • For CSV, FIX and Fixed Width Viewers, added the ability to click on the column header to sort the data by that column.
  • For CSV, FIX and Fixed Width layout manager, added ‘Type for Table Sorting’ column. It tells MQ Visual Edit how to sort the data in a particular column (i.e. String, Integer, Double, etc.).
  • Improved the handling of right-click popup menu on the main window, List of Queues and List of Topics windows
  • Enhanced the logging to include all GUI classes.
  • Fixed issue with preferences being removed when the language is changed.
  • Fixed issue with user selected language not being saved as a Preference.
  • Fixed an issue with the Choose Columns for MQMD.
  • Fixed an issue with the dock width setting not being removed when the Reset View was selected (under the View menu item).
  • Fixed an issue with the SIM Client missing the Browse button for text file.
  • Fixed an issue with handling PCF MQCFT_XR_SUMMARY messages from z/OS queue managers.
  • Fixed an issue with renaming a Group (on main window).

Regards,
Roger Lacroix
Capitalware Inc.

Capitalware, IBM MQ, IBM MQ Appliance, Linux, macOS (Mac OS X), MQ Visual Edit, Raspberry Pi, Windows Comments Off on MQ Visual Edit V3.2.0 Released

MQ Visual Browse V3.2.0 Released

Capitalware Inc. would like to announce the official release of MQ Visual Browse v3.2.0. This is a FREE upgrade for ALL licensed users of MQ Visual Browse V2/V3. MQ Visual Browse allows users to view messages in a queue and/or topic of an IBM MQ queue manager and presents the data in a simplified format similar to a database utility or spreadsheet program.

For more information about MQ Visual Browse go to:
https://www.capitalware.com/mqvb_overview.html

    Changes for MQ Visual Browse v3.2.0:

  • Added support for importing COBOL Copybook into the ‘Fixed Width’ configuration window for User Format.
  • Added ‘Show Temporary Queues’ checkbox on the Open Queue and MQ Monitoring Tools’ Open Queue dialog
  • Added the ability to sort the columns by clicking on the column header of List Of Queues and List Of Topics popup windows.
  • Added support for user defined date and time fields in the Preferences window.
  • Added the product version number to the Registration window.
  • Added code to convert Event messages as they are retrieved from the queue rather when the user opens the Message Edit window.
  • For CSV, FIX and Fixed Width Viewers, added the ability to click on the column header to sort the data by that column.
  • For CSV, FIX and Fixed Width layout manager, added ‘Type for Table Sorting’ column. It tells MQ Visual Browse how to sort the data in a particular column (i.e. String, Integer, Double, etc.).
  • Improved the handling of right-click popup menu on the main window, List of Queues and List of Topics windows
  • Enhanced the logging to include all GUI classes.
  • Fixed issue with preferences being removed when the language is changed.
  • Fixed issue with user selected language not being saved as a Preference.
  • Fixed an issue with the Choose Columns for MQMD.
  • Fixed an issue with the dock width setting not being removed when the Reset View was selected (under the View menu item).
  • Fixed an issue with handling PCF MQCFT_XR_SUMMARY messages from z/OS queue managers.
  • Fixed an issue with renaming a Group (on main window).

Regards,
Roger Lacroix
Capitalware Inc.

Capitalware, IBM MQ, IBM MQ Appliance, Linux, macOS (Mac OS X), MQ Visual Browse, Raspberry Pi, Windows Comments Off on MQ Visual Browse V3.2.0 Released

MQ Batch Toolkit v3.2.2 Released

Capitalware Inc. would like to announce the official release of MQ Batch Toolkit v3.2.2. This is a FREE upgrade for ALL licensed users of MQ Batch Toolkit. MQ Batch Toolkit allows users to manipulate, monitor and manage messages in a queue of an IBM MQ (formally WebSphere MQ & MQSeries) queue manager from a command-line or shell scripting environment.

MQ Batch Toolkit can run on the following platforms: Linux x86 64-bit, macOS (Mac OS X), Windows 7/8/8.1/10 and Raspberry Pi (ARM).

For more information about MQ Batch Toolkit go to:
https://www.capitalware.com/mqbt_overview.html

    Changes for MQ Batch Toolkit v3.2.2:

  • Fixed an issue with handling PCF MQCFT_XR_SUMMARY messages from z/OS queue managers.
  • Added code to output the directory used to write the CSV files from the MQ Monitoring Tools.

Regards,
Roger Lacroix
Capitalware Inc.

Capitalware, IBM MQ, Linux, macOS (Mac OS X), MQ Batch Toolkit, Raspberry Pi, Windows Comments Off on MQ Batch Toolkit v3.2.2 Released

MQTT Message Editing Suite V1.1.0 Released

Capitalware Inc. would like to announce the official release of MQTT Message Editing Suite V1.1.0.

MQTT Message Editing Suite (MMES) application allows users to subscribe, publish, edit, copy, delete, forward, backup, restore, import and export messages of a topic of an MQTT Broker.

The messages of a topic are presented in a table format similar to a spreadsheet program. MMES is an MQTT (MQ Telemetry Transport) client that connects to an MQTT Broker. MQTT is a machine-to-machine (M2M)/Internet of Things (IoT) connectivity protocol.

MMES supports MQTT protocol versions 3.1, 3.1.1 and 5.0.

MMES is a great tool for IoT (Internet of Things) application programmers, developers, quality assurance testers, and production support personnel. The tool allows for quick problem solving because the data is presented in a very logical and insightful manner.

MMES is able to connect to any remote MQTT Broker. The remote MQTT Broker can be on any platform. The following is a sample of the MQTT Brokers that MMES can connect to: 2lemetry, Apache ActiveMQ, Apache Apollo, EMQ, GnatMQ, HBMQTT, HiveMQ, IBM MessageSight, IBM MQ, JoramMQ, Moquette, Mosquitto, MQTT.js, RabbitMQ, RSMB, Software AG Universal Messaging, Solace, ThingMQ and VerneMQ.

MMES has full language support for the following 55 languages: Amharic, Arabic, Azerbaijani, Bengali, Cebuano, Chinese (Mandarin China), Chinese (Mandarin Taiwan), Czech, Danish, Dutch, English, Finnish, French, German, Greek, Gujarati, Hausa, Hebrew, Hindi, Hungarian, Igbo, Indonesian, Italian, Japanese, Javanese, Kannada, Korean, Malay, Malayalam, Marathi, Norwegian, Panjabi, Pashto, Persian, Polish, Portuguese, Romanian, Russian, Shona, Sindhi, Spanish, Sundanese, Swahili, Swedish, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Uzbek, Vietnamese, Xhosa, Yoruba and Zulu.

MMES is designed to run on a desktop platform that supports Java SE 8 (or higher). This includes: Linux x86, macOS (Mac OS X), Windows 7/8/8.1/10 and Raspberry Pi (ARM)..

Here’s screen-shots (click on the image to see a larger picture):

Message Edit
XML Viewer
JSON Viewer
Fixed Width Viewer
CSV Viewer
FIX Viewer
HEX Viewer
Visual Message Data
Message Moving Average
Ping Broker
Broker Status Monitor
 

For more information about MQTT Message Editing Suite, please go to:
https://www.capitalware.com/mmes_overview.html

Regards,
Roger Lacroix
Capitalware Inc.

Capitalware, Linux, macOS (Mac OS X), MQTT, MQTT Message Editing Suite, Raspberry Pi, Windows Comments Off on MQTT Message Editing Suite V1.1.0 Released

Oracle Flip Flops on Commercial Licensing for Java

Yup, as the subject line says, Oracle has flip flopped on how Oracle is licensing Java for commercial use.

This FAQ pertains to Oracle Java SE releases starting April 16, 2019 and has been updated to reflect the new Oracle No-Fee Terms and Conditions License available for Oracle Java 17 and later starting September 14, 2021.

Oracle JDK 17 and later is available under the Oracle No-Fee Terms and Conditions License which permits free use for all users.

Clearly, back in 2018, someone at Oracle thought they could make a boat load of cash off Java users. All it did was back fire on Oracle and make companies hate Oracle more than they already did.

Why would anyone care about Oracle and their JDK/JRE releases when many companies have stepped up and offered free licenses for JDK/JRE releases?

So, it took 30 months for Oracle to realize that they had screwed up. It was probably when customers starting leaving Oracle and it hit them in the pocket book!!! Since, we all know that Oracle is a greedy money-grubbing company!

I’m particularly pissed off because when Oracle made the licensing switch back in April of 2019, they caused Excelsior to close and sell their business to Huawei. Excelsior was put in a no-win situation regarding the collection of licensing fees. Excelsior Jet is a great tool for compiling and linking Java code into native binary executables. The current/last release of Excelsior Jet can compile Java 8 code, so I will continue to use it and sometime in the future, I’ll switch to GraalVM.

Regards,
Roger Lacroix
Capitalware Inc.

Java, JMS, Linux, macOS (Mac OS X), Programming, Unix, Windows Comments Off on Oracle Flip Flops on Commercial Licensing for Java

IBM MQ Fix Pack 9.0.0.12 Released

IBM has just released Fix Pack 9.0.0.12 for IBM MQ V9.0 LTS
https://www.ibm.com/support/pages/downloading-ibm-mq-90012

Regards,
Roger Lacroix
Capitalware Inc.

Fix Packs for MQ, IBM i (OS/400), IBM MQ, IBM MQ Appliance, Unix, Windows Comments Off on IBM MQ Fix Pack 9.0.0.12 Released

C# .NET MQ Code to Publish to a Topic

A couple of years ago, I posted a blog item called: C# .NET MQ Code to Subscribe to a Topic about subscribing to a topic using C# .NET code. I just realized that I never posted a C# .NET sample code to publish to a topic. So, here go – enjoy.

You can download the source code from here.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using IBM.WMQ;

/// <summary> Program Name
/// MQTest81
///
/// Description
/// This C# class will connect to a remote queue manager
/// and publish a message to a topic using a managed .NET environment.
///
/// Sample Command Line Parameters
/// -h 127.0.0.1 -p 1414 -c TEST.CHL -m MQA1 -t abc/xyz -u tester -x mypwd
/// </summary>
/// <author>  Roger Lacroix
/// </author>
namespace MQTest81
{
   public class MQTest81
   {
      private Hashtable inParms = null;
      private Hashtable qMgrProp = null;
      private System.String qManager;
      private System.String topicString;

      /*
      * The constructor
      */
      public MQTest81()
          : base()
      {
      }

      /// <summary> Make sure the required parameters are present.</summary>
      /// <returns> true/false
      /// </returns>
      private bool allParamsPresent()
      {
         bool b = inParms.ContainsKey("-h") && inParms.ContainsKey("-p") &&
                  inParms.ContainsKey("-c") && inParms.ContainsKey("-m") &&
                  inParms.ContainsKey("-t");
         if (b)
         {
            try
            {
               System.Int32.Parse((System.String)inParms["-p"]);
            }
            catch (System.FormatException e)
            {
               b = false;
            }
         }

         return b;
      }

      /// <summary> Extract the command-line parameters and initialize the MQ variables.</summary>
      /// <param name="args">
      /// </param>
      /// <throws>  IllegalArgumentException </throws>
      private void init(System.String[] args)
      {
         inParms = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable(14));
         if (args.Length > 0 && (args.Length % 2) == 0)
         {
            for (int i = 0; i < args.Length; i += 2)
            {
               inParms[args[i]] = args[i + 1];
            }
         }
         else
         {
            throw new System.ArgumentException();
         }

         if (allParamsPresent())
         {
            qManager = ((System.String)inParms["-m"]);
            topicString = ((System.String)inParms["-t"]);

            qMgrProp = new Hashtable();
            qMgrProp.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);

            qMgrProp.Add(MQC.HOST_NAME_PROPERTY, ((System.String)inParms["-h"]));
            qMgrProp.Add(MQC.CHANNEL_PROPERTY, ((System.String)inParms["-c"]));

            try
            {
               qMgrProp.Add(MQC.PORT_PROPERTY, System.Int32.Parse((System.String)inParms["-p"]));
            }
            catch (System.FormatException e)
            {
               qMgrProp.Add(MQC.PORT_PROPERTY, 1414);
            }

            if (inParms.ContainsKey("-u"))
               qMgrProp.Add(MQC.USER_ID_PROPERTY, ((System.String)inParms["-u"]));

            if (inParms.ContainsKey("-x"))
               qMgrProp.Add(MQC.PASSWORD_PROPERTY, ((System.String)inParms["-x"]));

            logger("Parameters:");
            logger("  QMgrName ='" + qManager + "'");
            logger("  Topic String ='" + topicString + "'");

            logger("Connection values:");
            foreach (DictionaryEntry de in qMgrProp)
            {
               logger("  " + de.Key + " = '" + de.Value + "'");
            }
         }
         else
         {
            throw new System.ArgumentException();
         }
      }

      /// <summary> Connect, open topic, publish a message, close topic and disconnect. </summary>
      ///
      private void testPublish()
      {
         MQQueueManager qMgr = null;
         MQTopic publisher = null;
         int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
         MQPutMessageOptions pmo = new MQPutMessageOptions();
         System.String line = "This is a test message embedded in the MQTest81 program.";

         try
         {
            qMgr = new MQQueueManager(qManager, qMgrProp);
            logger("Successfully connected to " + qManager);

            publisher = qMgr.AccessTopic(topicString, null, MQC.MQTOPIC_OPEN_AS_PUBLICATION, openOptions);
            logger("Successfully opened " + topicString);

            // Define a simple MQ message, and write some text
            MQMessage sendmsg = new MQMessage();
            sendmsg.Format = MQC.MQFMT_STRING;
            sendmsg.MessageType = MQC.MQMT_DATAGRAM;
            sendmsg.MessageId = MQC.MQMI_NONE;
            sendmsg.CorrelationId = MQC.MQCI_NONE;

            // .NET defaults to 1200 which is Windows double byte
            // So, use 819 to get single byte character set.
            sendmsg.CharacterSet = 819;

            sendmsg.WriteString(line);

            // put the message on the outQ
            publisher.Put(sendmsg, pmo);
            logger("Message Data:> " + line);
         }
         catch (MQException mqex)
         {
            logger("CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode);
         }
         catch (System.IO.IOException ioex)
         {
            logger("Error: ioex=" + ioex);
         }
         finally
         {
            try
            {
               if (publisher != null)
               {
                  publisher.Close();
                  logger("Closed: " + topicString);
               }
            }
            catch (MQException mqex)
            {
               logger("CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode);
            }

            try
            {
               if (qMgr != null)
               {
                  qMgr.Disconnect();
                  logger("Disconnected from " + qManager);
               }
            }
            catch (MQException mqex)
            {
               logger("CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode);
            }
         }
      }

      private void logger(String data)
      {
         DateTime myDateTime = DateTime.Now;
         System.Console.Out.WriteLine(myDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff") + " " + this.GetType().Name + ": " + data);
      }

      /// <summary> main line</summary>
      /// <param name="args">
      /// </param>
      //        [STAThread]
      public static void Main(System.String[] args)
      {
         MQTest81 write = new MQTest81();

         try
         {
            write.init(args);
            write.testPublish();
         }
         catch (System.ArgumentException e)
         {
            System.Console.Out.WriteLine("Usage: MQTest81 -h host -p port -c channel -m QueueManagerName -t topicString [-u userID] [-x passwd]");
            System.Environment.Exit(1);
         }
         catch (MQException e)
         {
            System.Console.Out.WriteLine(e);
            System.Environment.Exit(1);
         }

         System.Environment.Exit(0);
      }
   }
}

Regards,
Roger Lacroix
Capitalware Inc.

.NET, C#, IBM MQ, Open Source, Programming, Windows Comments Off on C# .NET MQ Code to Publish to a Topic

C# .Net Program That Adds Message Properties to an MQ Message

The other day, a colleague emailed me asking if I had a sample C# .Net/MQ program that adds message properties to a message. So. I thought I would post it for everyone to use.

You can download the source code from here.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using IBM.WMQ;

/// <summary> Program Name
/// MQTest01P
///
/// Description
/// This C# class will connect to a remote queue manager
/// and put a message to a queue with a message property using a managed .NET environment.
///
/// Sample Command Line Parameters
/// -h 127.0.0.1 -p 1414 -c TEST.CHL -m MQA1 -q TEST.Q1 -u tester -x mypwd
/// </summary>
/// <author>  Roger Lacroix
/// </author>
namespace MQTest01P
{
   class MQTest01P
   {
      private Hashtable inParms = null;
      private Hashtable qMgrProp = null;
      private System.String qManager;
      private System.String outputQName;

      /*
      * The constructor
      */
      public MQTest01P()
         : base()
      {
      }

      /// <summary> Make sure the required parameters are present.</summary>
      /// <returns> true/false
      /// </returns>
      private bool allParamsPresent()
      {
         bool b = inParms.ContainsKey("-h") && inParms.ContainsKey("-p") &&
                  inParms.ContainsKey("-c") && inParms.ContainsKey("-m") &&
                  inParms.ContainsKey("-q");
         if (b)
         {
            try
            {
               System.Int32.Parse((System.String)inParms["-p"]);
            }
            catch (System.FormatException e)
            {
               b = false;
            }
         }

         return b;
      }

      /// <summary> Extract the command-line parameters and initialize the MQ variables.</summary>
      /// <param name="args">
      /// </param>
      /// <throws>  IllegalArgumentException </throws>
      private void init(System.String[] args)
      {
         inParms = Hashtable.Synchronized(new Hashtable());
         if (args.Length > 0 && (args.Length % 2) == 0)
         {
            for (int i = 0; i < args.Length; i += 2)
            {
               inParms[args[i]] = args[i + 1];
            }
         }
         else
         {
            throw new System.ArgumentException();
         }

         if (allParamsPresent())
         {
            qManager = ((System.String)inParms["-m"]);
            outputQName = ((System.String)inParms["-q"]);

            qMgrProp = new Hashtable();
            qMgrProp.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);

            qMgrProp.Add(MQC.HOST_NAME_PROPERTY, ((System.String)inParms["-h"]));
            qMgrProp.Add(MQC.CHANNEL_PROPERTY, ((System.String)inParms["-c"]));

            try
            {
               qMgrProp.Add(MQC.PORT_PROPERTY, System.Int32.Parse((System.String)inParms["-p"]));
            }
            catch (System.FormatException e)
            {
               qMgrProp.Add(MQC.PORT_PROPERTY, 1414);
            }

            if (inParms.ContainsKey("-u"))
               qMgrProp.Add(MQC.USER_ID_PROPERTY, ((System.String)inParms["-u"]));

            if (inParms.ContainsKey("-x"))
               qMgrProp.Add(MQC.PASSWORD_PROPERTY, ((System.String)inParms["-x"]));

            logger("MQ Parms:");
            logger("  QMgrName ='" + qManager + "'");
            logger("  Output QName ='" + outputQName+"'");

            logger("Connection values:");
            foreach (DictionaryEntry de in qMgrProp)
            {
               logger("  " + de.Key + " = '" + de.Value + "'");
            }
         }
         else
         {
            throw new System.ArgumentException();
         }
      }

      /// <summary> Connect, open queue, write a message, close queue and disconnect.
      ///
      /// </summary>
      /// <throws>  MQException </throws>
      private void testSend()
      {
         MQQueueManager qMgr = null;
         MQQueue outQ = null;
         System.String line = "This is a test message embedded in the MQTest01P program.";
         int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
         MQPutMessageOptions pmo = new MQPutMessageOptions();

         try
         {
            qMgr = new MQQueueManager(qManager, qMgrProp);
            logger("successfully connected to " + qManager);

            outQ = qMgr.AccessQueue(outputQName, openOptions);
            logger("successfully opened " + outputQName);

            // Define a simple MQ message, and write some text in UTF format..
            MQMessage sendmsg = new MQMessage();
            sendmsg.Format = MQC.MQFMT_STRING;
            sendmsg.MessageType = MQC.MQMT_DATAGRAM;
            sendmsg.MessageId = MQC.MQMI_NONE;
            sendmsg.CorrelationId = MQC.MQCI_NONE;

            // .NET defaults to 1200 which is Windows double byte
            // So, use 819 to get single byte character set.
            sendmsg.CharacterSet = 819;

            // Add string property with key of "ABC" and value of "test1"
            sendmsg.SetStringProperty("ABC", "test1");

            sendmsg.WriteString(line);

            // put the message on the outQ
            outQ.Put(sendmsg, pmo);
            logger("Message Data:> " + line);
         }
         catch (MQException mqex)
         {
            logger("CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode);
         }
         catch (System.IO.IOException ioex)
         {
            logger("ioex=" + ioex);
         }
         finally
         {
            try
            {
                if (outQ != null)
                {
                    outQ.Close();
                    logger("closed: " + outputQName);
                }
            }
            catch (MQException mqex)
            {
                logger("CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode);
            }

            try
            {
                if (qMgr != null)
                {
                    qMgr.Disconnect();
                    logger("disconnected from " + qManager);
                }
            }
            catch (MQException mqex)
            {
                logger("CC=" + mqex.CompletionCode + " : RC=" + mqex.ReasonCode);
            }
         }
      }

      private void logger(String data)
      {
         DateTime myDateTime = DateTime.Now;
         System.Console.Out.WriteLine(myDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff") + " " + this.GetType().Name + ": " + data);
      }

      /// <summary> main line</summary>
      /// <param name="args">
      /// </param>
      //        [STAThread]
      public static void Main(System.String[] args)
      {
         MQTest01P mqt = new MQTest01P();

         try
         {
            mqt.init(args);
            mqt.testSend();
         }
         catch (System.ArgumentException e)
         {
            System.Console.Out.WriteLine("Usage: MQTest01P -h host -p port -c channel -m QueueManagerName -q QueueName [-u userID] [-x passwd]");
            System.Environment.Exit(1);
         }
         catch (MQException e)
         {
            System.Console.Out.WriteLine(e);
            System.Environment.Exit(1);
         }

         System.Environment.Exit(0);
      }
   }
}

Regards,
Roger Lacroix
Capitalware Inc.

.NET, C#, IBM MQ, Open Source, Programming, Windows Comments Off on C# .Net Program That Adds Message Properties to an MQ Message

JMS/MQ Program That Creates Connection Factory from Scratch

On StackOverflow, someone asked a question about why their JMS/MQ code was failing. There are many errors in the code. Here is a fully functioning JMS/MQ program that will create the Connection Factory from scratch, connect to a remote queue manager and put a message to a queue.

You can download the source code from here.

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;

import javax.jms.*;

import com.ibm.msg.client.jms.*;
import com.ibm.msg.client.wmq.*;

/**
 * Program Name
 *  MQTestJMS51
 *
 * Description
 *  This java JMS class will connect to a remote queue manager and put a message to a queue.
 *  This code will create the Connection Factory from scratch.
 *
 * Sample Command Line Parameters
 *  -m MQA1 -h 127.0.0.1 -p 1414 -c TEST.CHL -q TEST.Q1 -u UserID -x Password
 *
 * @author Roger Lacroix
 */
public class MQTestJMS51
{
   private static final SimpleDateFormat  LOGGER_TIMESTAMP = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
   private Hashtable<String,String> params;

   public MQTestJMS51()
   {
      super();
      params = new Hashtable<String,String>();
   }

   /**
    * Make sure the required parameters are present.
    * @return true/false
    */
   private boolean allParamsPresent()
   {
      boolean b = params.containsKey("-h") && params.containsKey("-p") &&
                  params.containsKey("-c") && params.containsKey("-m") &&
                  params.containsKey("-q") &&
                  params.containsKey("-u") && params.containsKey("-x");
      
      return b;
   }

   /**
    * Extract the command-line parameters and initialize the MQ variables.
    * @param args
    * @throws IllegalArgumentException
    */
   private void init(String[] args) throws IllegalArgumentException
   {
      if (args.length > 0 && (args.length % 2) == 0)
      {
         for (int i = 0; i < args.length; i += 2)
         {
            params.put(args[i], args[i + 1]);
         }
      }
      else
      {
         throw new IllegalArgumentException();
      }

      if (!allParamsPresent())
      {
         throw new IllegalArgumentException();
      }
   }

   /**
    * Create a connection to the queue manager then publish a message to a queue.
    */
   private void handleIt() 
   {
      Connection conn = null;
      Session session = null;
      Destination destination = null;
      MessageProducer producer = null;
      
      try
      {
         /*
          * Set JVM system environment variables
          */
         System.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "false");
         
//         System.setProperty("javax.net.ssl.trustStore", trustedStore);
//         System.setProperty("javax.net.ssl.trustStorePassword", trustedStorePasswd);
         
         JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
         JmsConnectionFactory cf = ff.createConnectionFactory();

         // Set the properties
         cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, (String) params.get("-h"));
         try
         {
            cf.setIntProperty(WMQConstants.WMQ_PORT, Integer.parseInt((String) params.get("-p")));
         }
         catch (NumberFormatException e)
         {
            cf.setIntProperty(WMQConstants.WMQ_PORT, 1414);
         }
         
         cf.setStringProperty(WMQConstants.WMQ_CHANNEL, (String) params.get("-c"));
         cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
         cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, (String) params.get("-m"));
         cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "MQTestJMS51");
         cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
         
         cf.setStringProperty(WMQConstants.USERID, (String) params.get("-u"));
         cf.setStringProperty(WMQConstants.PASSWORD, (String) params.get("-x"));
         
//         cf.setStringProperty(WMQConstants.WMQ_SSL_CIPHER_SUITE, "TLS_RSA_WITH_AES_128_CBC_SHA256");
         
         conn = cf.createConnection((String) params.get("-u"), (String) params.get("-x"));
         logger("created connection.");
         
         // Start the connection
         conn.start();
         logger("started connection.");

         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         logger("created session.");

         /*
          * targetClient=0 means it is sending a JMS message
          * targetClient=1 means it is sending an MQ message (non JMS)
          */
         destination = session.createQueue("queue://" + (String) params.get("-m") + "/" + (String) params.get("-q") + "?targetClient=0");
         logger("created destination.");

         producer = session.createProducer(destination);
         logger("created producer.");
         
         sendMsg(session, producer);
      }
      catch (JMSException e)
      {
         if (e != null)
         {
            logger(e.getLocalizedMessage());
            e.printStackTrace();
            
            Exception gle = e.getLinkedException();
            if (gle != null)
               logger(gle.getLocalizedMessage());
         }
      }
      finally
      {
         try
         {
            if (producer != null)
            {
               producer.close();
               logger("closed producer.");
            }
         }
         catch (Exception e)
         {
            logger("producer.close() : " + e.getLocalizedMessage());
         }

         try
         {
            if (session != null)
            {
               session.close();
               logger("closed session.");
            }
         }
         catch (Exception e)
         {
            logger("session.close() : " + e.getLocalizedMessage());
         }

         try
         {
            if (conn != null)
            {
               conn.stop();
               logger("stopped connection.");
            }
         }
         catch (Exception e)
         {
            logger("conn.stop() : " + e.getLocalizedMessage());
         }

         try
         {
            if (conn != null)
            {
               conn.close();
               logger("closed connection.");
            }
         }
         catch (Exception e)
         {
            logger("connection.close() : " + e.getLocalizedMessage());
         }
      }
   }

   /**
    * Send a message to a queue.
    */
   private void sendMsg(Session session, MessageProducer producer)
   {
      try
      {
         long uniqueNumber = System.currentTimeMillis() % 1000;
         TextMessage msg = session.createTextMessage("Your lucky number today is " + uniqueNumber);

         producer.send(msg);
         logger("Sent message: " + msg);
      }
      catch (JMSException e)
      {
         if (e != null)
         {
            logger(e.getLocalizedMessage());
            e.printStackTrace();
            
            Exception gle = e.getLinkedException();
            if (gle != null)
               logger(gle.getLocalizedMessage());
         }
      }
   }

   /**
    * A simple logger method
    * @param data
    */
   public static void logger(String data)
   {
      String className = Thread.currentThread().getStackTrace()[2].getClassName();

      // Remove the package info.
      if ( (className != null) && (className.lastIndexOf('.') != -1) )
         className = className.substring(className.lastIndexOf('.')+1);

      System.out.println(LOGGER_TIMESTAMP.format(new Date())+" "+className+": "+Thread.currentThread().getStackTrace()[2].getMethodName()+": "+data);
   }

   /**
    * main line
    * @param args
    */
   public static void main(String[] args)
   {
      logger("starting...");
      try
      {
         MQTestJMS51 tj = new MQTestJMS51();
         tj.init(args);
         tj.handleIt();
      }
      catch (IllegalArgumentException e)
      {
         logger("Usage: java MQTestJMS51 -m QueueManagerName -h host -p port -c channel -q Queue_Name -u UserID -x Password");
      }
      catch (Exception e)
      {
         logger(e.getLocalizedMessage());
         e.printStackTrace();
      }
      logger("ending...");
   }
}

Regards,
Roger Lacroix
Capitalware Inc.

HPE NonStop, IBM i (OS/400), IBM MQ, IBM MQ Appliance, Java, JMS, Linux, macOS (Mac OS X), Programming, Raspberry Pi, Unix, Windows, z/OS Comments Off on JMS/MQ Program That Creates Connection Factory from Scratch

Ubuntu 21.10 Released

Canonical has just released Ubuntu v21.10.
https://releases.ubuntu.com/21.10/

Super-fast, easy to use and free, the Ubuntu operating system powers millions of desktops, netbooks and servers around the world. Ubuntu does everything you need it to. It’ll work with your existing PC files, printers, cameras and MP3 players. And it comes with thousands of free apps.

Regards,
Roger Lacroix
Capitalware Inc.

Linux, Open Source, Operating Systems Comments Off on Ubuntu 21.10 Released