Message Queueとは? わかりやすく解説

MessageQueue イベント


パブリック イベントパブリック イベント

参照参照

関連項目

MessageQueue クラス
System.Messaging 名前空間
Message クラス
DefaultPropertiesToSend クラス
MessageQueueException
MessageQueue
Peek
Receive
BeginPeek
BeginReceive
MessageQueue.Path プロパティ
MessageQueue.Label プロパティ
MessageQueue.FormatName プロパティ
MessageQueue.QueueName プロパティ
MessageQueue.MachineName プロパティ

MessageQueue クラス

メッセージ キューサーバーのキューアクセスできるようにします。

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

Public Class MessageQueue
    Inherits Component
    Implements IEnumerable
public class MessageQueue : Component, IEnumerable
public ref class MessageQueue : public
 Component, IEnumerable
public class MessageQueue extends Component
 implements IEnumerable
public class MessageQueue extends
 Component implements IEnumerable
解説解説

メッセージ キュー技術使用すると、一時的にオフラインになる可能性のある異種ネットワーク異種システム間で、異な時間実行される複数アプリケーション相互に通信できますアプリケーションは、キューからのメッセージ送信受信、またはピーク (削除せず読み取ること) します。メッセージ キューWindows 2000 および Windows NTオプションコンポーネントです。個別インストールする必要があります

MessageQueue クラスは、メッセージ キューラッパー クラスです。メッセージ キューには複数のバージョンがあり、使用しているオペレーティング システムによって MessageQueue クラス動作が少し異なりますメッセージ キュー各バージョンにおける固有の機能の詳細については、MSDNプラットフォーム SDK ドキュメントトピックWhat's New in Message Queuing」を参照してください

MessageQueue クラスによりメッセージ キューキューへの参照できます。MessageQueue コンストラクタパス指定して既存リソース接続するか、サーバー新しキュー作成できますSend(Object)、Peek、または Receive呼び出す前にMessageQueue クラス新しインスタンス既存キュー関連付ける必要があります。この時点で、CategoryLabel などのキュー プロパティ操作ができるようになります

MessageQueue は、同期と非同期2 種類メッセージ取得サポートします同期メソッドである PeekReceive使用してプロセス スレッド新しメッセージキュー到達するまで待機する時間間隔指定します非同期メソッドである BeginPeekBeginReceive使用すると、キューメッセージ到達するまで、メイン アプリケーションタスク別のスレッド継続します。これらのメソッドは、コールバック オブジェクトと状態オブジェクト使用してスレッド間で情報通信することによって動作します

MessageQueue クラス新しインスタンス作成するときに、新しメッセージ キューキュー作成されません。その代わりに、Create(String)、DeletePurge の各メソッド使用してサーバーキュー管理できます

Purge とは異なりCreate(String)Deletestatic メンバであるため、MessageQueue クラス新しインスタンス作成せずに呼び出すことができます

MessageQueue オブジェクトPath プロパティには、表示名、FormatName、Label など、3 種類ある名前のうちの 1 つ設定できます表示名とは、キューの MachineName プロパティと QueueName プロパティ定義される名前であり、パブリック キュー場合MachineName \ QueueNameプライベート キュー場合MachineName \ Private$ \ QueueName です。FormatName プロパティ使用すると、メッセージ キューオフラインアクセスできますキューLabel プロパティ使用してキューPath設定することもできます

MessageQueueインスタンス初期プロパティ値の一覧については、MessageQueue コンストラクタトピック参照してください

使用例使用例

さまざまな種類パス構文使用して新しMessageQueue オブジェクト作成するコード例次に示しますいずれの場合も、コンストラクタパス定義されているキューメッセージ送信します

Imports System
Imports System.Messaging

Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '         
        ' This example demonstrates several ways to set
        ' a queue's path.
        

        Public Shared Sub
 Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New
 MyNewQueue()

            myNewQueue.SendPublic()
            myNewQueue.SendPrivate()
            myNewQueue.SendByLabel()
            myNewQueue.SendByFormatName()
            myNewQueue.MonitorComputerJournal()
            myNewQueue.MonitorQueueJournal()
            myNewQueue.MonitorDeadLetter()
            myNewQueue.MonitorTransactionalDeadLetter()

            Return

        End Sub 'Main


        ' References public queues.
        Public Sub SendPublic()

            Dim myQueue As New
 MessageQueue(".\myQueue")
            myQueue.Send("Public queue by path name.")

            Return

        End Sub 'SendPublic


        ' References private queues.
        Public Sub SendPrivate()

            Dim myQueue As New
 MessageQueue(".\Private$\myQueue")
            myQueue.Send("Private queue by path name.")

            Return

        End Sub 'SendPrivate


        ' References queues by label.
        Public Sub SendByLabel()

            Dim myQueue As New
 MessageQueue("Label:TheLabel")
            myQueue.Send("Queue by label.")

            Return

        End Sub 'SendByLabel


        ' References queues by format name.
        Public Sub SendByFormatName()

            Dim myQueue As New
 _
                MessageQueue("FormatName:Public="
 + _
                    "5A5F7535-AE9A-41d4-935C-845C2AFF7112")
            myQueue.Send("Queue by format name.")

            Return

        End Sub 'SendByFormatName


        ' References computer journal queues.
        Public Sub MonitorComputerJournal()

            Dim computerJournal As New
 MessageQueue(".\Journal$")

            While True

                Dim journalMessage As Message
 = _
                    computerJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub 'MonitorComputerJournal


        ' References queue journal queues.
        Public Sub MonitorQueueJournal()

            Dim queueJournal As New
 _
                            MessageQueue(".\myQueue\Journal$")

            While True

                Dim journalMessage As Message
 = _
                    queueJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub 'MonitorQueueJournal


        ' References dead-letter queues.
        Public Sub MonitorDeadLetter()
            Dim deadLetter As New
 MessageQueue(".\DeadLetter$")

            While True

                Dim deadMessage As Message
 = deadLetter.Receive()

                ' Process the dead-letter message.

            End While

            Return

        End Sub 'MonitorDeadLetter


        ' References transactional dead-letter queues.
        Public Sub MonitorTransactionalDeadLetter()

            Dim TxDeadLetter As New
 MessageQueue(".\XactDeadLetter$")

            While True

                Dim txDeadLetterMessage As
 Message = _
                    TxDeadLetter.Receive()

                ' Process the transactional dead-letter message.

            End While

            Return

        End Sub 'MonitorTransactionalDeadLetter

End Class 'MyNewQueue 

