コード例 #1
0
 /// <summary>
 /// Consumes the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public virtual Task Consume( ConsumeContext<TMessage> context )
 {
     RockLogger.Log.Debug( RockLogDomains.Core, "Rock Task Consumer: {0} TMessage Type: {1} Context: {@context}", GetType(), typeof( TMessage ), context );
     ConsumeContext = context;
     Consume( context.Message );
     return RockMessageBus.GetCompletedTask();
 }
コード例 #2
0
        /// <summary>
        /// Called when the transport receive faults
        /// </summary>
        /// <param name="context">The receive context of the message</param>
        /// <param name="exception">The exception that was thrown</param>
        /// <returns></returns>
        public Task ReceiveFault(ReceiveContext context, Exception exception)
        {
            var errorMessage = $"A ReceiveFault occurred. Context: {context}. Exception {exception}";

            ExceptionLogService.LogException(new BusException(errorMessage, exception));

            RockLogger.Log.Error(RockLogDomains.Bus, "A ReceiveFault occurred Context: @context Exception: @exception", context, exception);
            return(RockMessageBus.GetCompletedTask());
        }
コード例 #3
0
        /// <summary>
        /// Called when a message being consumed produced a fault
        /// </summary>
        /// <typeparam name="T">The message type</typeparam>
        /// <param name="context">The message consume context</param>
        /// <param name="duration">The consumer duration</param>
        /// <param name="consumerType">The consumer type</param>
        /// <param name="exception">The exception from the consumer</param>
        /// <returns></returns>
        public Task ConsumeFault <T>(ConsumeContext <T> context, TimeSpan duration, string consumerType, Exception exception) where T : class
        {
            var errorMessage = $"A ConsumeFault occurred in the {consumerType}. Original Message: {context.Message}. Exception: {exception}";

            ExceptionLogService.LogException(new BusException(errorMessage, exception));

            RockLogger.Log.Error(RockLogDomains.Bus, "A ConsumeFault occurred in the @consumerType. Original Message: @originalMessage Exception: @exception", consumerType, context.Message, exception);
            return(RockMessageBus.GetCompletedTask());
        }
コード例 #4
0
        /// <summary>
        /// Called after the message has been dispatched to all consumers - note that in the case of an exception
        /// this method is not called, and the DispatchFaulted method is called instead
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <returns></returns>
        public Task PostConsume <T>(ConsumeContext <T> context) where T : class
        {
            // Log for the bus as a whole
            RockMessageBus.StatLog?.LogConsume();

            // Log for the specific queue
            var queue = RockMessage.GetQueue(typeof(T));

            queue?.StatLog?.LogConsume();

            return(RockMessageBus.GetCompletedTask());
        }
コード例 #5
0
 /// <summary>
 /// Called before a message is dispatched to any consumers
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="context">The consume context</param>
 /// <returns></returns>
 public Task PreConsume <T>(ConsumeContext <T> context) where T : class
 {
     return(RockMessageBus.GetCompletedTask());
 }
コード例 #6
0
 /// <summary>
 /// Called after the message has been dispatched to all consumers when one or more exceptions have occurred
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="context"></param>
 /// <param name="exception"></param>
 /// <returns></returns>
 /// <exception cref="NotImplementedException"></exception>
 public Task ConsumeFault <T>(ConsumeContext <T> context, Exception exception) where T : class
 {
     ExceptionLogService.LogException(new BusException($"A Consume Fault occurred. Original Message: {context?.Message}", exception));
     RockLogger.Log.Error(RockLogDomains.Core, "A Consume Fault occurred Original Message: @originalMessage Exception: @exception", context.Message, exception);
     return(RockMessageBus.GetCompletedTask());
 }
コード例 #7
0
 /// <summary>
 /// Called when a message has been delivered by the transport is about to be received by the endpoint
 /// </summary>
 /// <param name="context">The receive context of the message</param>
 /// <returns></returns>
 public Task PreReceive(ReceiveContext context)
 {
     return(RockMessageBus.GetCompletedTask());
 }
コード例 #8
0
 /// <summary>
 /// Called when a message has been consumed by a consumer
 /// </summary>
 /// <typeparam name="T">The message type</typeparam>
 /// <param name="context">The message consume context</param>
 /// <param name="duration">The consumer duration</param>
 /// <param name="consumerType">The consumer type</param>
 /// <returns></returns>
 public Task PostConsume <T>(ConsumeContext <T> context, TimeSpan duration, string consumerType) where T : class
 {
     return(RockMessageBus.GetCompletedTask());
 }