MQ

 View Only
  • 1.  Connection pool

    Posted Wed September 01, 2021 09:27 AM
    I want to implement MQ connection pool without JMS. like using MQSimpleConnectionManager. I tried to get help from document site but it doesn't contains any full block/program. any suggestion will be very helpful.


    ------------------------------
    Irfan Ali Shaheed
    ------------------------------


  • 2.  RE: Connection pool

    Posted Thu September 02, 2021 08:47 AM
    Edited by Brian S Paskin Thu September 02, 2021 08:53 AM

    Hi, here is a sample program, with hardcoded values.  You if you change the max number of connections to 1, then the app will fail after 1 connection stating the all connections are in use (MQRC 2025).

    - Brian

    EDIT:  Since it did not format well.  I placed it in my Github.

    ------------------------------
    Brian S Paskin
    Sr. Cloud Engineer
    IBM Technology Garage
    ------------------------------



  • 3.  RE: Connection pool

    Posted Fri September 03, 2021 05:32 AM
    Great help. Thanks

    ------------------------------
    Irfan Ali Shaheed
    ------------------------------



  • 4.  RE: Connection pool

    Posted Tue October 05, 2021 10:54 AM
    Hi Brian/All,
    I have implemented the solution as per your advice. It working absolutely perfect. 
    The challenge I am facing is in multithreaded environment. Requirement is to run 4(max, min is 2) different threads, which will try to use the 4 different pool to make MQ connections. I am trying with 2 threads as of now, problem here is each time its creating new connection to use. I have refer below IBM site for help,

    https://www.ibm.com/docs/en/ibm-mq/9.0?topic=cpimcj-supplying-different-connection-pool-in-mq-classes-java

    Please suggest.

    ------------------------------
    Irfan Ali Shaheed
    ------------------------------



  • 5.  RE: Connection pool

    Posted Tue October 05, 2021 11:11 AM
    Can you show your code?  

    Brian

    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 6.  RE: Connection pool

    Posted Thu October 21, 2021 10:26 AM
    Hi, do we have any way to check if each MQ manager are really using same MQSimpleConnectionManager, my code is basically as below,
    block start{
    MQQueueManager qmgr1=new MQQueueManager(null,mqSimpleConMan);
    requestedQueue1=qmgr1.accessQueue(Q_Name, options)

    MQQueueManager qmgr2=new MQQueueManager(null,mqSimpleConMan);
    requestedQueue2=qmgr2.accessQueue(Q_Name, options)

    After use I am closing both MQQueueManager 
    requestedQueue1.close()
    requestedQueue2.close()
    qmgr1.disconnect()
    qmgr2.disconnect()
    }Block ends

    Thread.run(above code)

    I have done the coding. Just wanted to make sure it's working as expected (like utilizing MQSimpleConnectionManager each time)

    ------------------------------
    Irfan Ali Shaheed
    ------------------------------



  • 7.  RE: Connection pool

    Posted Fri October 22, 2021 12:49 PM
    Usually you would have a different connection pool for each QMGR.  Utilising the same connection pool limits the number of overall connections to the limit set on the connection pool, not for each QMGR.  It also makes the pool not really reusable since the connections would need to be tossed away each time instead of keeping the connections open.

    You can use mqSimpleConMan.getActive() to see the number of active connections currently in use.  


    Brian

    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------



  • 8.  RE: Connection pool

    Posted Mon October 25, 2021 08:35 AM
    Thanks Brian,
    any thoughts about the code I shared(privately)?

    ------------------------------
    Irfan Ali Shaheed
    ------------------------------



  • 9.  RE: Connection pool

    Posted Mon October 25, 2021 08:46 AM
    No, I did not look at it.  If you need private support, then please open a support ticket with IBM.

    Brian

    ------------------------------
    Brian S Paskin
    Sr. Web Engineer
    IBM Tech Garage
    ------------------------------