Esempio n. 1
0
        /// <inheritdoc />
        protected override void Dispatch(CloudEvent e)
        {
            _logger.LogTrace("dispatching...");
            Spigot.AfterReceive?.Invoke(e);
            var message = new EventArrived <T>
            {
                EventData = Spigot.Serializer.Deserialize <T>(e.Data as byte[]),
                Context   = new Context
                {
                    Headers = e.GetAttributes(),
                    Sender  = new Sender(e.Source)
                }
            };

            _logger.LogTrace($"Received {e.Type} message from stream with id {e.Id}");

            try
            {
                HandleMessage(message);
            }
            catch (Exception exx)
            {
                _logger.LogCritical(exx, $"User code threw an exception.");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Gets invoked whenever an instance of T is received from the <see cref="ISpigotStream"/>
 /// </summary>
 protected abstract void HandleMessage(EventArrived <T> message);