Author |
Message
|
naory |
Posted: Sat Oct 15, 2005 10:27 am Post subject: setting user to outgoing messages |
|
|
Novice
Joined: 05 Oct 2005 Posts: 17
|
Hi,
I am trying to set the user id for sent messages from the application using the JAVA API with no success.
the queue is opened with the following options:
Code: |
private static final int QOPEN_WRITE_ONLY =
MQC.MQOO_OUTPUT |
MQC.MQOO_SET_ALL_CONTEXT |
MQC.MQOO_SET_IDENTITY_CONTEXT |
MQC.MQOO_BIND_NOT_FIXED |
MQC.MQOO_FAIL_IF_QUIESCING; |
and messages are sent with the following options:
Code: |
MQMessage message = new MQMessage();
message.messageType = MQC.MQMT_DATAGRAM;
message.format = MQC.MQFMT_STRING;
message.writeString("some message text");
// specify for COD:
message.replyToQueueManagerName = rtoqm;
message.replyToQueueName = rtoq;
message.report =
MQC.MQRO_NEW_MSG_ID |
MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID |
MQC.MQRO_DEAD_LETTER_Q |
MQC.MQRO_COD_WITH_FULL_DATA;
//message options:
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SYNCPOINT;
|
i make the following call to send the message and specify "someuser" as the alternative user:
Code: |
MQQueueManager queueManager = new MQQueueManager("qmgrName");
MQQueue queue = queueManager.accessQueue(queuename,
QOPEN_WRITE_ONLY,
null, // default queue manager
null, // no dynamic queue name
"someuser"); // alternate user id |
but still get a blank userid.
I've also tried setting the user in the following way:
Code: |
//message options:
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SYNCPOINT |
MQC.MQPMO_SET_IDENTITY_CONTEXT;
message.userId = "someuser"; |
but get exception for invalid options: com.ibm.mq.MQException: Completion Code 2, Reason 2046
can anyone please advise how to acomplish this
thanks
naor |
|
Back to top |
|
 |
hopsala |
Posted: Sat Oct 15, 2005 11:29 am Post subject: |
|
|
 Guardian
Joined: 24 Sep 2004 Posts: 960
|
|
Back to top |
|
 |
wschutz |
Posted: Sat Oct 15, 2005 12:13 pm Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Me thinks you shouldn't be setting both of these:
Code: |
MQC.MQOO_SET_ALL_CONTEXT |
MQC.MQOO_SET_IDENTITY_CONTEXT | |
Try with just set identity.... _________________ -wayne |
|
Back to top |
|
 |
naory |
Posted: Sat Oct 15, 2005 2:02 pm Post subject: |
|
|
Novice
Joined: 05 Oct 2005 Posts: 17
|
setting the MQC.MQOO_ALTERNATE_USER_AUTHORITY only caused yet another 2035 error
however when i removed the MQC.MQOO_SET_IDENTITY_CONTEXT i can see the user on my outgoing messages!!
Thanks for your help.
NY |
|
Back to top |
|
 |
hopsala |
Posted: Sun Oct 16, 2005 4:27 am Post subject: |
|
|
 Guardian
Joined: 24 Sep 2004 Posts: 960
|
naory wrote: |
setting the MQC.MQOO_ALTERNATE_USER_AUTHORITY only caused yet another 2035 error |
2035 is a good thing, it means your prog has set the options correctly, but has no authorities to use alternateUserId; you have to use setmqaut with +altusr option to the user you MQCONN with.
I believe you are confusing two seperate things - alternate user authorization and setting MQMD.UserId: AlternateUserId means your prog puts the message under a different set of authorities, i.e the authorities of the alternate user; to use this option your prog must have +altusr special authority, since this using altuser pretty much means you can have any authority you want. MQMD.UserId, on the other hand, is just another MQMD field which is normally set automatically, and if you wish to change it you must have some type of set_context authority.
I advise you read about this in the manuals before proceeding to put your code into production, you may be doing the wrong thing, while getting a seemingly correct result. |
|
Back to top |
|
 |
naory |
Posted: Mon Oct 17, 2005 8:22 am Post subject: |
|
|
Novice
Joined: 05 Oct 2005 Posts: 17
|
thanks for your help so far hopsala.
now i'm a little confused.
Quote: |
you have to use setmqaut with +altusr option to the user you MQCONN with. |
why do i also need to run the setmqaut command? isn't there a way to do this from the API?
naor |
|
Back to top |
|
 |
naory |
Posted: Mon Oct 17, 2005 9:51 am Post subject: |
|
|
Novice
Joined: 05 Oct 2005 Posts: 17
|
let me explain.
my ultimate goal is to be able to set the authority/user that the java application is using to put messages on a remote qmanager.
the required authority/user is 'cbxmqm' and this is also the unix user that is starting MQ, the qmanagers and the queues (member of the mqm group).
here is what i got when i logged in as the cbxmqm user and run the dspmqaut command:
Code: |
[cbxmqm@qaapp2 cbxgt]$ dspmqaut -m QM.CLIENT.REMOTE -n Q.OUT -t q -p cbxmqm
Entity cbxmqm has the following authorizations for object Q.OUT:
get
browse
put
inq
set
crt
dlt
chg
dsp
passid
passall
setid
setall
clr |
so i assume that this user already has the right authorities.
however messages i send from the java application (running in the same linux box but started by 'appuser' user) show null/blank user and cause CODs to end up on my client's deadq.
i am looking for a way to resolve this by setting this from the application.
as i explaind above i managed to set the MQMD.UserId to 'cbxmqm' and i now can see using the MQ explorer that the messages have 'cbxmqm' as the user but i have yet to test this with my client.
is that the proper way to resolve this?
will setting the altUser resolve this?
naor |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Oct 17, 2005 9:55 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
naory wrote: |
my ultimate goal is to be able to set the authority/user that the java application is using to put messages on a remote qmanager. |
Did you try looking at all of the properties of MQEnvironment? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Tibor |
Posted: Tue Oct 18, 2005 2:08 am Post subject: |
|
|
 Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
We use the next method redefining pubsub users:
Code: |
setmqaut -m RINO -n SYSTEM.BROKER.CONTROL.QUEUE -t queue -g _intgrp +inq +put +setid |
and the group "_intgrp" contains all of these users.
Tibor |
|
Back to top |
|
 |
naory |
Posted: Sat Oct 22, 2005 1:22 pm Post subject: |
|
|
Novice
Joined: 05 Oct 2005 Posts: 17
|
a combination of the MQMD userID as well as setting it in the MQEnvironment got me the desired results.
Thank you all for your great help in getting a better understanding of it all.
naor |
|
Back to top |
|
 |
|