NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MessageQueue.Send (Object)

Sends an object to the queue referenced by this MessageQueue. The object is serialized using the formatter provided.

[Visual Basic]
Overloads Overridable Public Sub Send( _
   ByVal obj As Object _
)
[C#]
public virtual void Send(
   object obj
);
[C++]
public: virtual void Send(
   Object* obj
);
[JScript]
public function Send(
   obj : Object
);

Parameters

obj
The object to send to the queue.

Exceptions

Exception Type Condition
MessageQueueException The attempt to retrieve queue information generated an exception specified by the given status message.

Remarks

Use this overload to send a message to the queue referenced by the MessageQueue. The Path must already be specified before the message is sent, because this overload is not static (in Visual Basic Shared).

The object sent to the queue can be a Message, a structure, a data object, or any other NGWS object.

If you set DefaultPropertiesToSend before sending any object besides a Message object, these properties apply when you call Send. When sending a Message object, the property values are initially set by the Message object's constructor and must be overridden explicitly if you want to use the DefaultPropertiesToSend.

Example [Visual Basic]

The following example sends an object defined by a structure to a message queue. This example assumes there is a queue named "myQueue" on the computer "myComputer". It also assumes that there is a structure named MyNewObject with the members Item and Quantity.

[Visual Basic]

Structure MyNewObject
    Public Item As String
    Public Quantity As Integer
End Structure

Private Sub SendObject()
    'Create a new Order object.
    Dim myNewObject1 As MyNewObject
    Dim messageQueue1 As MessageQueue
    messageQueue1 = New MessageQueue("myComputer\myQueue")
    'Populate the structure's members.
    myNewObject1.Item = "new item"
    myNewObject1.Quantity = 1
    'Send the structure to the message queue.
    messageQueue1.Send(myNewObject1)
End Sub

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | MessageQueue.Send Overload List | DefaultPropertiesToSend | Message | Purge | Path