public async Task <MessageHandlingResult> ProcessMessageAsync( Message message, IEndpointHandlingConfig handlingConfig, CancellationToken ct) { try { var messageContext = MessageContext.Create(message); var contractMessage = _serialiser.Deserialise <TMessage>(message); if (contractMessage == null) { return(MessageHandlingResult.UnrecognisedMessageType( $"Serialiser could not de-serialise message to {typeof(TMessage).AssemblyQualifiedName}", message.UserProperties)); } var stopwatch = Stopwatch.StartNew(); var handlingResult = await _handler.HandleMessageAsync(contractMessage, messageContext, ct).ConfigureAwait(false); _instrumentor.TrackElapsed( LogEventIds.HandlerMeasuredElapsed, stopwatch.ElapsedMilliseconds, _handler.GetType().Name, message.UserProperties); return(handlingResult); } catch (OperationCanceledException ex) { _logger.LogWarning(LogEventIds.ProcessorCancelled, ex, $"Operation was cancelled in Processor<{typeof(TMessage).Name}>"); return(MessageHandlingResult.Abandoned(ex, message.UserProperties)); } }
private static void EnsureEndpointHandlingConfigInvariants(IEndpointHandlingConfig endpointConfig) { EnsureEndpointConfigInvariants(endpointConfig); if (endpointConfig.MaxConcurrentCalls < 1) { throw new ArgumentException($"{nameof(endpointConfig.MaxConcurrentCalls)} cannot be less than one"); } }
public SpyMessageReceiver(IEndpointHandlingConfig config) { ServiceBusConnection = new ServiceBusConnection(config.ConnectionString); Path = config.EntityPath; }
public IMessageReceiver CreateDeadLetterMessageReceiver(IEndpointHandlingConfig config, ReceiveMode receiveMode = ReceiveMode.PeekLock, RetryPolicy retryPolicy = null, int prefetchCount = 0) { return(CreateDeadLetterMessageReceiver(config.ConnectionString, config.EntityPath, receiveMode, retryPolicy ?? DefaultRetryPolicy, prefetchCount)); }
public IMessageReceiver CreateMessageReceiver(IEndpointHandlingConfig config, RetryPolicy policy = null) { return(CreateMessageReceiver(config.ConnectionString, config.EntityPath, retryPolicy: policy ?? DefaultRetryPolicy)); }