Esempio n. 1
0
        private static EventData ToEventData(TransportMessage transportMessage, EventStoreMessageMetadata metadata)
        {
            metadata.CorrelationId = transportMessage.CorrelationId;
            metadata.MessageId     = transportMessage.Id;
            metadata.ReplyTo       = transportMessage.ReplyToAddress.ToString();
            metadata.Headers       = transportMessage.Headers;
            var type = transportMessage.IsControlMessage()
                              ? "ControlMessage"
                              : transportMessage.Headers[Headers.EnclosedMessageTypes];

            byte[] data;
            string contentType;

            if (transportMessage.Headers.TryGetValue(Headers.ContentType, out contentType))
            {
                if (contentType != ContentTypes.Json)
                {
                    throw new InvalidOperationException("Invalid content type: " + contentType);
                }
                data = transportMessage.Body;
            }
            else
            {
                data = new byte[0];
            }
            return(new EventData(Guid.NewGuid(), type, true, data, metadata.ToJsonBytes()));
        }
        private static EventData ToEventData(TransportMessage transportMessage, EventStoreMessageMetadata metadata)
        {
            metadata.CorrelationId = transportMessage.CorrelationId;
            metadata.MessageId = transportMessage.Id;
            metadata.ReplyTo = transportMessage.ReplyToAddress.ToString();
            metadata.Headers = transportMessage.Headers;
            var type = transportMessage.IsControlMessage() 
                              ? "ControlMessage" 
                              : transportMessage.Headers[Headers.EnclosedMessageTypes];

            byte[] data;
            string contentType;
            if (transportMessage.Headers.TryGetValue(Headers.ContentType, out contentType))
            {
                if (contentType != ContentTypes.Json)
                {
                    throw new InvalidOperationException("Invalid content type: "+contentType);
                }
                data = transportMessage.Body;
            }
            else
            {
                data = new byte[0];
            }
            return new EventData(Guid.NewGuid(), type, true, data, metadata.ToJsonBytes());
        }
 public static EventData ToIndirectCommandEventData(this TransportMessage transportMessage, Address destination)
 {
     var metadata = new EventStoreMessageMetadata()
         {
             DestinationComponent = destination.GetComponentName()
         };
     return ToEventData(transportMessage, metadata);
 }
Esempio n. 4
0
        public static EventData ToIndirectCommandEventData(this TransportMessage transportMessage, Address destination)
        {
            var metadata = new EventStoreMessageMetadata()
            {
                DestinationComponent = destination.GetComponentName()
            };

            return(ToEventData(transportMessage, metadata));
        }