开发者

IBM MQSeries ActiveX Write Message Error

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'开发者_StackOverflowm 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?


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 an OPEN. In this case the problem could either be on the PUT or an implicit OPEN, depending on what's in the code that was not provided and whether it contains an OPEN.

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.


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