using System;
using System.Messaging;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        //**************************************************
        // Provides an entry point into the application.
        //         
        // This example demonstrates several ways to set
        // a queue's path.
        //**************************************************

        public static void
 Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            myNewQueue.SendPublic();
            myNewQueue.SendPrivate();
            myNewQueue.SendByLabel();
            myNewQueue.SendByFormatName();
            myNewQueue.MonitorComputerJournal();
            myNewQueue.MonitorQueueJournal();
            myNewQueue.MonitorDeadLetter();
            myNewQueue.MonitorTransactionalDeadLetter();

            return;
        }
        
        // References public queues.
        public void SendPublic()
        {
            MessageQueue myQueue = new MessageQueue(".\\myQueue");
            myQueue.Send("Public queue by path name.");

            return;
        }

        // References private queues.
        public void SendPrivate()
        {
            MessageQueue myQueue = new 
                MessageQueue(".\\Private$\\myQueue");
            myQueue.Send("Private queue by path name.");

            return;
        }

        // References queues by label.
        public void SendByLabel()
        {
            MessageQueue myQueue = new MessageQueue("Label:TheLabel");
            myQueue.Send("Queue by label.");

            return;
        }

        // References queues by format name.
        public void SendByFormatName()
        {
            MessageQueue myQueue = new 
                MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4" + 
                "-935C-845C2AFF7112");
            myQueue.Send("Queue by format name.");

            return;
        }

        // References computer journal queues.
        public void MonitorComputerJournal()
        {
            MessageQueue computerJournal = new 
                MessageQueue(".\\Journal$");
            while(true)
            {
                Message journalMessage = computerJournal.Receive();
                // Process the journal message.
            }
        }

        // References queue journal queues.
        public void MonitorQueueJournal()
        {
            MessageQueue queueJournal = new 
                MessageQueue(".\\myQueue\\Journal$");
            while(true)
            {
                Message journalMessage = queueJournal.Receive();
                // Process the journal message.
            }
        }
        
        // References dead-letter queues.
        public void MonitorDeadLetter()
        {
            MessageQueue deadLetter = new 
                MessageQueue(".\\DeadLetter$");
            while(true)
            {
                Message deadMessage = deadLetter.Receive();
                // Process the dead-letter message.
            }
        }

        // References transactional dead-letter queues.
        public void MonitorTransactionalDeadLetter()
        {
            MessageQueue TxDeadLetter = new 
                MessageQueue(".\\XactDeadLetter$");
            while(true)
            {
                Message txDeadLetter = TxDeadLetter.Receive();
                // Process the transactional dead-letter message.
            }
        }

    }
}
#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:

   // References public queues.
   void SendPublic()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
      myQueue->Send( "Public queue by path name." );
      return;
   }


   // References private queues.
   void SendPrivate()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\Private$\\myQueue"
 );
      myQueue->Send( "Private queue by path name." );
      return;
   }


   // References queues by label.
   void SendByLabel()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "Label:TheLabel" );
      myQueue->Send( "Queue by label." );
      return;
   }


   // References queues by format name.
   void SendByFormatName()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "FormatName:Public=5A5F7535-AE9A-41d4
 -935C-845C2AFF7112" );
      myQueue->Send( "Queue by format name." );
      return;
   }


   // References computer journal queues.
   void MonitorComputerJournal()
   {
      MessageQueue^ computerJournal = gcnew MessageQueue( ".\\Journal$"
 );
      while ( true )
      {
         Message^ journalMessage = computerJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References queue journal queues.
   void MonitorQueueJournal()
   {
      MessageQueue^ queueJournal = gcnew MessageQueue( ".\\myQueue\\Journal$"
 );
      while ( true )
      {
         Message^ journalMessage = queueJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References dead-letter queues.
   void MonitorDeadLetter()
   {
      MessageQueue^ deadLetter = gcnew MessageQueue( ".\\DeadLetter$" );
      while ( true )
      {
         Message^ deadMessage = deadLetter->Receive();
         
         // Process the dead-letter message.
      }
   }


   // References transactional dead-letter queues.
   void MonitorTransactionalDeadLetter()
   {
      MessageQueue^ TxDeadLetter = gcnew MessageQueue( ".\\XactDeadLetter$"
 );
      while ( true )
      {
         Message^ txDeadLetter = TxDeadLetter->Receive();
         
         // Process the transactional dead-letter message.
      }
   }

};


//*************************************************
// Provides an entry point into the application.
//         
// This example demonstrates several ways to set
// a queue's path.
//*************************************************
int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   myNewQueue->SendPublic();
   myNewQueue->SendPrivate();
   myNewQueue->SendByLabel();
   myNewQueue->SendByFormatName();
   myNewQueue->MonitorComputerJournal();
   myNewQueue->MonitorQueueJournal();
   myNewQueue->MonitorDeadLetter();
   myNewQueue->MonitorTransactionalDeadLetter();
   return 0;
}

package MyProject;

import System.*;
import System.Messaging.*;

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
    //**************************************************
    // Provides an entry point into the application.
    //         
    // This example demonstrates several ways to set
    // a queue's path.
    //**************************************************
    public static void main(String[]
 args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();

        myNewQueue.SendPublic();
        myNewQueue.SendPrivate();
        myNewQueue.SendByLabel();
        myNewQueue.SendByFormatName();
        myNewQueue.MonitorComputerJournal();
        myNewQueue.MonitorQueueJournal();
        myNewQueue.MonitorDeadLetter();
        myNewQueue.MonitorTransactionalDeadLetter();

        return;
    } //main

    // References public queues.
    public void SendPublic()
    {
        MessageQueue myQueue = new MessageQueue(".\\myQueue");
        myQueue.Send("Public queue by path name.");
        return;
    } //SendPublic

    // References private queues.
    public void SendPrivate()
    {
        MessageQueue myQueue = new MessageQueue(".\\Private$\\myQueue");
        myQueue.Send("Private queue by path name.");
        return;
    } //SendPrivate

    // References queues by label.
    public void SendByLabel()
    {
        MessageQueue myQueue = new MessageQueue("Label:TheLabel");
        myQueue.Send("Queue by label.");
        return;
    } //SendByLabel

    // References queues by format name.
    public void SendByFormatName()
    {
        MessageQueue myQueue =
            new MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4"
            + "-935C-845C2AFF7112");
        myQueue.Send("Queue by format name.");
        return;
    } //SendByFormatName

    // References computer journal queues.
    public void MonitorComputerJournal()
    {
        MessageQueue computerJournal = new MessageQueue(".\\Journal$");
        while (true) {
            Message journalMessage = computerJournal.Receive();
            // Process the journal message.
        }
    } //MonitorComputerJournal

    // References queue journal queues.
    public void MonitorQueueJournal()
    {
        MessageQueue queueJournal = new MessageQueue(".\\myQueue\\Journal$");
        while (true) {
            Message journalMessage = queueJournal.Receive();
            // Process the journal message.
        }
    } //MonitorQueueJournal

    // References dead-letter queues.
    public void MonitorDeadLetter()
    {
        MessageQueue deadLetter = new MessageQueue(".\\DeadLetter$");
        while (true) {
            Message deadMessage = deadLetter.Receive();
            // Process the dead-letter message.
        }
    } //MonitorDeadLetter

    // References transactional dead-letter queues.
    public void MonitorTransactionalDeadLetter()
    {
        MessageQueue objTxDeadLetter = new MessageQueue(".\\XactDeadLetter$");
        while (true) {
            Message txDeadLetter = objTxDeadLetter.Receive();
            // Process the transactional dead-letter message.
        }
    } //MonitorTransactionalDeadLetter
} //MyNewQueue

アプリケーション固有の Order というクラス使用してメッセージキュー送信しキューからメッセージ受信するコード例次に示します

Imports System
Imports System.Messaging

    ' This class represents an object the following example 
    ' sends to a queue and receives from a queue.
    Public Class Order
        Public orderId As Integer
        Public orderTime As DateTime
    End Class 'Order


   
    Public Class MyNewQueue


        '
        ' Provides an entry point into the application.
        '         
        ' This example sends and receives a message from
        ' a qeue.
        '

        Public Shared Sub
 Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New
 MyNewQueue()

            ' Send a message to a queue.
            myNewQueue.SendMessage()

            ' Receive a message from a queue.
            myNewQueue.ReceiveMessage()

            Return

        End Sub 'Main


        '
        ' Sends an Order to a queue.
        '

        Public Sub SendMessage()

            ' Create a new order and set values.
            Dim sentOrder As New
 Order()
            sentOrder.orderId = 3
            sentOrder.orderTime = DateTime.Now

            ' Connect to a queue on the local computer.
            Dim myQueue As New
 MessageQueue(".\myQueue")

            ' Send the Order to the queue.
            myQueue.Send(sentOrder)

            Return

        End Sub 'SendMessage


        '
        ' Receives a message containing an Order.
        '

        Public Sub ReceiveMessage()

            ' Connect to the a queue on the local computer.
            Dim myQueue As New
 MessageQueue(".\myQueue")

            ' Set the formatter to indicate the body contains an Order.
            myQueue.Formatter = New XmlMessageFormatter(New
 Type() _
                {GetType(Order)})

            Try

                ' Receive and format the message. 
                Dim myMessage As Message =
 myQueue.Receive()
                Dim myOrder As Order = CType(myMessage.Body,
 Order)

                ' Display message information.
                Console.WriteLine(("Order ID: " +
 _
                    myOrder.orderId.ToString()))
                Console.WriteLine(("Sent: " + _
                    myOrder.orderTime.ToString()))

            Catch m As MessageQueueException
                ' Handle Message Queuing exceptions.

            Catch e As InvalidOperationException
                ' Handle invalid serialization format.
                Console.WriteLine(e.Message)


                ' Catch other exceptions as necessary.

            End Try

            Return

        End Sub 'ReceiveMessage

