IBM MQSeries ActiveX 写入消息错误
我有一个带有用于 ActiveX 的 MQSeries 自动化类的 VB6 应用程序。问题是当我在队列中写入消息时。我使用此代码:
这就是我打开连接和相关队列的方式:
Set MQSess = New MQSession
//Access Queue
Set QMgr = MQSess.AccessQueueManager(QueueManagerName)
Dim Queue As MQQueue
Dim msg As MQMessage
Dim pmo As MQPutMessageOptions
Dim ArrCar() As Byte
Set pmo = New MQPutMessageOptions
Set Queue = QMgr.AccessQueue(QueueName, OpenOption , RemoteQueueManagerName)
//OpenOption is a integer with value of 16 (MQOO_OUTPUT)
strMsgAppo = Translate("*MESSAGE_TO_INSERT*", ASCII_To_EBCDIC_Table())
ReDim ArrCar(Len(strMsgAppo) - 1)
For lngI = 1 To Len(strMsgAppo)
ArrCar(lngI - 1) = Asc(Mid(strMsgAppo, lngI, 1))
Next lngI
Call msg.Write(ArrCar) //Write the ByteArray
Call Queue.Put(msg, pmo)
ASCII_To_EBCDIC_Table 是用于更改编码的函数。
我从 MQ 收到的错误是:
MQAX200.MQMessage::Write CompletionCode = 2, ReasonCode = 2043, ReasonName = MQRC_OBJECT_TYPE_ERROR
是否有人使用此 activex,可以帮助我如何在队列?
I've a VB6 application with MQSeries Automation Classes for ActiveX. The problem is when i'm writing the message con the queue. I use this code :
This is how I open the connection and the relative queue :
Set MQSess = New MQSession
//Access Queue
Set QMgr = MQSess.AccessQueueManager(QueueManagerName)
Dim Queue As MQQueue
Dim msg As MQMessage
Dim pmo As MQPutMessageOptions
Dim ArrCar() As Byte
Set pmo = New MQPutMessageOptions
Set Queue = QMgr.AccessQueue(QueueName, OpenOption , RemoteQueueManagerName)
//OpenOption is a integer with value of 16 (MQOO_OUTPUT)
strMsgAppo = Translate("*MESSAGE_TO_INSERT*", ASCII_To_EBCDIC_Table())
ReDim ArrCar(Len(strMsgAppo) - 1)
For lngI = 1 To Len(strMsgAppo)
ArrCar(lngI - 1) = Asc(Mid(strMsgAppo, lngI, 1))
Next lngI
Call msg.Write(ArrCar) //Write the ByteArray
Call Queue.Put(msg, pmo)
The ASCII_To_EBCDIC_Table is a function used to change the encoding.
The error i'm getting from MQ is :
MQAX200.MQMessage::Write CompletionCode = 2, ReasonCode = 2043, ReasonName = MQRC_OBJECT_TYPE_ERROR
Is Anyone using this activex and can help me on how to write message in a queue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在提供的代码片段中,我没有看到与 QMgr 的连接是在哪里建立的,也没有看到队列是在哪里打开的。必须先完成这两个步骤,然后才能将消息放入队列。
当
PUT
或OPEN
的消息选项字段中存在无效选项时,会出现 2043 原因代码。在这种情况下,问题可能出在 PUT 上,也可能出在隐式OPEN
上,具体取决于未提供的代码中的内容以及它是否包含OPEN
。我的建议是参考安装中提供的 .Net 示例,并在这些示例与您的应用程序之间进行协调。在默认 V7 安装中,这些示例位于
C:\Program Files (x86)\IBM\WebSphere MQ\tools\dotnet\samples
中。In the code snippet provided, I'm not seeing where the connection to the QMgr is made nor where the queue is opened. Both of these steps must be completed before it is possible to put messages on the queue.
The 2043 reason code occurs when there is an invalid option in the Message Options field for a
PUT
or anOPEN
. In this case the problem could either be on the PUT or an implicitOPEN
, depending on what's in the code that was not provided and whether it contains anOPEN
.My suggestion would be to refer to the .Net samples provided in the installation and reconcile between those and your application. The samples reside at
C:\Program Files (x86)\IBM\WebSphere MQ\tools\dotnet\samples
in a default V7 installation.失败发生在您的 msg.Write 上,在将 .CharacterSet 属性设置为 37 (EBCDIC) 后,您可能应该使用 .WrirteString 方法。
Translate() 函数的黑客方法可能会起作用,但前提是分配给 Byte 数组。当数据转换回 Unicode 时,您可能会看到混乱。或者,如果 Translate() 确实返回一个 Byte 数组,您将会遇到 Unicode 字符串中的 8 位数据的混乱(这可能没问题,但对于这个 MQ 库则不然)。
你也许可以直接扔掉 Translate() 和你的桌子。
有关此 API 的 IBM 手册称为“使用组件对象模型接口e。"一探究竟!
The failure is on your msg.Write, and you should probably be using the .WrirteString method instead, after setting the .CharacterSet property to 37 (EBCDIC).
The hackish approach of your Translate() function might work, but only if assigned to a Byte array. As you have things you're likely to see scrambling when the data is converted back to Unicode. Or if Translate() does return a Byte array you'll have a mess with 8-bit data in a Unicode String (which can be fine but not with this MQ library).
You can probably just throw Translate() and your table away.
The IBM manual on this API is called "Using the Component Object Model Interface." Check it out!