In this section, we will learn how to build a custom Compressor Middleware.
If you want to build your own way of compress and decompress messages, you can find in this section the needed instructions.
Add the AddCompressor
/AddDecompressor
extension method to your producer/consumer middlewares to use it.
The method receives a class that implements the ICompressor
/IDecompressor
interface as a generic argument. This class will be used in the compress/decompress process.
A class instance can be provided as an argument through a factory method too.
Install the KafkaFlow.Compressor.Gzip package to use the GzipMessageCompressor
/GzipMessageDecompressor
that uses the GZIP algorithm.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddKafka(kafka => kafka
.AddCluster(cluster => cluster
.WithBrokers(new[] { "localhost:9092" })
.AddProducer<ProductEventsProducer>(producer => producer
...
.AddMiddlewares(middlewares => middlewares
...
.AddCompressor<GzipMessageCompressor>()
.AddCompressor(resolver => new GzipMessageCompressor(...))
...
)
)
)
);
}
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4