End Class 'MyNewQueue

using System;
using System.Messaging;

namespace MyProject
{

    // This class represents an object the following example 
    // sends to a queue and receives from a queue.
    public class Order
    {
        public int orderId;
        public DateTime orderTime;
    };    

    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        //**************************************************
        // Provides an entry point into the application.
        //         
        // This example sends and receives a message from
        // a queue.
        //**************************************************

        public static void
 Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            // Send a message to a queue.
            myNewQueue.SendMessage();

            // Receive a message from a queue.
            myNewQueue.ReceiveMessage();

            return;
        }


        //**************************************************
        // Sends an Order to a queue.
        //**************************************************
        
        public void SendMessage()
        {
            
            // Create a new order and set values.
            Order sentOrder = new Order();
            sentOrder.orderId = 3;
            sentOrder.orderTime = DateTime.Now;

            // Connect to a queue on the local computer.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Send the Order to the queue.
            myQueue.Send(sentOrder);

            return;
        }


        //**************************************************
        // Receives a message containing an Order.
        //**************************************************
        
        public  void ReceiveMessage()
        {
            // Connect to the a queue on the local computer.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Set the formatter to indicate body contains an Order.
            myQueue.Formatter = new XmlMessageFormatter(new
 Type[]
                {typeof(MyProject.Order)});
            
            try
            {
                // Receive and format the message. 
                Message myMessage =    myQueue.Receive(); 
                Order myOrder = (Order)myMessage.Body;

                // Display message information.
                Console.WriteLine("Order ID: " + 
                    myOrder.orderId.ToString());
                Console.WriteLine("Sent: " + 
                    myOrder.orderTime.ToString());
            }
            
            catch (MessageQueueException)
            {
                // Handle Message Queuing exceptions.
            }

            // Handle invalid serialization format.
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e.Message);
            }
            
            // Catch other exceptions as necessary.

            return;
        }
    }
}
#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;

// This class represents an object the following example 
// sends to a queue and receives from a queue.
ref class Order
{
public:
   int orderId;
   DateTime orderTime;
};


/// <summary>
/// Provides a container class for the example.
/// </summary>
ref class MyNewQueue
{
public:

   //*************************************************
   // Sends an Order to a queue.
   //*************************************************
   void SendMessage()
   {
      // Create a new order and set values.
      Order^ sentOrder = gcnew Order;
      sentOrder->orderId = 3;
      sentOrder->orderTime = DateTime::Now;

      // Connect to a queue on the local computer.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Send the Order to the queue.
      myQueue->Send( sentOrder );
      return;
   }

   //*************************************************
   // Receives a message containing an Order.
   //*************************************************
   void ReceiveMessage()
   {
      // Connect to the a queue on the local computer.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Set the formatter to indicate body contains an Order.
      array<Type^>^p = gcnew array<Type^>(1);
      p[ 0 ] = Order::typeid;
      myQueue->Formatter = gcnew XmlMessageFormatter( p );
      try
      {
         // Receive and format the message. 
         Message^ myMessage = myQueue->Receive();
         Order^ myOrder = static_cast<Order^>(myMessage->Body);

         // Display message information.
         Console::WriteLine( "Order ID: {0}", myOrder->orderId );
         Console::WriteLine( "Sent: {0}", myOrder->orderTime );
      }
      catch ( MessageQueueException^ ) 
      {
         // Handle Message Queuing exceptions.
      }
      // Handle invalid serialization format.
      catch ( InvalidOperationException^ e ) 
      {
         Console::WriteLine( e->Message );
      }

      // Catch other exceptions as necessary.
      return;
   }
};

//*************************************************
// Provides an entry point into the application.
//         
// This example sends and receives a message from
// a queue.
//*************************************************
int main()
{
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;

   // Send a message to a queue.
   myNewQueue->SendMessage();

   // Receive a message from a queue.
   myNewQueue->ReceiveMessage();
   return 0;
}
package MyProject;

import System.*;
import System.Messaging.*;

// This class represents an object the following example 
// sends to a queue and receives from a queue.
public class Order
{
    public int orderId;
    public DateTime orderTime;
} //Order

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
    //**************************************************
    // Provides an entry point into the application.
    //         
    // This example sends and receives a message from
    // a queue.
    //**************************************************
    public static void main(String[]
 args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();
        // Send a message to a queue.
        myNewQueue.SendMessage();
        // Receive a message from a queue.
        myNewQueue.ReceiveMessage();

        return;
    } //main

    //**************************************************
    // Sends an Order to a queue.
    //**************************************************
    public void SendMessage()
    {
        // Create a new order and set values.
        Order sentOrder = new Order();
        sentOrder.orderId = 3;
        sentOrder.orderTime = DateTime.get_Now();
        // Connect to a queue on the local computer.
        MessageQueue myQueue = new MessageQueue(".\\myQueue");
        // Send the Order to the queue.
        myQueue.Send(sentOrder);

        return;
    } //SendMessage

    //**************************************************
    // Receives a message containing an Order.
    //**************************************************
    public void ReceiveMessage()
    {
        // Connect to the a queue on the local computer.
        MessageQueue myQueue = new MessageQueue(".\\myQueue");
        // Set the formatter to indicate body contains an Order.
        myQueue.set_Formatter(new XmlMessageFormatter(new
 Type[] 
            { MyProject.Order.class.ToType() }));
        try {
            // Receive and format the message. 
            Message myMessage = myQueue.Receive();
            Order myOrder = (Order)(myMessage.get_Body());
            // Display message information.
            Console.WriteLine("Order ID: "+((Int32)myOrder.orderId).ToString());
            Console.WriteLine("Sent: " + myOrder.orderTime.ToString());
        }
        catch (MessageQueueException exp) {
            // Handle Message Queuing exceptions.
        }
        // Handle invalid serialization format.
        catch (InvalidOperationException e) {
            Console.WriteLine(e.get_Message());
        }
        // Catch other exceptions as necessary.
        return;
    } //ReceiveMessage
} //MyNewQueue
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
      System.Messaging.MessageQueue
スレッド セーフスレッド セーフ

マルチスレッド操作安全なのは、BeginPeek、BeginReceive、EndPeek、EndReceive、GetAllMessages、PeekReceive の各メソッドだけです。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MessageQueue メンバ
System.Messaging 名前空間
Message クラス
DefaultPropertiesToSend クラス
MessageQueueException
MessageQueue
Peek
Receive
BeginPeek
BeginReceive
Path
Label
FormatName
QueueName
MachineName

MessageQueue コンストラクタ ()

MessageQueue クラス新しインスタンス初期化します。既定コンストラクタ新しインスタンス初期化した後、そのインスタンス使用する前にインスタンスPath プロパティ設定する必要があります

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

public MessageQueue ()
public:
MessageQueue ()
public MessageQueue ()
public function MessageQueue ()
解説解説
使用例使用例

新しMessageQueue作成するコード例次に示します

// Connect to a queue on the local computer. You must set the queue's
// Path property before you can use the queue.
MessageQueue queue = new MessageQueue();
queue.Path = ".\\exampleQueue";
// Connect to a queue on the local computer. You must set the queue's
// Path property before you can use the queue.
MessageQueue queue = new MessageQueue();
queue.set_Path(".\\exampleQueue");
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MessageQueue クラス
MessageQueue メンバ
System.Messaging 名前空間
Path
QueueName
FormatName
Label

