I am trying to connect to a remote Enterprise MQ server using JMS in Spring boot. When I try to connect to a local MQ, I am able to make the connection and send messages, but the same code doesnt work for the remote MQ. Below are the error details -
Caused by: com.ibm.msg.client.jms.DetailedJMSSecurityException: JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'MQGWD2' with connection mode 'Client' and host name 'mqcad1.sdde.deere.com(2171)'.
Please check if the supplied username and password are correct on the QueueManager to which you are connecting.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:531)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:215)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:424)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:8475)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:7815)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl._createConnection(JmsConnectionFactoryImpl.java:303)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:236)
at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6016)
at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:136)
at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:209)
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.doCreateConnection(UserCredentialsConnectionFactoryAdapter.java:188)
at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.createConnection(UserCredentialsConnectionFactoryAdapter.java:162)
at org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:428)
at org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:353)
at org.springframework.jms.connection.SingleConnectionFactory.getConnection(SingleConnectionFactory.java:328)
at org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:243)
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:197)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:494)
... 53 more
Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2035' ('MQRC_NOT_AUTHORIZED').
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203)
Please note , for local MQ server I use - admin,passw0rd as the credentials which are set by default. For Enterprise MQ, we have created an application ID and gained access to the MQ using this appID. I am giving all the details - queue manager, host, port, channel, queue name and username(appID) and password while hitting the queue.
My question is - the same code is working for local queue but I get unauthorized when I hit the remote one. Also , we do not get any error logs for the remote MQ, so it is quite difficult to debug the reason for getting Unauthorized Error. Could anyone help in this regard? Any inputs will really be helpful. What changes when we hit the remote MQ?
I have only 2 files -
properties -
ibm.mq.queueManager=QM1
ibm.mq.channel=DEV.ADMIN.SVRCONN
ibm.mq.connName=localhost(1414)
ibm.mq.user=admin(this is replaced by appID when I hit remote MQ)
ibm.mq.password=passw0rd(pwd for appID in case of remote MQ)
Created a test controller -
@EnableJms
@Component
@RestController
public class SendMessage {
@Autowired
JmsTemplate jmsTemplate;
@GetMapping("send")
String send(){
try{
jmsTemplate.convertAndSend("DEV.QUEUE.1", "Hello World!");
return "OK";
}catch(JmsException ex){
return "FAIL";
}
}