public void MutateIncoming(TransportMessage transportMessage)
        {
            // the bytes containing the incoming messages.
            byte[] bytes = transportMessage.Body;

            // optionally replace the Body
            transportMessage.Body = ServiceThatChangesBody.Mutate(transportMessage.Body);


            // the incoming headers
            Dictionary <string, string> headers = transportMessage.Headers;

            // optional manipulate headers

            // add a header
            headers.Add("MyHeaderKey1", "MyHeaderValue");

            // remove a header
            headers.Remove("MyHeaderKey2");
        }
        public Task MutateOutgoing(MutateOutgoingTransportMessageContext context)
        {
            object incomingMessage;

            if (context.TryGetIncomingMessage(out incomingMessage))
            {
                // do something with the incoming message
            }

            IReadOnlyDictionary <string, string> incomingHeaders;

            if (context.TryGetIncomingHeaders(out incomingHeaders))
            {
                // do something with the incoming headers
            }

            // the outgoing message
            object outgoingMessage = context.OutgoingMessage;

            // the bytes containing the serialized outgoing messages.
            byte[] bytes = context.OutgoingBody;

            // optionally replace the Body.
            // this can be done using any information from the context
            context.OutgoingBody = ServiceThatChangesBody.Mutate(context.OutgoingMessage);


            // the outgoing headers
            IDictionary <string, string> headers = context.OutgoingHeaders;

            // optional manipulate headers

            // add a header
            headers.Add("MyHeaderKey1", "MyHeaderValue");

            // remove a header
            headers.Remove("MyHeaderKey2");

            return(Task.FromResult(0));
        }
        public Task MutateIncoming(MutateIncomingTransportMessageContext context)
        {
            // the bytes containing the incoming messages.
            byte[] bytes = context.Body;

            // optionally replace the Body
            context.Body = ServiceThatChangesBody.Mutate(context.Body);


            // the incoming headers
            IDictionary <string, string> headers = context.Headers;

            // optional manipulate headers

            // add a header
            headers.Add("MyHeaderKey1", "MyHeaderValue");

            // remove a header
            headers.Remove("MyHeaderKey2");

            return(Task.FromResult(0));
        }
Ejemplo n.º 4
0
        public void MutateOutgoing(LogicalMessage logicalMessage, TransportMessage transportMessage)
        {
            // the outgoing message instance
            object instance = logicalMessage.Instance;

            // the bytes containing the serialized outgoing messages.
            byte[] bytes = transportMessage.Body;

            // optionally replace the Body.
            // this can be done using either the information from the logicalMessage or transportMessage
            transportMessage.Body = ServiceThatChangesBody.Mutate(logicalMessage.Instance);


            // the outgoing headers
            Dictionary <string, string> headers = transportMessage.Headers;

            // optional manipulate headers

            // add a header
            headers.Add("MyHeaderKey1", "MyHeaderValue");

            // remove a header
            headers.Remove("MyHeaderKey2");
        }