当我通过基于 Java 的客户端程序发送消息时,为什么我的 WebSphere MQ(在 Windows 上)API Exit 没有记录任何内容?
我在 Windows 上为 WebSphere MQ 7 编写了一个 API EXIT,当我从命令行放入队列或从队列中获取一条简单消息时,例如:“amqsput”或“amqsget”,我会得到一些包含时间、消息数据、队列名称等信息的日志文件。
这就是我对用 Java 编写的测试程序的期望,但是当我使用下面的代码时:
MQMessage msg = new MQMessage();< br>msg.writeUTF("Hello, World!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo);
我收到空白日志文件。然后我使用下面的代码:
MQMessage msg = new MQMessage();
msg.writeString("Hello, World!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put( msg, pmo);
然后我在日志文件中看到了熟悉的数据。
我打开MQ资源管理器,在“消息浏览器”中看到两条消息: <强>
你好,世界!
%Hello, World!
我完全迷失了,这个“%”来自哪里?由于编码原因,我的 api 出口没有记录 put 操作?
任何建议将不胜感激! 谢谢你!
I wrote a API EXIT for WebSphere MQ 7 on Windows, when I put to or get from queue a simple message from command line like: "amqsput" or "amqsget", I would get some log files containing information like time, message data, queue name, etc.
That's what I expect for my test program writen in Java, but when I used code below:
MQMessage msg = new MQMessage();
msg.writeUTF("Hello, World!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo);
I got blank log file. Then I used code below:
MQMessage msg = new MQMessage();
msg.writeString("Hello, World!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo);
Then I saw familar data in log file.
I opened MQ explorer, I saw two messages in "Message Browser":
Hello, World!
%Hello, World!
I'm totally lost here, where is this "%" from? My api exit didn't record the put action because of the encoding?
Any advices would be appreciated!
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很确定我记得在某处读到
writeUTF()
输出长度信息以及字符串。啊,是的,这里是:
来自 IBM 自己的 doco on
WriteUTF()
:(我的斜体)。正如您已经发现的,
WriteString()
是无需长度即可完成此操作的方法。I'm pretty certain I remember reading somewhere that
writeUTF()
outputs length information as well as the string.Ah, yes, here it is:
From IBM's own doco on
WriteUTF()
:(my italics). As you've already discovered,
WriteString()
is the way to do it without a length.当您安装 API 出口时,必须停止并重新启动队列管理器才能加载出口。您是否有机会在执行第一个和第二个程序之间回收 QMgr?
另外,除非退出显式刷新输出缓冲区,否则您可能不会立即看到输出。这是对您所看到的行为的另一种可能的解释。
最后,您使用的是哪个版本的 WMQ? (执行
dspmq
来找出答案。)这是一个 APAR IC60172:64 位 WINDOWS 应用程序在 EXITS64 中找不到 API 退出,该问题已在 7.0.1.0 中修复,并且会解释 32 位程序和 64 位程序之间行为不同的差异关于退出。至于输出的差异,pax已经提供了链接。输出将包含 Java 和 ActiveX 中的长度字节,因此 doco 同样适用于您的情况。
When you install an API exit, the queue manager must be stopped and restarted in order to load the exit. Did you by any chance recycle the QMgr between executing the first and second programs?
Also, unless the exit explicitly flushes the output buffer you may not see the output immediately. This is another possible explanation for the behavior you are seeing.
Finally, what version of WMQ are you on? (Do a
dspmq
to find out.) Here's an APAR IC60172: 64-BIT WINDOWS APPLICATION DOES NOT FIND API EXIT IN EXITS64 which was fixed in 7.0.1.0 and would account for a difference between 32-bit programs and 64-bit programs behaving differently with regard to exits.As for the difference in output, pax has provided a link. The output would contain the length bytes in Java as well as ActiveX so the doco applies equally well in your case.