-
-
Notifications
You must be signed in to change notification settings - Fork 364
Message compression and encryption
By default, Rebus uses the built-in JSON serializer which internally uses the excellent Newtonsoft JSON.NET.
Rebus supports automatic encryption of message bodies, which means that the contents of messages cannot easily be read by eavesdroppers. This can be useful if you're e.g. sending messages containing payroll information, or other kinds of information that should not be readily readable.
You can enable encryption by going:
Configure.With(...)
.(...)
.Options(o => {
o.EnableEncryption("base 64 encoded encryption key");
})
.(...)
In case you forget to provide a valid key, Rebus is nice enough to generate one for you that you may copy into your configuration file and start using :) Rebus will used the built-in functionality in .NET to generate the key.
Since many serialization formats are pretty verbose, and JSON in that regard is probabably one of the most verbose formats because it includes the entire schema along with every single message, you may want to enable message compression.
In order to enable compression, you can do this:
Configure.With(...)
.(...)
.Options(o => {
o.EnableCompression(512);
})
.(...)
in order to compress messages whose raw byte[]
payload exceeds 512 bytes in length, or
Configure.With(...)
.(...)
.Options(o => {
o.EnableCompression();
})
.(...)
in order to use the default threshold of 1024 bytes.
You can, of course, combine both encryption and compression, by going
Configure.With(...)
.(...)
.Options(o => {
o.EnableEncryption(key);
o.EnableCompression();
})
.(...)
Since encryption scrambles messages badly, Rebus will of course compress messages before they're encrypted when sending, and in reverse upon receiving them, no matter how you configure it.
The awesome Simon Cropp has provided a Rebus-compatible version of his excellent JSON encryption library, which allows for selectively encrypting nodes of JSON-serialized message objects, e.g. by attaching an [Encrypt]
attribute to a property.
The library speaks for itself, so please visit the code repository, or go download the NuGet package.
Basic stuff
- Home
- Introduction
- Getting started
- Different bus modes
- How does rebus compare to other .net service buses?
- 3rd party extensions
- Rebus versions
Configuration
Scenarios
Areas
- Logging
- Routing
- Serialization
- Pub sub messaging
- Process managers
- Message context
- Data bus
- Correlation ids
- Container adapters
- Automatic retries and error handling
- Message dispatch
- Thread safety and instance policies
- Timeouts
- Timeout manager
- Transactions
- Delivery guarantees
- Idempotence
- Unit of work
- Workers and parallelism
- Wire level format of messages
- Handler pipeline
- Polymorphic message dispatch
- Persistence ignorance
- Saga parallelism
- Transport message forwarding
- Testing
- Outbox
- Startup/shutdown
Transports (not a full list)
Customization
- Extensibility
- Auto flowing user context extensibility example
- Back off strategy
- Message compression and encryption
- Fail fast on certain exception types
Pipelines
- Log message pipelines
- Incoming messages pipeline
- Incoming step context
- Outgoing messages pipeline
- Outgoing step context
Prominent application services