MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Any native Library for IBM MQ in Powershell

  • 1.  Any native Library for IBM MQ in Powershell

    Posted Thu December 05, 2024 10:26 AM

    Hi Team,

    I am exploring how to query the IBM MQ Server using Powershell and the IBM MQ Client. Is there a native Powershell library available for this purpose? My research pointed me to the 'MO74' library, but it appears to be outdated (from 2012) which doesn't use MQ Client 

    My goal is to retrieve the status of queues, channels, and the depth of queues. Are there any recommended best practices for using Powershell to achieve this effectively?

    I found these 2 options:

    1) Can I use "MO74" library considering its old?

    2) Use the MQ Client library and import the required IBM MQ .NET client libraries to the Powershell script and query from the .NET library?

    Thanks.



    ------------------------------
    Naveen P
    ------------------------------


  • 2.  RE: Any native Library for IBM MQ in Powershell

    Posted Fri December 06, 2024 02:56 AM

    Hi,
    MO74 is the only Powershell library available and it hasn't been updated since then. Please can you raise an RFE for it using the link here



    ------------------------------
    Ram Subba Rao Chalamalasetti
    ------------------------------



  • 3.  RE: Any native Library for IBM MQ in Powershell

    Posted Sun December 08, 2024 06:59 PM

    Hi Ram,

      Thank you for confirming. I tried this link but couldn't find "IBM MQ" in the product list. Could you let me know if there's another way to access it?



    ------------------------------
    Naveen P
    ------------------------------



  • 4.  RE: Any native Library for IBM MQ in Powershell

    Posted Sun December 08, 2024 11:08 PM

    Try this link for raising an MQ requirement: https://integration-development.ideas.ibm.com/

    Could you tell us a little more about what doesn't work when you try to use MO74 please?

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 5.  RE: Any native Library for IBM MQ in Powershell

    Posted Sun December 08, 2024 11:17 PM
    Edited by Naveen P Sun December 08, 2024 11:20 PM

    Hi ,

       I am currently exploring options to implement a PowerShell script for retrieving key status information for IBM MQ queues, specifically focusing on:

    • Queue depth
    • Message rate
    • Queue status

    While researching this, I came across references to the MO74 package as well as using .NET client libraries to fetch this data. However, I noticed that the last update for the MO74 package was around 2015, and I'm hesitant to use this as it may be outdated.

    Given this, I would like to inquire if there are more modern and widely used approaches to achieve the same goal-specifically, if the .NET client libraries are the recommended method for interacting with MQ and extracting queue metrics.

    I would appreciate any insights on best practices for automating queue monitoring, especially with PowerShell, and whether the .NET client libraries are considered a more reliable and future-proof solution for this use case.

    Thank you for your assistance!



    ------------------------------
    Naveen P
    ------------------------------



  • 6.  RE: Any native Library for IBM MQ in Powershell

    Posted Mon December 09, 2024 09:49 AM

    Hi Naveen

    Have you considered looking at the rest API? I'm not sure about message rate (but that seems a tricky one), but the other info you can get from there.

    https://www.ibm.com/docs/en/ibm-mq/9.2?topic=adminqmgrqmgrnamequeue-get

    An example



    ------------------------------
    Regards
    Matthias Blomme
    Integration Specialist
    Integration Designers
    Turnhout
    ------------------------------



  • 7.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed December 11, 2024 05:45 PM

    Hi Naveen - quick update. I tried to install MO74 on my x64 Windows 11 machine, and was unable to because of a requirement for .NET V2 ( I only have V8!). I have passed on my finding to the owner of MO74 and another IBMer and told them about your thread here. Hopefully they will reply soon.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 8.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed December 11, 2024 05:51 PM

    Thanks Morag. I tried same but couldn't install. For now, I am using powershell scripts on the MQ Server itself (Just for testing purpose) .



    ------------------------------
    Naveen P
    ------------------------------



  • 9.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed December 11, 2024 06:03 PM

    Hi Naveen,

    What are you using to do that? Surely we can get those working with an MQ Client too? 

    Happy to help you try to do that.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 10.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed December 11, 2024 06:11 PM

    Hi Morag,

    I am doing a POC if the commands provided in the IBM MQ Doc are getting all the fields required for my requirement. 

    I have couple of questions on MQ Client -

    1) The MQ Client is different service and should we need to have any seperate licence / subscription to use this or its Free ?

    2) If I am not wrong, MQ Client needs to installed on the remote server  to query multiple MQ Servers ?

    Thanks



    ------------------------------
    Naveen P
    ------------------------------



  • 11.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed December 11, 2024 06:20 PM

    MQ Client is free. It is licenced by means of the fact that you have a queue manager with a licence. The MQ Client is not much use without a queue manager to connect to!

    The MQ Client would need to be installed on the machine where you wanted to run the tool you are using to do the inquiry if that is a different machine from where the queue manager is running.

    So, help me to help you. What are you currently using to run commands in PowerShell on the local machine where your queue manager is running? We should be able to make that work with an MQ Client. I will help you if you can tell me what you are currently using.

    I can also help you with getting the fields you want. But one thing at a time :-)

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 12.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed December 11, 2024 10:32 PM

    Thanks Morag. That will be helpful.

    OS - Windows Server 2022

    IBM MQ Server - 9.3

    IBM MQ Explorer installed

    4 Queue Managers in Active on that server

    3  Commands are used as below:

    1) "dspmq -m $queueManagerName " - This command is used to get the status of Each Queue Manager . If the STATUS is not RUNNING then send email to Team with  Queue Manager Name

    2) "runmqsc $queueManagerName  DISPLAY QLOCAL(*) CURDEPTH "  -- This command is used to get current depth of all the Local Queues in a Queue Manager. If the Current depth > Threshold then send email to Team with  Queue Manager Name, Queue Name

    3)"runmqsc $queueManagerName  DISPLAY CHSTATUS(*) STATUS"  -- This command is used to status  of all the channels in a Queue Manager. If the status is not ACTIVE then send email to Team with  Queue Manager Name, Channel Name

    Powershell script is scheduled to run for every 5 mins. There is no increase in Queue Managers (Its always 4 Queue Managers, Only single instance )



    ------------------------------
    Naveen P
    ------------------------------



  • 13.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed December 11, 2024 11:06 PM

    Hi Naveen,

    Thanks for that. Very helpful.

    Let's look at each command in turn.

    1. The dspmq command can only be run local to the queue manager. I believe the REST interface gives you a similar view. However, if either of your next two commands fails to connect to the queue manager, i.e. before even getting as far as running the DISPLAY command, then you have as much of an answer about queue manager availability as you need.
    2. For runmqsc - you can connect as a client. For now we can do this quite simply with an environment variable for basic non-TLS connectivity to prove the point. However, you can also set this connectivity up with user ID/password or TLS and digital certificates should you need that when you get past just doing a PoC.
      Set up the environment where you are running your script with:-
      set MQSERVER=PSHELL.SVRCONN/TCP/ip-qm-machine(1414)
      You can change "PSHELL.SVRCONN" to whatever you decide to call the SVRCONN channel name you define on your queue manager for this purpose. You must set "ip-qm-machine" to the IP address or hostname where your queue manager is running - you can try straight away by using localhost and running your script on the same machine, just connecting with a client instead of locally. You must set the port number where I have written 1414 to whatever your queue manager TCP/IP listener port is.
      then use runmqsc with the -c parameter before the queue manager name.
    3. See #2

    I will say something else though. You might be interested to know that instead of having to ask your queue manager every 5 minutes whether there are any queues that have a depth that has gone over a particular threshold, or whether there are any channels that have had a problem, you can instead have your queue manager emit a notification when those things are true. There are several benefits to this:-

    • You get timely notification instead of having to wait, in the worse case, nearly 5 minutes, to find out.
    • Your queue manager doesn't have to expend effort in answering your queries, in order to tell you that there is nothing of interest.

    You can let me know if you are interested in learning more about this. I won't write more just now.

    Have a quick try of the runmqsc in client mode and see if you can get that working first and we can go from there. If you need help getting the SVRCONN and TCP/IP listener set up, just let me know.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 14.  RE: Any native Library for IBM MQ in Powershell

    Posted Thu December 12, 2024 04:51 PM

    > You can let me know if you are interested in learning more about this. I won't write more just now.

    I'm interested!  I think I know what you are talking about, but if you happen to have a tutorial or some examples I'd love to see them.

    I also think we should point out that if using the client, you are dependent of the queue manager being active and the channel the SVRCONN channel on the queue manager being active so you can communicate to it.  If you can't communicate, it could be QM down, or channel down, or a communications failure, but it any of those cases you know its time to check on the queue manager directly.



    ------------------------------
    Vincent Greene
    IT Consultant
    Technology Expert labs
    IBM
    Vincent.Greene@ibm.com


    The postings on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
    ------------------------------



  • 15.  RE: Any native Library for IBM MQ in Powershell

    Posted Mon January 13, 2025 04:05 PM

    > > You can let me know if you are interested in learning more about this. I won't write more just now.

    > I'm interested!  I think I know what you are talking about, but if you happen to have a tutorial or some examples I'd love to see them.

    I decided that this might be useful for everyone, so I wrote a little example in this blog post: I want to know when queues are filling

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 16.  RE: Any native Library for IBM MQ in Powershell

    Posted Wed January 22, 2025 02:32 PM

    Thanks Morag,

    I am trying to use it as well and I'm getting the specific error:

    Error accessing queue: A constructor was not found. Cannot find an appropriate constructor for type
    IBM.WMQ.MQEnvironment.

    At the lines:

    try {
            $connectionOptions = New-Object IBM.WMQ.MQEnvironment
            $connectionOptions.Hostname = $properties.HostName

    ....

    Since I just downloaded and installed it today I'm guessing there isn't a fix yet. :)

    -- Ray



    ------------------------------
    Ray Wilson
    ------------------------------