SALES: 1-800-867-1380

SubscriptionClient.OnMessage Method (Action<BrokeredMessage>, OnMessageOptions)

Processes a message in an event-driven message pump, with the given set of OnMessageOptions options.

Namespace:  Microsoft.ServiceBus.Messaging
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

public void OnMessage(
	Action<BrokeredMessage> callback,
	OnMessageOptions onMessageOptions
)

Parameters

callback
Type: System.Action<BrokeredMessage>
The method to invoke when the operation is complete.
onMessageOptions
Type: Microsoft.ServiceBus.Messaging.OnMessageOptions
Specifies the OnMessageOptions options with which to instantiate the message pump.

OnMessageOptions options = new OnMessageOptions();
            options.AutoComplete = true; // Indicates if the message-pump should call complete on messages after the callback has completed processing.

            options.MaxConcurrentCalls = 1; // Indicates the maximum number of concurrent calls to the callback the pump should initiate 

            options.ExceptionReceived += LogErrors; // Enables you to be notified of any errors encountered by the message pump

            // Start receiveing messages
            Client.OnMessage((receivedMessage) => // Initiates the message pump and callback is invoked for each message that is received. Calling Close() on the client will stop the pump.

                {
                    // Process the message
                    Trace.WriteLine("Processing", receivedMessage.SequenceNumber.ToString());
                }, options);
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft