Example #1
0
        /// <summary>
        /// handle as an asynchronous operation.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="cancellationToken">
        /// The cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>TCommand.</returns>
        public override async Task <BrighterCommand> HandleAsync(BrighterCommand command, CancellationToken cancellationToken = default)
        {
            _ = command ?? throw new ArgumentNullException(nameof(command));
            await GetActor(command.Command.AggregateId).Tell(command.Command);

            return(await base.HandleAsync(command, cancellationToken));
        }
Example #2
0
        /// <summary>
        /// Maps to message.
        /// </summary>
        /// <param name="command">The command to serialize.</param>
        /// <returns>Paramore.Brighter.Message.</returns>
        /// <exception cref="System.ArgumentNullException">request</exception>
        public Paramore.Brighter.Message MapToMessage(BrighterCommand command)
        {
            _ = command ?? throw new ArgumentNullException(nameof(command));
            var header = new MessageHeader(
                messageId: ((Paramore.Brighter.IRequest)command).Id,
                topic: command.Command.AggregateType,
                messageType: MessageType.MT_COMMAND,
                correlationId: command.Command.CorrelationId.ToGuidOrDefault());
            var body    = new MessageBody(JsonConvert.SerializeObject(new Envelope(command.Command)));
            var message = new Paramore.Brighter.Message(header, body);

            return(message);
        }