MessageQueue コンストラクタ (String)

指定したパスメッセージ キューキュー参照する MessageQueue クラス新しインスタンス初期化します。

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

public MessageQueue (
    string path
)
public:
MessageQueue (
    String^ path
)
public MessageQueue (
    String path
)
public function MessageQueue (
    path : String
)

パラメータ

path

この MessageQueue が参照するキューの場所。

例外例外
解説解説

パス書式名、ラベル判明している、メッセージ キュー特定のキューMessageQueue新しインスタンス結び付ける場合は、このオーバーロード使用しますキュー参照する最初アプリケーション排他アクセス許可与え場合は、DenySharedReceive プロパティtrue設定するか、読み取りアクセス制限パラメータを渡すコンストラクタ使用する必要があります

MessageQueue コンストラクタMessageQueue クラス新しインスタンスインスタンス化ます。メッセージ キュー新しキュー作成しません。メッセージ キュー新しキュー作成するには、Create(String) を使用します

path パラメータ構文は、参照するキュー種類によって異なります詳細については、次の表を参照してください

代わりに、FormatName または Label使用してキューパス記述することもできます詳細については、次の表を参照してください

参照

構文

書式

FormatName: [ format name ]

FormatName:Public= 5A5F7535-AE9A-41d4-935C-845C2AFF7112

FormatName:DIRECT=SPX: NetworkNumber; HostNumber\QueueName

FormatName:DIRECT=TCP: IPAddress\QueueName

FormatName:DIRECT=OS: MachineName\QueueName

ラベル

Label: [ label ]

Label: TheLabel

オフライン作業をするには、パス構文ではなく書式構文コンストラクタ使用する必要がありますパス構文使用すると、パス書式名に解決するプライマリ ドメイン コントローラ利用できないため、例外スローさます。

MessageQueueインスタンス初期プロパティ値を次の表に示します。これらの値は、path パラメータ指定されパスメッセージ キューキュー プロパティに基づきます。

プロパティ

初期値

Authenticate

false

BasePriority

0

Category

Empty

DefaultPropertiesToSend

DefaultPropertiesToSend クラス既定コンストラクタ設定される値。

EncryptionRequired

メッセージ キューキューのプライバシ レベル設定が "Body" の場合trueそれ以外場合false

Formatter

XmlMessageFormatter

Label

Empty

MachineName

メッセージ キューキューコンピュータプロパティの値。

MaximumJournalSize

InfiniteQueueSize

MaximumQueueSize

InfiniteQueueSize

MessageReadPropertyFilter

MessagePropertyFilter クラス既定コンストラクタ設定される値。

Path

コンストラクタ設定しない場合Empty

QueueName

コンストラクタ設定しない場合Empty

DenySharedReceive

false

UseJournalQueue

メッセージ キューオブジェクトの履歴設定有効な場合trueそれ以外場合false

Windows Mobile for Pocket PCWindows Mobile for SmartphoneWindows CE プラットフォームメモ : デバイスActive Directoryサポートされないため、.NET Compact Framework ではリモート キュートランザクションかどうか確認できません。リモート トランザクション キューメッセージ送信するには、コンストラクタに渡す path パラメータ;XACTONLY付加します詳細については、「.NET Compact Framework の MSMQ」を参照してください

使用例使用例

さまざまな種類パス構文使用して新しMessageQueue オブジェクト作成するコード例次に示しますいずれの場合も、コンストラクタパス定義されているキューメッセージ送信します

Imports System
Imports System.Messaging

Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '         
        ' This example demonstrates several ways to set
        ' a queue's path.
        

        Public Shared Sub
 Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New
 MyNewQueue()

            myNewQueue.SendPublic()
            myNewQueue.SendPrivate()
            myNewQueue.SendByLabel()
            myNewQueue.SendByFormatName()
            myNewQueue.MonitorComputerJournal()
            myNewQueue.MonitorQueueJournal()
            myNewQueue.MonitorDeadLetter()
            myNewQueue.MonitorTransactionalDeadLetter()

            Return

        End Sub 'Main


        ' References public queues.
        Public Sub SendPublic()

            Dim myQueue As New
 MessageQueue(".\myQueue")
            myQueue.Send("Public queue by path name.")

            Return

        End Sub 'SendPublic


        ' References private queues.
        Public Sub SendPrivate()

            Dim myQueue As New
 MessageQueue(".\Private$\myQueue")
            myQueue.Send("Private queue by path name.")

            Return

        End Sub 'SendPrivate


        ' References queues by label.
        Public Sub SendByLabel()

            Dim myQueue As New
 MessageQueue("Label:TheLabel")
            myQueue.Send("Queue by label.")

            Return

        End Sub 'SendByLabel


        ' References queues by format name.
        Public Sub SendByFormatName()

            Dim myQueue As New
 _
                MessageQueue("FormatName:Public="
 + _
                    "5A5F7535-AE9A-41d4-935C-845C2AFF7112")
            myQueue.Send("Queue by format name.")

            Return

        End Sub 'SendByFormatName


        ' References computer journal queues.
        Public Sub MonitorComputerJournal()

            Dim computerJournal As New
 MessageQueue(".\Journal$")

            While True

                Dim journalMessage As Message
 = _
                    computerJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub 'MonitorComputerJournal


        ' References queue journal queues.
        Public Sub MonitorQueueJournal()

            Dim queueJournal As New
 _
                            MessageQueue(".\myQueue\Journal$")

            While True

                Dim journalMessage As Message
 = _
                    queueJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub 'MonitorQueueJournal


        ' References dead-letter queues.
        Public Sub MonitorDeadLetter()
            Dim deadLetter As New
 MessageQueue(".\DeadLetter$")

            While True

                Dim deadMessage As Message
 = deadLetter.Receive()

                ' Process the dead-letter message.

            End While

            Return

        End Sub 'MonitorDeadLetter


        ' References transactional dead-letter queues.
        Public Sub MonitorTransactionalDeadLetter()

            Dim TxDeadLetter As New
 MessageQueue(".\XactDeadLetter$")

            While True

                Dim txDeadLetterMessage As
 Message = _
                    TxDeadLetter.Receive()

                ' Process the transactional dead-letter message.

            End While

            Return

        End Sub 'MonitorTransactionalDeadLetter

End Class 'MyNewQueue 

