Пример #1
0
        public async Task <bool> Dispatch(EventEnvelope eventEnvelope)
        {
            try
            {
                using (var scope = scopeFactory.CreateScope())
                {
                    scope.ServiceProvider.GetRequiredService <CallContext>().InitializeCallContextFrom(eventEnvelope.CallContext);

                    var eventBus = scope.ServiceProvider.GetRequiredService <EventBus>();

                    await eventBus.PublishEventAsync(eventEnvelope.Event);
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error during event processing");
                return(false);
            }

            return(true);
        }
Пример #2
0
        private string SerializeEventEnvelope(EventEnvelope eventEnvelope)
        {
            var jsonSerializerSettings = jsonSerializerSettingsProvider.GetJsonSerializerSettings();

            return(JsonConvert.SerializeObject(eventEnvelope, jsonSerializerSettings));
        }