public static void Publish(this IMessageBus <IPublishableException> exBus, IPublishableException publishableException) { var envelope = new Envelope <IPublishableException>(publishableException, ObjectId.GenerateNewId().ToString()); exBus.Send(envelope); }
public PublishableExceptionDescriptor(IPublishableException exception) { var keyProvider = exception as IRoutingProvider; if (keyProvider != null) { Key = keyProvider.GetRoutingKey(); } else { Key = string.Empty; } }
private void PublishExceptionAsync(ProcessingCommand processingCommand, IPublishableException exception, int retryTimes) { _ioHelper.TryAsyncActionRecursively <AsyncTaskResult>("PublishExceptionAsync", () => _exceptionPublisher.PublishAsync(exception), currentRetryTimes => PublishExceptionAsync(processingCommand, exception, currentRetryTimes), result => { NotifyCommandExecuted(processingCommand, CommandStatus.Failed, exception.GetType().Name, (exception as Exception).Message); }, () => { var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var exceptionInfo = string.Join(",", serializableInfo.Select(x => string.Format("{0}:{1}", x.Key, x.Value))); return(string.Format("[commandId:{0}, exceptionInfo:{1}]", processingCommand.Message.Id, exceptionInfo)); }, () => NotifyCommandExecuted(processingCommand, CommandStatus.Failed, null, "Publish exception async failed."), retryTimes); }
private void PublishExceptionAsync(ProcessingCommand processingCommand, IPublishableException exception, int retryTimes) { _ioHelper.TryAsyncActionRecursively("PublishExceptionAsync", () => _exceptionPublisher.PublishAsync(exception), currentRetryTimes => PublishExceptionAsync(processingCommand, exception, currentRetryTimes), result => { CompleteCommand(processingCommand, CommandStatus.Failed, exception.GetType().Name, (exception as Exception).Message); }, () => { var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var exceptionInfo = string.Join(",", serializableInfo.Select(x => string.Format("{0}:{1}", x.Key, x.Value))); return(string.Format("[commandId:{0}, exceptionInfo:{1}]", processingCommand.Message.Id, exceptionInfo)); }, errorMessage => { _logger.Fatal(string.Format("Publish event has unknown exception, the code should not be run to here, errorMessage: {0}", errorMessage)); }, retryTimes, true); }
private Task PublishExceptionAsync(ProcessingCommand processingCommand, IPublishableException exception, int retryTimes, TaskCompletionSource <bool> taskSource) { exception.MergeItems(processingCommand.Message.Items); _ioHelper.TryAsyncActionRecursively("PublishExceptionAsync", () => _exceptionPublisher.PublishAsync(exception), currentRetryTimes => PublishExceptionAsync(processingCommand, exception, currentRetryTimes, taskSource), async result => { await CompleteCommand(processingCommand, CommandStatus.Failed, exception.GetType().Name, (exception as Exception).Message); taskSource.SetResult(true); }, () => { var serializableInfo = new Dictionary <string, string>(); exception.SerializeTo(serializableInfo); var exceptionInfo = string.Join(",", serializableInfo.Select(x => string.Format("{0}:{1}", x.Key, x.Value))); return(string.Format("[commandId:{0}, exceptionInfo:{1}]", processingCommand.Message.Id, exceptionInfo)); }, null, retryTimes, true); return(taskSource.Task); }
public ProcessingPublishableExceptionMessage(IPublishableException message, IMessageProcessContext processContext) { Message = message; _processContext = processContext; }
public Task <AsyncTaskResult> PublishAsync(IPublishableException exception) { return(_successResultTask); }