Skip to content

Instantly share code, notes, and snippets.

@robertmclaws
Last active August 29, 2015 14:06
Show Gist options
  • Save robertmclaws/2dbadad305131e1483d4 to your computer and use it in GitHub Desktop.
Save robertmclaws/2dbadad305131e1483d4 to your computer and use it in GitHub Desktop.
Our current WebJobs method signature
public static void ProcessQueueMessage([QueueTrigger("events")] byte[] messageEnvelope)
{
var message = messageEnvelope.Deserialize<string>());
Trace.WriteLine(message).
}
public static T Deserialize<T>(this byte[] data) where T : class
{
if (data == null)
{
return null;
}
//if (typeof(T) == typeof(string))
//{
return Decompress(data) as T;
//}
//return DeserializeFromJson<T>(data);
}
private static string Decompress(byte[] data)
{
using (var outputMemoryStream = new MemoryStream())
{
using (var inputMemoryStream = new MemoryStream(data))
{
using (var decompressionStream = new DeflateStream(inputMemoryStream, CompressionMode.Decompress))
{
decompressionStream.CopyTo(outputMemoryStream);
}
}
return outputMemoryStream.ToArray().GetString();
}
}
@rustd
Copy link

rustd commented Sep 18, 2014

public static void ProcessQueueMessage([QueueTrigger("events")] CloudQueueMessage messageEnvelope)
{
// Get byte 
var message = messageEnvelope.AsBytes();
// Get string 
var message = messageEnvelope.AsString();
    var message = messageEnvelope.Deserialize<string>());
    Trace.WriteLine(message).
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment