本文整理汇总了C#中ClientContext.OnMessageAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ClientContext.OnMessageAsync方法的具体用法?C# ClientContext.OnMessageAsync怎么用?C# ClientContext.OnMessageAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClientContext
的用法示例。
在下文中一共展示了ClientContext.OnMessageAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Receiver
public Receiver(NamespaceContext context, ClientContext clientContext, IPipe<ReceiveContext> receivePipe, ClientSettings clientSettings,
ITaskSupervisor supervisor, ISendEndpointProvider sendEndpointProvider, IPublishEndpointProvider publishEndpointProvider)
{
_context = context;
_clientContext = clientContext;
_receivePipe = receivePipe;
_clientSettings = clientSettings;
_sendEndpointProvider = sendEndpointProvider;
_publishEndpointProvider = publishEndpointProvider;
_tracker = new DeliveryTracker(DeliveryComplete);
_participant = supervisor.CreateParticipant($"{TypeMetadataCache<Receiver>.ShortName} - {clientContext.InputAddress}", Stop);
var options = new OnMessageOptions
{
AutoComplete = false,
AutoRenewTimeout = clientSettings.AutoRenewTimeout,
MaxConcurrentCalls = clientSettings.MaxConcurrentCalls
};
options.ExceptionReceived += (sender, x) =>
{
if (!(x.Exception is OperationCanceledException))
{
if (_log.IsErrorEnabled)
_log.Error($"Exception received on receiver: {clientContext.InputAddress} during {x.Action}", x.Exception);
}
if (_tracker.ActiveDeliveryCount == 0)
{
if (_log.IsDebugEnabled)
_log.DebugFormat("Receiver shutdown completed: {0}", clientContext.InputAddress);
_participant.SetComplete();
}
};
clientContext.OnMessageAsync(OnMessage, options);
_participant.SetReady();
}