using System;
using System.Messaging;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        //**************************************************
        // Provides an entry point into the application.
        //         
        // This example demonstrates several ways to set
        // a queue's path.
        //**************************************************

        public static void
 Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            myNewQueue.SendPublic();
            myNewQueue.SendPrivate();
            myNewQueue.SendByLabel();
            myNewQueue.SendByFormatName();
            myNewQueue.MonitorComputerJournal();
            myNewQueue.MonitorQueueJournal();
            myNewQueue.MonitorDeadLetter();
            myNewQueue.MonitorTransactionalDeadLetter();

            return;
        }
        
        // References public queues.
        public void SendPublic()
        {
            MessageQueue myQueue = new MessageQueue(".\\myQueue");
            myQueue.Send("Public queue by path name.");

            return;
        }

        // References private queues.
        public void SendPrivate()
        {
            MessageQueue myQueue = new 
                MessageQueue(".\\Private$\\myQueue");
            myQueue.Send("Private queue by path name.");

            return;
        }

        // References queues by label.
        public void SendByLabel()
        {
            MessageQueue myQueue = new MessageQueue("Label:TheLabel");
            myQueue.Send("Queue by label.");

            return;
        }

        // References queues by format name.
        public void SendByFormatName()
        {
            MessageQueue myQueue = new 
                MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4" + 
                "-935C-845C2AFF7112");
            myQueue.Send("Queue by format name.");

            return;
        }

        // References computer journal queues.
        public void MonitorComputerJournal()
        {
            MessageQueue computerJournal = new 
                MessageQueue(".\\Journal$");
            while(true)
            {
                Message journalMessage = computerJournal.Receive();
                // Process the journal message.
            }
        }

        // References queue journal queues.
        public void MonitorQueueJournal()
        {
            MessageQueue queueJournal = new 
                MessageQueue(".\\myQueue\\Journal$");
            while(true)
            {
                Message journalMessage = queueJournal.Receive();
                // Process the journal message.
            }
        }
        
        // References dead-letter queues.
        public void MonitorDeadLetter()
        {
            MessageQueue deadLetter = new 
                MessageQueue(".\\DeadLetter$");
            while(true)
            {
                Message deadMessage = deadLetter.Receive();
                // Process the dead-letter message.
            }
        }

        // References transactional dead-letter queues.
        public void MonitorTransactionalDeadLetter()
        {
            MessageQueue TxDeadLetter = new 
                MessageQueue(".\\XactDeadLetter$");
            while(true)
            {
                Message txDeadLetter = TxDeadLetter.Receive();
                // Process the transactional dead-letter message.
            }
        }

    }
}
#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:

   // References public queues.
   void SendPublic()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
      myQueue->Send( "Public queue by path name." );
      return;
   }


   // References private queues.
   void SendPrivate()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\Private$\\myQueue"
 );
      myQueue->Send( "Private queue by path name." );
      return;
   }


   // References queues by label.
   void SendByLabel()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "Label:TheLabel" );
      myQueue->Send( "Queue by label." );
      return;
   }


   // References queues by format name.
   void SendByFormatName()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "FormatName:Public=5A5F7535-AE9A-41d4
 -935C-845C2AFF7112" );
      myQueue->Send( "Queue by format name." );
      return;
   }


   // References computer journal queues.
   void MonitorComputerJournal()
   {
      MessageQueue^ computerJournal = gcnew MessageQueue( ".\\Journal$"
 );
      while ( true )
      {
         Message^ journalMessage = computerJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References queue journal queues.
   void MonitorQueueJournal()
   {
      MessageQueue^ queueJournal = gcnew MessageQueue( ".\\myQueue\\Journal$"
 );
      while ( true )
      {
         Message^ journalMessage = queueJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References dead-letter queues.
   void MonitorDeadLetter()
   {
      MessageQueue^ deadLetter = gcnew MessageQueue( ".\\DeadLetter$" );
      while ( true )
      {
         Message^ deadMessage = deadLetter->Receive();
         
         // Process the dead-letter message.
      }
   }


   // References transactional dead-letter queues.
   void MonitorTransactionalDeadLetter()
   {
      MessageQueue^ TxDeadLetter = gcnew MessageQueue( ".\\XactDeadLetter$"
 );
      while ( true )
      {
         Message^ txDeadLetter = TxDeadLetter->Receive();
         
         // Process the transactional dead-letter message.
      }
   }

};


//*************************************************
// Provides an entry point into the application.
//         
// This example demonstrates several ways to set
// a queue's path.
//*************************************************
int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   myNewQueue->SendPublic();
   myNewQueue->SendPrivate();
   myNewQueue->SendByLabel();
   myNewQueue->SendByFormatName();
   myNewQueue->MonitorComputerJournal();
   myNewQueue->MonitorQueueJournal();
   myNewQueue->MonitorDeadLetter();
   myNewQueue->MonitorTransactionalDeadLetter();
   return 0;
}

package MyProject;

import System.*;
import System.Messaging.*;

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
    //**************************************************
    // Provides an entry point into the application.
    //         
    // This example demonstrates several ways to set
    // a queue's path.
    //**************************************************
    public static void main(String[]
 args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();

        myNewQueue.SendPublic();
        myNewQueue.SendPrivate();
        myNewQueue.SendByLabel();
        myNewQueue.SendByFormatName();
        myNewQueue.MonitorComputerJournal();
        myNewQueue.MonitorQueueJournal();
        myNewQueue.MonitorDeadLetter();
        myNewQueue.MonitorTransactionalDeadLetter();

        return;
    } //main

    // References public queues.
    public void SendPublic()
    {
        MessageQueue myQueue = new MessageQueue(".\\myQueue");
        myQueue.Send("Public queue by path name.");
        return;
    } //SendPublic

    // References private queues.
    public void SendPrivate()
    {
        MessageQueue myQueue = new MessageQueue(".\\Private$\\myQueue");
        myQueue.Send("Private queue by path name.");
        return;
    } //SendPrivate

    // References queues by label.
    public void SendByLabel()
    {
        MessageQueue myQueue = new MessageQueue("Label:TheLabel");
        myQueue.Send("Queue by label.");
        return;
    } //SendByLabel

    // References queues by format name.
    public void SendByFormatName()
    {
        MessageQueue myQueue =
            new MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4"
            + "-935C-845C2AFF7112");
        myQueue.Send("Queue by format name.");
        return;
    } //SendByFormatName

    // References computer journal queues.
    public void MonitorComputerJournal()
    {
        MessageQueue computerJournal = new MessageQueue(".\\Journal$");
        while (true) {
            Message journalMessage = computerJournal.Receive();
            // Process the journal message.
        }
    } //MonitorComputerJournal

    // References queue journal queues.
    public void MonitorQueueJournal()
    {
        MessageQueue queueJournal = new MessageQueue(".\\myQueue\\Journal$");
        while (true) {
            Message journalMessage = queueJournal.Receive();
            // Process the journal message.
        }
    } //MonitorQueueJournal

    // References dead-letter queues.
    public void MonitorDeadLetter()
    {
        MessageQueue deadLetter = new MessageQueue(".\\DeadLetter$");
        while (true) {
            Message deadMessage = deadLetter.Receive();
            // Process the dead-letter message.
        }
    } //MonitorDeadLetter

    // References transactional dead-letter queues.
    public void MonitorTransactionalDeadLetter()
    {
        MessageQueue objTxDeadLetter = new MessageQueue(".\\XactDeadLetter$");
        while (true) {
            Message txDeadLetter = objTxDeadLetter.Receive();
            // Process the transactional dead-letter message.
        }
    } //MonitorTransactionalDeadLetter
} //MyNewQueue
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MessageQueue クラス
MessageQueue メンバ
System.Messaging 名前空間
FormatName
Label
QueueName
Path

MessageQueue コンストラクタ (String, Boolean)

指定した読み取りアクセス制限を持つ指定したパスメッセージ キューキュー参照する MessageQueue クラス新しインスタンス初期化します。

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    sharedModeDenyReceive As Boolean _
)
Dim path As String
Dim sharedModeDenyReceive As Boolean

Dim instance As New MessageQueue(path,
 sharedModeDenyReceive)
public MessageQueue (
    string path,
    bool sharedModeDenyReceive
)
public:
MessageQueue (
    String^ path, 
    bool sharedModeDenyReceive
)
public MessageQueue (
    String path, 
    boolean sharedModeDenyReceive
)
public function MessageQueue (
    path : String, 
    sharedModeDenyReceive : boolean
)

パラメータ

path

この MessageQueue が参照するキューの場所。ローカル コンピュータ場合は "." にできます。このパラメータ正し構文詳細については、「解説」を参照してください

sharedModeDenyReceive

キューアクセスする最初アプリケーション排他読み取りアクセス許可与え場合trueそれ以外場合false

例外例外
解説解説

パス書式名、ラベル判明している、メッセージ キュー特定のキュー新しMessageQueue結び付ける場合は、このオーバーロード使用しますキュー参照する最初アプリケーション排他アクセス許可与え場合は、sharedModeDenyReceive パラメータtrue設定しますそれ以外場合は、sharedModeDenyReceivefalse設定するか、path パラメータだけを指定するコンストラクタ使用します

sharedModeDenyReceivetrue設定すると、他のアプリケーション含めて、そのメッセージ キューキューアクセスするすべてのオブジェクト影響受けますパラメータ影響は、このアプリケーションだけにとどまりません。

