Search code examples
javaspring-bootapache-camelibm-mq

How to set MQOO_INPUT_EXCLUSIVE option for IBM MQ Connection Factory in Camel Consumer with Spring boot?


I am trying to setup spring boot application that needs to consume messages from an IBM MQ queue while ensuring that only one instance of the application receives all messages to maintain message ordering. To achieve this, I need to configure the Camel consumer to open a connection with the MQOO_INPUT_EXCLUSIVE option enabled.

I have already set up the JmsComponent, MQQueueConnectionFactory and RouteBuilder in my application, but I couldn't find the property key and value to enable the MQOO_INPUT_EXCLUSIVE option for the connection via MQQueueConnectionFactory.

Tried this approach by changing the Default input open option in the queue setting and it works, but is there a way to achieve this by passing this property while opening connection?

I have tried searching online for information on how to set this option, but I haven't been able to find a solution,the results were either not relevant to camel based configuration or those were outdated. Can anyone help me with this? Any help would be greatly appreciated!


Solution

  • Update: I checked from on my side that setting MQConstants.MQOO_INPUT_EXCLUSIVE (package - com.ibm.mq.constants) in the method setMQConnectionOptions(int cTagOpt) from MQQueueConnectionFactory doesn't work at all and throws error.

    So, It's impossible to set the MQOO_INPUT_EXCLUSIVE via MQQueueConnectionFactory.

    I have some useful links which will help you to understand why it's impossible and check if this helps.

    Only the option that's available to you is to access queue from queueManager with the openOption as MQOO_INPUT_EXCLUSIVE

    MQQueue queue = queueManager.accessQueue("name-of-the-queue", MQConstants.MQOO_INPUT_EXCLUSIVE);
    

    Refer to Java Docs on MQConstants here.