Closed fshi7418 closed 3 years ago
Edit: adding context
Hi Frank,
Thanks for getting in touch. Firstly, I want to reassure you that your java steps look correct.
I am assuming you have taken the following steps:
amqsputc
in bindings modeamqsputc
in client mode (the mode where you connect with a Java client application in your question)Note: 2035 is MQRC_NOT_AUTHORIZED
I believe that your application may not be authorised to communicate with IBM MQ. In client mode, there must be a Windows group with authorisation granted to access MQ queues and put messages via channels.
Firstly, I would strongly recommend this tutorial: https://developer.ibm.com/tutorials/mq-connect-app-queue-manager-windows/
It includes the step of configuring your queue manager with some sensible developer default objects, including queues and channels, and the step of authorising the group to connect to MQ.
Note: if you follow the tutorial above, you will create a Windows user "mqclient" and authorise group members to access only queues with names beginning "DEV." If you want to use your queue with the name Q1, change the line in Step 5 from
setmqaut -m QM1 -n DEV.** -t queue -g mqclient +put +get +browse +inq
to
setmqaut -m QM1 -n Q1 -t queue -g mqclient +put +get +browse +inq
Once you've done this, you should be able to follow the steps in the Java tutorial and send messages with MQ.
This is explained on some level in this IBM Documentation tutorial https://www.ibm.com/docs/en/ibm-mq/9.2?topic=tutorials-tutorial-3-sending-message-client-server-configuration but we wrote the tutorial on IBM Developer to make this whole process clearer.
Let me know how you get on with it!
Max
Hello Max,
Thank you for your prompt reply. It worked!
Before I did not complete this tutorial because I hit a bottleneck when I tried to add local groups and users. I am on Windows 10 Home, so my PC manager wouldn't let me add groups/users there. I didn't know this was actually important so I just left the tutorial.
On Windows 10 (Home) all I had to do is run cmd as admin, then use net localgroup mqclient /add to add a local group called mqclient. Then, I go to Control Panel to add a local user called "app" with the password "passw0rd". Finally I go back to cmd and use net localgroup mqclient app /add to add "app" into the "mqclient" group.
And then after that everything worked as intended.
Thanks a lot, Frank
Glad to hear it worked Frank! Yes, Windows manages authorisation when you connect in this way so creating the groups is very important here.
Max
Hello,
I set up a local queue manager via MQ Explorer (v 9.2.2.0, Windows 10) via this tutorial: https://www.ibm.com/docs/en/ibm-mq/8.0?topic=tutorials-tutorial-1-sending-message-local-queue and then I try to run JmsPutGet with the method here: https://developer.ibm.com/components/ibm-mq/tutorials/mq-develop-mq-jms but haven't been able to get it to work.
In particular, I have tried to set up the constants in the script to put/get a message from the queue manager, as follows:
I then compile the file with the following command in Windows command line: javac -cp .\com.ibm.mq.allclient-9.1.4.0.jar;.\javax.jms-api-2.0.1.jar com\ibm\mq\samples\jms\JmsPutGet.java
Then I try to run the compiled program with: java -cp .\com.ibm.mq.allclient-9.1.4.0.jar;.\javax.jms-api-2.0.1.jar;. com.ibm.mq.samples.jms.JmsPutGet
I get a error with reason code 2035 and completion code 2. I have tried numerous ways to fix the issue, such as the ones listed here and here, but still get the same error.
I've also tried to change channel to DEV.APP.SVRCONN, but that gives an error with reason code 2540.
The task of put/get to a local queue should be straightforward but for whatever reason I haven't been able to get it to work... If you could provide any help at all, I would really appreciate it.
Many thanks, Frank