MessageQueue コンストラクタMessageQueue クラス新しインスタンス作成しますメッセージ キュー新しキュー作成しません。メッセージ キュー新しキュー作成するには、Create(String) を使用します

path パラメータ構文は、キュー種類によって異なります

メッセージ キューキュー書式名またはラベル使用してキューパス記述することもできます

参照

構文

書式

FormatName: [ format name ]

FormatName:Public= 5A5F7535-AE9A-41d4-935C-845C2AFF7112

FormatName:DIRECT=SPX: NetworkNumber; HostNumber\QueueName

FormatName:DIRECT=TCP: IPAddress\QueueName

FormatName:DIRECT=OS: MachineName\QueueName

ラベル

Label: [ label ]

Label: TheLabel

オフライン作業をするには、表示名構文ではなく書式構文使用する必要があります表示名構文使用すると、パス書式名に解決するプライマリ ドメイン コントローラ (Active Directory常駐) が利用できないため、例外スローされます

MessageQueuesharedModeDenyReceive パラメータtrue設定してキューを開くと、そのキューから読み取ろうとするあらゆる MessageQueue は、共有違反のため MessageQueueException を生成します。既に MessageQueue が非排他モードキューアクセスしているときに、別の MessageQueue排他モードでそのキューアクセスようとした場合にも、MessageQueueExceptionスローさます。

MessageQueueインスタンス初期プロパティ値を次の表に示します。これらの値は、path パラメータ指定されパスメッセージ キューキュー プロパティに基づきます。

プロパティ

初期値

Authenticate

false

BasePriority

0

Category

Empty

DefaultPropertiesToSend

DefaultPropertiesToSend クラス既定コンストラクタ設定される値。

EncryptionRequired

メッセージ キューキューのプライバシ レベル設定が "Body" の場合trueそれ以外場合false

Formatter

XmlMessageFormatter

Label

Empty

MachineName

メッセージ キューキューコンピュータプロパティの値。

MaximumJournalSize

InfiniteQueueSize

MaximumQueueSize

InfiniteQueueSize

MessageReadPropertyFilter

MessagePropertyFilter クラス既定コンストラクタ設定される値。

Path

コンストラクタ設定しない場合Empty

QueueName

コンストラクタ設定しない場合Empty

DenySharedReceive

sharedModeDenyReceive パラメータの値。

UseJournalQueue

メッセージ キューオブジェクトの履歴設定有効な場合trueそれ以外場合false

使用例使用例

新しMessageQueue排他アクセス作成しパス設定しメッセージキュー送信するコード例次に示します

Imports System
Imports System.Messaging

Public Class MyNewQueue


        ' Provides an entry point into the application.
        '         
        ' This example connects to a message queue, and
        ' requests exclusive read access to the queue.
 

        Public Shared Sub
 Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New
 MyNewQueue()

            ' Output the count of Lowest priority messages.
            myNewQueue.GetExclusiveAccess()

            Return

        End Sub 'Main


  
        ' Requests exlusive read access to the queue. If
        ' access is granted, receives a message from the 
        ' queue.
  

        Public Sub GetExclusiveAccess()

            Try

                ' Request exclusive read access to the queue.
                Dim myQueue As New
 MessageQueue(".\myQueue", True)

                ' Receive a message. This is where a SharingViolation
 
                ' exception would be thrown.
                Dim myMessage As Message =
 myQueue.Receive()

            Catch e As MessageQueueException

                ' Handle request for denial of exclusive read access.
                If e.MessageQueueErrorCode = _
                    MessageQueueErrorCode.SharingViolation Then

                    Console.WriteLine("Denied exclusive read access.")

                End If

                ' Handle other sources of a MessageQueueException.

                ' Handle other exceptions as necessary.

            End Try

            Return

        End Sub 'GetExclusiveAccess

End Class 'MyNewQueue

using System;
using System.Messaging;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        //**************************************************
        // Provides an entry point into the application.
        //         
        // This example connects to a message queue, and
        // requests exclusive read access to the queue.
        //**************************************************

        public static void
 Main()
        {
            // Create a new instance of the class.
            MyNewQueue myNewQueue = new MyNewQueue();

            // Output the count of Lowest priority messages.
            myNewQueue.GetExclusiveAccess();
                        
            return;
        }


        //**************************************************
        // Requests exlusive read access to the queue. If
        // access is granted, receives a message from the 
        // queue.
        //**************************************************
        
        public void GetExclusiveAccess()
        {
            try
            {
                // Request exclusive read access to the queue.
                MessageQueue myQueue = new 
                    MessageQueue(".\\myQueue", true);

                // Receive a message. This is where SharingViolation
 
                // exceptions would be thrown.
                Message myMessage = myQueue.Receive();
            }
            
            catch (MessageQueueException e)
            {
                // Handle request for denial of exclusive read access.
                if (e.MessageQueueErrorCode == 
                    MessageQueueErrorCode.SharingViolation)
                {
                    Console.WriteLine("Denied exclusive read access");
                }

                // Handle other sources of a MessageQueueException.
            }

            // Handle other exceptions as necessary.

            return;
        }
    }
}
#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:

   // Requests exlusive read access to the queue. If
   // access is granted, receives a message from the 
   // queue.
   void GetExclusiveAccess()
   {
      try
      {
         
         // Request exclusive read access to the queue.
         MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue",true
 );
         
         // Receive a message. This is where SharingViolation 
         // exceptions would be thrown.
         Message^ myMessage = myQueue->Receive();
      }
      catch ( MessageQueueException^ e ) 
      {
         
         // Handle request for denial of exclusive read access.
         if ( e->MessageQueueErrorCode == MessageQueueErrorCode::SharingViolation
 )
         {
            Console::WriteLine( "Denied exclusive read access" );
         }

         
         // Handle other sources of a MessageQueueException.
      }

      
      // Handle other exceptions as necessary.
      return;
   }

};


// Provides an entry point into the application.
// This example connects to a message queue, and
// requests exclusive read access to the queue.
int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   
   // Output the count of Lowest priority messages.
   myNewQueue->GetExclusiveAccess();
   return 0;
}

package MyProject;

import System.*;
import System.Messaging.*;

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
    //**************************************************
    // Provides an entry point into the application.
    //         
    // This example connects to a message queue, and
    // requests exclusive read access to the queue.
    //**************************************************
    public static void main(String[]
 args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();
        // Output the count of Lowest priority messages.
        myNewQueue.GetExclusiveAccess();
        return;
    } //main

    //**************************************************
    // Requests exlusive read access to the queue. If
    // access is granted, receives a message from the 
    // queue.
    //**************************************************
    public void GetExclusiveAccess()
    {
        try {
            // Request exclusive read access to the queue.
            MessageQueue myQueue = new MessageQueue(".\\myQueue",
 true);
            // Receive a message.This is where SharingViolation 
            // exceptions would be thrown.
            Message myMessage = myQueue.Receive();
        }
        catch (MessageQueueException e) {
            // Handle request for denial of exclusive read access.
            if (e.get_MessageQueueErrorCode().
                Equals(MessageQueueErrorCode.SharingViolation)) {
                Console.WriteLine("Denied exclusive read access");
            }
            // Handle other sources of a MessageQueueException.
        }        
        // Handle other exceptions as necessary.
        return;
    } //GetExclusiveAccess
} //MyNewQueue
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MessageQueue クラス
MessageQueue メンバ
System.Messaging 名前空間
FormatName
Label
Path
QueueName
DenySharedReceive

MessageQueue コンストラクタ (String, Boolean, Boolean)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

MessageQueue クラス新しインスタンス初期化します。

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    sharedModeDenyReceive As Boolean, _
    enableCache As Boolean _
)
Dim path As String
Dim sharedModeDenyReceive As Boolean
Dim enableCache As Boolean

Dim instance As New MessageQueue(path,
 sharedModeDenyReceive, enableCache)
