예제 #1
0
        /// <inheritdoc />
        public MessageRecord CreateMessageRecord(IMessageContext context)
        {
            var record = MessageRecordHelpers.Create(context);

            record.Type = MessageContextConstants.MessageTypeQuery;
            return(record);
        }
예제 #2
0
        /// <inheritdoc />
        public virtual async Task HandleAsync(IMessageContext messageContext, CancellationToken cancellationToken)
        {
            if (!Active)
            {
                return;
            }

            MessageRecord messageRecord   = null;
            var           convertPipeline = messageContext.Pipeline as IMessageRecordConverter;

            if (convertPipeline != null)
            {
                messageRecord = convertPipeline.CreateMessageRecord(messageContext);
            }
            else
            {
                messageRecord = MessageRecordHelpers.Create(messageContext);
            }

            if (filter != null && !filter.IsMatch(messageRecord))
            {
                return;
            }

            try
            {
                await repository.AddAsync(messageRecord, cancellationToken).ConfigureAwait(false);
            }
            catch (Exception)
            {
                if (RethrowExceptions)
                {
                    throw;
                }
            }
        }