EOleException访问消息体 [英] EOleException on accessing message body

查看:875
本文介绍了EOleException访问消息体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试访问MSMQ消息对象的.Body属性时,Windows服务会抛出一个EOleException - 但是只有当此消息中包含的Xml文档有一个空列表节点时。



EOleException消息提示内存不足(异常代码-2147024882)。因为异常只发生在最小的可能的Xml文档,内存不能是真正的问题。接下来要记住的是访问权限的问题,但是所有好消息(如下所述)都会被处理而没有问题。



异常可以是(坏消息首先,许多好消息首先 - 然后坏消息,在调试器中运行或仅记录异常)。



使用同一个COM对象(MSMQ.MSMQQueueInfo)从一个VBScript中使用在同一台机器上不会产生任何错误。



访问除.Body之外的任何其他属性不会抛出异常,因此消息对象实例似乎被成功接收。






Windows服务


qInfo:= CreateOleObject('MSMQ.MSMQQueueInfo');
qTxDisp:= CreateOleObject('MSMQ.MSMQTransactionDispenser');
// ...
qTx:= qTxDisp.BeginTransaction;
qMessage:= qQueue.Receive(qTx,False,True,0);
// ...
sBody:= qMessage.Body; // throws EOleException

qMessage.BodyLength 会返回 165 >

 <?xml version =1.0encoding =Windows-1252?> 
< response space =Message =Entry_7>
< query>
< entrylist count =0>
< / entrylist>
< / query>
< / response>

此消息可靠地使服务代码抛出EOleExecption。



好消息

 <?xml version =1.0 =Windows-1252?> 
< response space =Message =Entry_7>
< query>
< entrylist count =2>
< entry>
< abc> 123< / abc>
< def> 456< / def>
< / entry>
< entry>
< abc> 789< / abc>
< def> 000< / def>
< / entry>
< / entrylist>
< / query>
< / response>

此邮件可靠无误地处理。



当将服务从Win2003机器移动到Win2008(32位标准)时,首次出现问题。

解决方案

VBScript工作正常,那么我想这是在MSMQ和Delphi服务之间的交互。



您是否尝试在独立应用程序中运行Delphi代码?



我还没有使用MSMQ,但也许你也可以尝试使用从消息队列的非事务性读取,看看它是否有区别(减少代码



一个潜在的原因可能是Win2008机器上不同的(较新的)MSXML库。


A Windows service when trying to access the .Body property of a MSMQ message object throws an EOleException - but only when the Xml document contained in this message has an empty list node.

The EOleException message complains about insufficient memory (exception code -2147024882). Since the exception only occurs with the smallest possible Xml document, memory cannot be the real issue. The next thing that comes to mind is a problem with access rights but then again all "good" messages (as described below) are processed without problems.

The exception can be reproduced under any thinkable condition ("bad" message first, many "good" messages first - then "bad" message, run in debugger or just logging the exception); it doesn't matter if the code shown below is run as a service or as a simple excecutable.

Using the same COM object (MSMQ.MSMQQueueInfo) from within a VBScript on the same machine does not produce any errors.

Accessing any other properties apart from .Body doesn't throw an exception so the message object instance seems to be received sucessfully. Also the transaction receiving the message can be comitted sucessfully if the .Body property is not accessed.


Windows Service code

//...
qInfo    := CreateOleObject('MSMQ.MSMQQueueInfo');
qTxDisp  := CreateOleObject('MSMQ.MSMQTransactionDispenser');
//...
qTx := qTxDisp.BeginTransaction;
qMessage := qQueue.Receive(qTx, False, True, 0);
//...
sBody := qMessage.Body; //throws EOleException

The qMessage.BodyLength property returns the value 165 for "bad" messages as shown below.

"Bad" message

<?xml version="1.0" encoding="Windows-1252"?>
<response space="" Message="Entry_7">
    <query>
        <entrylist count="0">
        </entrylist>
    </query>
</response>

This message reliably makes the service code throw an EOleExecption.

"Good" message

<?xml version="1.0" encoding="Windows-1252"?>
<response space="" Message="Entry_7">
    <query>
        <entrylist count="2">
            <entry>
                <abc>123</abc>
                <def>456</def>
            </entry>
            <entry>
                <abc>789</abc>
                <def>000</def>
            </entry>
        </entrylist>
    </query>
</response>

This message is reliably processed without problems.

The problem first occured when moving the service from a Win2003 machine to a Win2008 (32-bit Standard).

解决方案

If the VBScript works fine, then I guess that it is something in the interaction between MSMQ and the Delphi service.

Have you tried to run the Delphi code in a standalone application?

I have not yet worked with MSMQ, but maybe you can also try to use a non transactional read from the message queue to see if it makes a difference (reduce the code to be as small/simple as possble).

A potential reason could be a different (newer) MSXML library on the Win2008 machine.

这篇关于EOleException访问消息体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