public MessageQueue (
    string path,
    bool sharedModeDenyReceive,
    bool enableCache
)
public:
MessageQueue (
    String^ path, 
    bool sharedModeDenyReceive, 
    bool enableCache
)
public MessageQueue (
    String path, 
    boolean sharedModeDenyReceive, 
    boolean enableCache
)
public function MessageQueue (
    path : String, 
    sharedModeDenyReceive : boolean, 
    enableCache : boolean
)

パラメータ

path

この MessageQueue が参照するキューの場所。ローカル コンピュータ場合は "." にできます

sharedModeDenyReceive

キューアクセスする最初アプリケーション排他読み取りアクセス許可与え場合trueそれ以外場合false

enableCache

接続キャッシュ作成し使用する場合trueそれ以外場合false

使用例使用例

排他読み取りアクセスで、接続キャッシュ有効にして、新しMessageQueue作成するコード例次に示します

// Connect to a queue on the local computer, grant exclusive read
// access to the first application that accesses the queue, and
// enable connection caching.
MessageQueue queue = new MessageQueue(".\\exampleQueue",
 true, true);
// Connect to a queue on the local computer, grant exclusive read
// access to the first application that accesses the queue, and
// enable connection caching.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue", true,
 true);

queue->Close();
// Connect to a queue on the local computer, grant exclusive read
// access to the first application that accesses the queue, and
// enable connection caching.
MessageQueue queue = new MessageQueue(".\\exampleQueue",
 true, true);
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

MessageQueue コンストラクタ (String, QueueAccessMode)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

MessageQueue クラス新しインスタンス初期化します。

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    accessMode As QueueAccessMode _
)
Dim path As String
Dim accessMode As QueueAccessMode

Dim instance As New MessageQueue(path,
 accessMode)
public MessageQueue (
    string path,
    QueueAccessMode accessMode
)
public:
MessageQueue (
    String^ path, 
    QueueAccessMode accessMode
)
public MessageQueue (
    String path, 
    QueueAccessMode accessMode
)
public function MessageQueue (
    path : String, 
    accessMode : QueueAccessMode
)

パラメータ

path

この MessageQueue が参照するキューの場所。ローカル コンピュータ場合は "." にできます

accessMode

QueueAccessMode 値の 1 つ

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

MessageQueue コンストラクタ (String, Boolean, Boolean, QueueAccessMode)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

MessageQueue クラス新しインスタンス初期化します。

名前空間: System.Messaging
アセンブリ: System.Messaging (system.messaging.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    sharedModeDenyReceive As Boolean, _
    enableCache As Boolean, _
    accessMode As QueueAccessMode _
)
Dim path As String
Dim sharedModeDenyReceive As Boolean
Dim enableCache As Boolean
Dim accessMode As QueueAccessMode

Dim instance As New MessageQueue(path,
 sharedModeDenyReceive, enableCache, accessMode)
public MessageQueue (
    string path,
    bool sharedModeDenyReceive,
    bool enableCache,
    QueueAccessMode accessMode
)
public:
MessageQueue (
    String^ path, 
    bool sharedModeDenyReceive, 
    bool enableCache, 
    QueueAccessMode accessMode
)
public MessageQueue (
    String path, 
    boolean sharedModeDenyReceive, 
    boolean enableCache, 
    QueueAccessMode accessMode
)
public function MessageQueue (
    path : String, 
    sharedModeDenyReceive : boolean, 
    enableCache : boolean, 
    accessMode : QueueAccessMode
)

パラメータ

path

この MessageQueue が参照するキューの場所。ローカル コンピュータ場合は "." にできます

sharedModeDenyReceive

キューアクセスする最初アプリケーション排他読み取りアクセス許可与え場合trueそれ以外場合false

enableCache

接続キャッシュ作成し使用する場合trueそれ以外場合false

accessMode

QueueAccessMode 値の 1 つ

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

MessageQueue コンストラクタ

MessageQueue クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

参照参照

関連項目

MessageQueue クラス
MessageQueue メンバ
System.Messaging 名前空間
Path
QueueName
FormatName
Label

MessageQueue フィールド


パブリック フィールドパブリック フィールド

参照参照

関連項目

MessageQueue クラス
System.Messaging 名前空間
Message クラス
DefaultPropertiesToSend クラス
MessageQueueException
MessageQueue
Peek
Receive
BeginPeek
BeginReceive
Path
Label
FormatName
QueueName
MachineName

MessageQueue プロパティ


