2014-07-23 26 views
0

我在使用IronPython訪問MSMQ中的專用隊列時遇到以下異常。 (1)當我使用IronPython控制檯發送和接收消息時,在我的腳本上使用完全相同的命令,它可以工作,(2)私人消息實際上是存在的(即'。\ private $ \ sample) (3)我已經將私人消息的'每個人'用戶的權限設置爲完全控制。腳本中的IronPython:MessageQueue.Receive()異常

這是我使用的代碼段,無論是在IPY控制檯和我的腳本來完成消息的接收:

import clr 
clr.AddReference('System.Messaging') 
from System.Messaging import * 
queue_name = '.\\private$\sample' 
queue = None 
if MessageQueue.Exists(queue_name) = queue = MessageQueue(queue_name) 
else : queue = MessageQueue.Create(queue_name) 
print queue.Receive().Body # As mentioned this works in ipy console, but not on script 

這裏的例外:

System.Messaging.MessageQueueException (0x80004005): The queue does not exist or you do 
not have sufficient permissions to perform the operation. 

at System.Messaging.MessageQueue.ResolveFormatNameFromQueuePath(String queuePath, 
Boolean throwException) 

at System.Messaging.MessageQueue.get_FormatName() 

at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, 
CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction 
internalTransaction, MessageQueueTransactionType transactionType) 

at System.Messaging.MessageQueue.Receive() 

at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame) 

at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) 

at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 
arg2) 

at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, 
T1 arg1) 

at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) 

at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) 

希望有人有一個想法。提前致謝!

回答

0

我有一個類似的問題,根本原因是超過了MSMQ的存儲配額!這似乎與錯誤消息不相關,這使得它難以檢測到... 要更改此配額,請右鍵單擊消息隊列(例如,使用Windows Server 2003從計算機管理),然後選擇屬性... (我無法發佈圖片,因爲我是新用戶),但在屬性窗口中,您會在第一個標籤中找到可編輯的存儲限制字段。

要檢查服務器上當前使用的存儲,請打開存儲的路徑並檢查其大小:(打開相同屬性窗口中的存儲選項卡,並獲取存儲文件夾的路徑)如果大小配額與存儲文件夾的大小相似,則這是您問題的根源。

如果您沒有權限增加此配額限制,則應該將您的用戶添加到郵件排隊屬性窗口的「安全」選項卡中。

希望這有助於...