public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { log.Info("transportMessage.Body size before compression: " + context.OutgoingBody.Length); MemoryStream mStream = new MemoryStream(context.OutgoingBody); MemoryStream outStream = new MemoryStream(); using (GZipStream tinyStream = new GZipStream(outStream, CompressionMode.Compress)) { mStream.CopyTo(tinyStream); } // copy the compressed buffer only after the GZipStream is disposed, // otherwise, not all the compressed message will be copied. context.OutgoingBody = outStream.ToArray(); context.OutgoingHeaders["IWasCompressed"]= "true"; log.Info("transportMessage.Body size after compression: " + context.OutgoingBody.Length); return Task.FromResult(0); }
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 MutateOutgoing(MutateOutgoingTransportMessageContext context) { context.OutgoingHeaders["WinIdName"] = Thread.CurrentPrincipal.Identity.Name; return Task.FromResult(0); }
public async Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { context.OutgoingHeaders["MyCustomHeader"] = "My custom value"; }
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { context.OutgoingBody = context.OutgoingBody.Reverse().ToArray(); return Task.FromResult(false); }
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { context.OutgoingHeaders["Debug"]= Debug.ToString(); return Task.FromResult(0); }
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { logger.Info("Adding Thread.CurrentPrincipal user to headers"); context.OutgoingHeaders["UserName"] = Thread.CurrentPrincipal.Identity.Name; return Task.FromResult(0); }
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) { context.OutgoingHeaders["MutateOutgoingTransportMessages"]= "ValueMutateOutgoingTransportMessages"; return Task.FromResult(0); }