MessageQueue メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド BeginPeek オーバーロードされますメッセージピーク開始し完了したときにイベント ハンドラ通知するようにメッセージ キュー指示して非同期ピーク操作実行します
パブリック メソッド BeginReceive オーバーロードされますメッセージ受信開始し完了したときにイベント ハンドラ通知するようにメッセージ キュー指示して非同期受信操作実行します
パブリック メソッド ClearConnectionCache 接続キャッシュ消去します。
パブリック メソッド Close MessageQueue で割り当てられすべてのリソース解放します。
パブリック メソッド Create オーバーロードされますメッセージ キュー サーバー指定したパス新しキュー作成します
パブリック メソッド CreateCursor 現在のメッセージ キュー新しCursor作成します
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信使用するプロキシ生成必要な情報をすべて格納しているオブジェクト作成します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Delete メッセージ キュー サーバーキュー削除します
パブリック メソッド Dispose オーバーロードされますMessageQueue使用されていたリソース (メモリを除く) を解放します。
パブリック メソッド EndPeek 指定した非同期ピーク操作完了します
パブリック メソッド EndReceive 指定した非同期受信操作完了します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド Exists 指定したパスメッセージ キューキュー存在するかどうか判断します
パブリック メソッド GetAllMessages キューにあるすべてのメッセージ返します
パブリック メソッド GetEnumerator キュー内のメッセージ列挙します。GetEnumerator の使用避けてください代わりに、GetMessageEnumerator2 を使用してください
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetLifetimeService  対象インスタンス有効期間ポリシー制御する現在の有効期間サービス オブジェクト取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド GetMachineId この MessageQueue参照するキュー存在するコンピュータID取得します
パブリック メソッド GetMessageEnumerator キューにあるすべてのメッセージに対して列挙オブジェクト作成します。GetMessageEnumerator の使用避けてください代わりにGetMessageEnumerator2使用してください
パブリック メソッド GetMessageEnumerator2 キューにあるすべてのメッセージに対して列挙オブジェクト作成します
パブリック メソッド GetMessageQueueEnumerator オーバーロードされます列挙オブジェクト作成しネットワーク上のパブリック キュー動的リスト作成します
パブリック メソッド GetPrivateQueuesByMachine 指定したコンピュータにあるすべてのプライベート キュー取得します
パブリック メソッド GetPublicQueues オーバーロードされますネットワーク上のすべてのパブリック キュー取得します
パブリック メソッド GetPublicQueuesByCategory 指定したカテゴリ属すネットワーク上のすべてのパブリック キュー取得します
パブリック メソッド GetPublicQueuesByLabel 指定したラベル設定されているネットワーク上のすべてのパブリック キュー取得します
パブリック メソッド GetPublicQueuesByMachine 指定したコンピュータにあるすべてのパブリック キュー取得します
パブリック メソッド GetSecurityContext この呼び出し時点現在のユーザーが MSMQ によって関連付けられているセキュリティ コンテキスト (スレッド ID) を取得します
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象インスタンス有効期間ポリシー制御する有効期間サービス オブジェクト取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Peek オーバーロードされますキューにある最初メッセージコピー返しますメッセージキューから削除されません。
パブリック メソッド PeekByCorrelationId オーバーロードされます指定した相関 ID一致するメッセージピークます。
パブリック メソッド PeekById オーバーロードされます指定したメッセージ ID を持つメッセージコピー返しますメッセージキューから削除されません。
パブリック メソッド PeekByLookupId オーバーロードされます。 MSMQ 3.0導入されました。キュー内の特定のメッセージピークます。メッセージは、参照識別子指定することも、キュー前後位置関係指定することもできます
パブリック メソッド Purge キュー含まれるすべてのメッセージ削除します
パブリック メソッド Receive オーバーロードされますキューにある最初メッセージ受信しキューから削除します
パブリック メソッド ReceiveByCorrelationId オーバーロードされます指定した相関 ID一致するメッセージ受信します
パブリック メソッド ReceiveById オーバーロードされます指定した ID一致するメッセージ受信しキューから削除します
パブリック メソッド ReceiveByLookupId オーバーロードされます。 MSMQ 3.0導入されました。特定のメッセージキューから受信しますメッセージは、参照識別子指定することも、キュー前後位置関係指定することもできます
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Refresh リソース現在の状態反映するには、MessageQueue表されるプロパティ更新します
パブリック メソッド ResetPermissions アクセス許可リストオペレーティング システム既定値リセットします。既定リスト追加したキューアクセス許可削除します
パブリック メソッド Send オーバーロードされますキューオブジェクト送信します
パブリック メソッド SetPermissions オーバーロードされます現在のセットアクセス許可追加しますキュープロパティキューメッセージアクセスできるユーザー制御します
パブリック メソッド ToString  Component の名前を格納している String返します (存在する場合)。このメソッドオーバーライドできません。 ( Component から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

MessageQueue クラス
System.Messaging 名前空間
Message クラス
DefaultPropertiesToSend クラス
MessageQueueException
MessageQueue
Peek
Receive
BeginPeek
BeginReceive
Path
Label
FormatName
QueueName
MachineName

MessageQueue メンバ

メッセージ キューサーバーのキューアクセスできるようにします。

MessageQueue データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック フィールドパブリック フィールド
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド BeginPeek オーバーロードされますメッセージピーク開始し完了したときにイベント ハンドラ通知するようにメッセージ キュー指示して非同期ピーク操作実行します
パブリック メソッド BeginReceive オーバーロードされますメッセージ受信開始し完了したときにイベント ハンドラ通知するようにメッセージ キュー指示して非同期受信操作実行します
パブリック メソッド ClearConnectionCache 接続キャッシュ消去します。
パブリック メソッド Close MessageQueue割り当てられすべてのリソース解放します。
パブリック メソッド Create オーバーロードされますメッセージ キュー サーバー指定したパス新しキュー作成します
パブリック メソッド CreateCursor 現在のメッセージ キュー新しCursor作成します
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信使用するプロキシ生成必要な情報をすべて格納しているオブジェクト作成します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Delete メッセージ キュー サーバーキュー削除します
パブリック メソッド Dispose オーバーロードされますMessageQueue使用されていたリソース (メモリを除く) を解放します。
パブリック メソッド EndPeek 指定した非同期ピーク操作完了します
パブリック メソッド EndReceive 指定した非同期受信操作完了します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド Exists 指定したパスメッセージ キューキュー存在するかどうか判断します
パブリック メソッド GetAllMessages キューにあるすべてのメッセージ返します
パブリック メソッド GetEnumerator キュー内のメッセージ列挙します。GetEnumerator の使用避けてください代わりに、GetMessageEnumerator2 を使用してください
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetLifetimeService  対象インスタンス有効期間ポリシー制御する現在の有効期間サービス オブジェクト取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド GetMachineId この MessageQueue参照するキュー存在するコンピュータID取得します
パブリック メソッド GetMessageEnumerator キューにあるすべてのメッセージに対して列挙オブジェクト作成します。GetMessageEnumerator の使用避けてください代わりにGetMessageEnumerator2使用してください
パブリック メソッド GetMessageEnumerator2 キューにあるすべてのメッセージに対して列挙オブジェクト作成します
パブリック メソッド GetMessageQueueEnumerator オーバーロードされます列挙オブジェクト作成しネットワーク上のパブリック キュー動的リスト作成します
パブリック メソッド GetPrivateQueuesByMachine 指定したコンピュータにあるすべてのプライベート キュー取得します
パブリック メソッド GetPublicQueues オーバーロードされますネットワーク上のすべてのパブリック キュー取得します
パブリック メソッド GetPublicQueuesByCategory 指定したカテゴリ属すネットワーク上のすべてのパブリック キュー取得します
パブリック メソッド GetPublicQueuesByLabel 指定したラベル設定されているネットワーク上のすべてのパブリック キュー取得します
パブリック メソッド GetPublicQueuesByMachine 指定したコンピュータにあるすべてのパブリック キュー取得します
パブリック メソッド GetSecurityContext この呼び出し時点現在のユーザーが MSMQ によって関連付けられているセキュリティ コンテキスト (スレッド ID) を取得します
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象インスタンス有効期間ポリシー制御する有効期間サービス オブジェクト取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Peek オーバーロードされますキューにある最初メッセージコピー返しますメッセージキューから削除されません。
パブリック メソッド PeekByCorrelationId オーバーロードされます指定した相関 ID一致するメッセージピークます。
パブリック メソッド PeekById オーバーロードされます指定したメッセージ ID を持つメッセージコピー返しますメッセージキューから削除されません。
パブリック メソッド PeekByLookupId オーバーロードされます。 MSMQ 3.0導入されました。キュー内の特定のメッセージピークます。メッセージは、参照識別子指定することも、キュー前後位置関係指定することもできます
パブリック メソッド Purge キュー含まれるすべてのメッセージ削除します
パブリック メソッド Receive オーバーロードされますキューにある最初メッセージ受信しキューから削除します
パブリック メソッド ReceiveByCorrelationId オーバーロードされます指定した相関 ID一致するメッセージ受信します
パブリック メソッド ReceiveById オーバーロードされます指定した ID一致するメッセージ受信しキューから削除します
パブリック メソッド ReceiveByLookupId オーバーロードされます。 MSMQ 3.0導入されました。特定のメッセージキューから受信しますメッセージは、参照識別子指定することも、キュー前後位置関係指定することもできます
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Refresh リソース現在の状態反映するには、MessageQueue表されるプロパティ更新します
パブリック メソッド ResetPermissions アクセス許可リストオペレーティング システム既定値リセットします。既定リスト追加したキューアクセス許可削除します
パブリック メソッド Send オーバーロードされますキューオブジェクト送信します
パブリック メソッド SetPermissions オーバーロードされます現在のセットアクセス許可追加しますキュープロパティキューメッセージアクセスできるユーザー制御します
パブリック メソッド ToString  Component の名前を格納している String返します (存在する場合)。このメソッドオーバーライドできません。 (Component から継承されます。)
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
参照参照

関連項目

MessageQueue クラス
System.Messaging 名前空間
Message クラス
DefaultPropertiesToSend クラス
MessageQueueException
MessageQueue
Peek
Receive
BeginPeek
BeginReceive
Path
Label
FormatName
QueueName
MachineName

メッセージキュー

(Message Queue から転送)

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2019/08/16 07:02 UTC 版)

メッセージキュー: Message queue)は、プロセス間通信や同一プロセス内のスレッド間通信に使われるソフトウェアコンポーネントである。制御やデータを伝達するメッセージキューである。


  1. ^ Win32 system message queues. About Messages and Message Queues”. Windows User Interface. Microsoft Developer Network. 2010年4月21日閲覧。
  2. ^ Linux and POSIX message queues. Overview of POSIX message queues at linux.die.net
  3. ^ Using Linux Message Queues. [1] at www.civilized.com
  4. ^ 例えば MSMQ がある。Message Queuing (MSMQ)”. Network Communication. Microsoft Developer Network. 2009年5月9日閲覧。
  5. ^ Apache Qpid Project, an implementation of AMQP.


「メッセージキュー」の続きの解説一覧


英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Message Queue」の関連用語

Message Queueのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Message Queueのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアのメッセージキュー (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。

©2024 GRAS Group, Inc.RSS