Is there a way to set the back-out threshold and back-out queue in Java? I don't have access to MQ Console to manually set these as I am using Testcontainers. So each test run should set these property on the queue. Currently I am using JMS to send messages to the queue, and I want to set a threshold to 3 so as soon as the threshold reaches I will transfer the message to the back-out queue. Currently the message redelivers indefinitely.
I tried using MQ as shown in this article. However, it just sends a message to the queue.
After reading the comments I tried doing through PCF
PCFMessageAgent agent = new PCFMessageAgent(queueManager);
PCFMessage request = new PCFMessage(MQConstants.MQCMD_CHANGE_Q);
request.addParameter(MQConstants.MQCA_Q_NAME, queueName);
request.addParameter(MQConstants.MQIA_BACKOUT_THRESHOLD, 3);
request.addParameter(MQConstants.MQCA_BACKOUT_REQ_Q_NAME, backoutQueue);
agent.send(request);
It just throws PCFException MQJE001: Completion Code 2, Reason 3014.
Thanks to @Morag for pointing me to right direction. For anyone who wants to setup.
PCFMessageAgent agent = new PCFMessageAgent(queueManager);
PCFMessage request = new PCFMessage(MQConstants.MQCMD_CHANGE_Q);
request.addParameter(MQConstants.MQCA_Q_NAME, queueName);
request.addParameter(MQConstants.MQIA_Q_TYPE, MQConstants.MQQT_LOCAL);
request.addParameter(MQConstants.MQIA_BACKOUT_THRESHOLD, 3);
request.addParameter(MQConstants.MQCA_BACKOUT_REQ_Q_NAME, backoutQueue);
agent.send(request);