导出 (0) 打印
全部展开

OnMessage 方法 (Action(BrokeredMessage), OnMessageOptions)

注:本页面内容可能不完全适用中国大陆地区运营的 Windows Azure服务。如要了解不同地区 Windows Azure 服务的差异, 请参考本网站.

使用给定的一组 OnMessageOptions 选项,在事件驱动的消息泵中处理消息。

命名空间:  Microsoft.ServiceBus.Messaging
程序集:  Microsoft.ServiceBus(在 Microsoft.ServiceBus.dll 中)

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

参数

callback
类型:System..::..Action<(Of <(<'BrokeredMessage>)>)>
完成操作时要调用的方法。
onMessageOptions
类型:Microsoft.ServiceBus.Messaging..::..OnMessageOptions
指定要用于实例化消息泵的 OnMessageOptions 选项。

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);

社区附加资源

添加
显示:
© 2014 Microsoft