Skip to content
Azure Service Bus Compression Plugin
Branch: develop
Clone or download
Latest commit 9f91ec5 Jan 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Dec 18, 2018
images Scale down project icon Dec 18, 2018
src 1.0.0-preview-005 Jan 6, 2019
.gitattributes Initial commit Dec 18, 2018
.gitignore Approving public API Dec 24, 2018
CODEOWNERS Initial commit Dec 18, 2018
LICENSE Initial commit Dec 18, 2018
README.md Doco update Jan 8, 2019
appveyor.yml Clean up appveyor.yml Dec 20, 2018

README.md

Icon

This is a plugin for Microsoft.Azure.ServiceBus client

Allows sending and receiving compressed messages.

license develop opened issues

NuGet package

NuGet Status

Available here http://nuget.org/packages/ServiceBus.CompressionPlugin

To Install from the NuGet Package Manager Console

PM> Install-Package ServiceBus.CompressionPlugin

Examples

Using default compression (GZip, body of at least 1500 bytes)

Configuration and registration

var sender = new MessageSender(connectionString, queueName);
sender.RegisterCompressionPlugin();

Sending

var payload = new MyMessage { ... }; 
var serialized = JsonConvert.SerializeObject(payload);
var payloadAsBytes = Encoding.UTF8.GetBytes(serialized);
var message = new Message(payloadAsBytes);

Receiving

var receiver = new MessageReceiver(connectionString, entityPath, ReceiveMode.ReceiveAndDelete);
receiver.RegisterCompressionPlugin();
var msg = await receiver.ReceiveAsync().ConfigureAwait(false);
// msg will contain the original payload

Overriding minimum body size

var sender = new MessageSender(connectionString, queueName);
sender.RegisterCompressionPlugin(1024); // compress messages using GZip with at least 1024 bytes

Custom compressions

Configuration and registration

var configuration = new CompressionConfiguration(compressionMethodName: "noop", compressor: bytes => Task.FromResult, decompressor: bytes => Task.FromResult, minimumSize: 1);

var sender = new MessageSender(connectionString, queueName);
sender.RegisterCompressionPlugin(configuration);

Sending

var payload = new MyMessage { ... }; 
var serialized = JsonConvert.SerializeObject(payload);
var payloadAsBytes = Encoding.UTF8.GetBytes(serialized);
var message = new Message(payloadAsBytes);

Receiving

var receiver = new MessageReceiver(connectionString, entityPath, ReceiveMode.ReceiveAndDelete);
receiver.RegisterCompressionPlugin(configuration);
var msg = await receiver.ReceiveAsync().ConfigureAwait(false);
// msg will contain the original payload

Transitioning to a different compression or receiving a different compression

To transition to a different compression or process messages compressed used a different method, additional decompressors can be registered to ensure messages in flight compressed using older/other methods are handled properly.

configuration = new CompressionConfiguration(/* new version of compression */);
configuration.AddDecompressor(compressionMethodName: "old compression method name", decompressor: bytes => Task.FromResult);
configuration.AddDecompressor(compressionMethodName: "other compression method name", decompressor: bytes => Task.FromResult);

Who's trusting this plugin in production

Proudly list your company here if use this plugin in production

Icon

Created by Eucalyp from the Noun Project.

You can’t perform that action at this time.