【发布时间】:2011-04-16 11:01:30
【问题描述】:
我们的代码在 weblogic 和 MQ 6.0 中运行。无论我使用默认的createQueueConnection() 还是createQueueConnection("myuserid","mypassword"),它似乎总是使用用户标识mqm。请参阅下面的代码。
当我从版本 6.0 连接到较旧的 mq 安装 5 时,使用默认的 createQueueConnection() 似乎会抛出以下错误 javax.jms.JMSSecurityException: MQJMS2013: invalid security authentication supplied for MQQueueManager,除非我发送一个空白用户 ID/密码,如 createQueueConnection("","") 中那样
我怎样才能让 myuserid 被发送呢?
Hashtable properties = new Hashtable(2);
properties.put(Context.PROVIDER_URL,context);
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
InitialContext ctx = new InitialContext(properties);
QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("QCF");
QueueConnection qc = qcf.createQueueConnection();
javax.jms.Queue q = (javax.jms.Queue) ctx.lookup("MYQUEUE");
QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
TextMessage tm = qs.createTextMessage();
tm.setText(outString);
QueueSender sender = qs.createSender(q);
sender.send(tm);
sender.close();
qs.close();
qc.close();
【问题讨论】: