You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kafka.md 1.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Apache Kafka®
  2. [Apache Kafka®](https://kafka.apache.org/) is an open-source stream-processing software platform developed by LinkedIn and donated to the Apache Software Foundation, written in Scala and Java.
  3. CAP has supported Kafka® as message transporter.
  4. ## Configuration
  5. To use Kafka transporter, you need to install the following extensions from NuGet:
  6. ```powershell
  7. PM> Install-Package DotNetCore.CAP.Kafka
  8. ```
  9. Then you can add memory-based configuration items to the `ConfigureServices` method of `Startup.cs`.
  10. ```csharp
  11. public void ConfigureServices(IServiceCollection services)
  12. {
  13. // ...
  14. services.AddCap(x =>
  15. {
  16. x.UseKafka(opt=>{
  17. //KafkaOptions
  18. });
  19. // x.UseXXX ...
  20. });
  21. }
  22. ```
  23. #### Kafka Options
  24. The Kafka configuration parameters provided directly by the CAP are as follows:
  25. NAME | DESCRIPTION | TYPE | DEFAULT
  26. :---|:---|---|:---
  27. Servers | Broker server address | string |
  28. ConnectionPoolSize | connection pool size | int | 10
  29. #### Kafka MainConfig Options
  30. If you need **more** native Kakfa related configuration items, you can set it with the `MainConfig` configuration option:
  31. ```csharp
  32. services.AddCap(capOptions =>
  33. {
  34. capOptions.UseKafka(kafkaOption=>
  35. {
  36. // kafka options.
  37. // kafkaOptions.MainConfig.Add("", "");
  38. });
  39. });
  40. ```
  41. `MainConfig` is a configuration dictionary, you can find a list of supported configuration items through the following link.
  42. [https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md)