当我通过基于 Java 的客户端程序发送消息时,为什么我的 WebSphere MQ(在 Windows 上)API Exit 没有记录任何内容?

发布于 2024-09-14 00:57:26 字数 775 浏览 8 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明月松间行 2024-09-21 00:57:26

我很确定我记得在某处读到 writeUTF() 输出长度信息以及字符串。


啊,是的,这里是:

来自 IBM 自己的 doco on WriteUTF()

此方法采用 ActiveX 字符串并将其以 UTF 格式写入消息数据缓冲区的当前位置。写入的数据由 2 字节长度组成,后跟字符数据。如果该方法成功,DataOffset 将按字符串的长度递增。

(我的斜体)。正如您已经发现的,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():

This method takes an ActiveX string and writes it into the message data buffer at the current position in UTF format. The data written consists of a 2-byte length followed by the character data. DataOffset is incremented by the length of the string if the method succeeds.

(my italics). As you've already discovered, WriteString() is the way to do it without a length.

金橙橙 2024-09-21 00:57:26

当您安装 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文