1

Windows Server 2003 を実行しているサーバーでメッセージ キューを作成し、メッセージを送信できるクライアント プログラムを作成しましたが、それらをプルバックできません。メッセージを送信するために、次のコードを使用しています (トランザクション キューを使用していることに注意してください)。

    MessageQueueTransaction transaction = new MessageQueueTransaction();
    transaction.Begin();
    messageQueue.Send("Hello MSMQ!", "Title", transaction);
    transaction.Commit();
    transaction.Dispose();

私がこれを試したメッセージをプルするには、成功しませんでした:

    MessageQueueTransaction transaction = new MessageQueueTransaction();
    try
    {
        transaction.Begin();
        MessageQueue queue = new MessageQueue(QUEUE_NAME);
        Message msg = queue.Receive(new TimeSpan(0, 0, 5), transaction);
        msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(String) });
        Console.WriteLine(msg.Label + " - " + msg.Body);
        transaction.Commit();
    }
    catch (Exception e)
    {
        transaction.Abort();
        Console.WriteLine(e.Message);
    }

queue.Receive() 呼び出しで例外が発生しています。これに関する同様の質問をたくさん見つけました。この記事には 3 つの解決策がありましたが、どれもうまくいきませんでした。サーバーのファイアウォールを無効にし、レジ​​ストリに DWORD 値を作成しましたが、提供された解決策の 1 つが Windows Server 2008 に固有のもののようです。

4

0 に答える 0