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.

rabbitmq.md 1.7 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # RabbitMQ
  2. RabbitMQ is an open-source message-broker software that originally implemented the Advanced Message Queuing Protocol and has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol, Message Queuing Telemetry Transport, and other protocols.
  3. CAP has supported RabbitMQ as message transporter.
  4. ## Configuration
  5. To use RabbitMQ transporter, you need to install the following extensions from NuGet:
  6. ```powershell
  7. PM> Install-Package DotNetCore.CAP.RabbitMQ
  8. ```
  9. Next, add 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.UseRabbitMQ(opt=>
  17. {
  18. //RabbitMQOptions
  19. });
  20. // x.UseXXX ...
  21. });
  22. }
  23. ```
  24. #### RabbitMQ Options
  25. The RabbitMQ configuration parameters provided directly by the CAP are as follows:
  26. NAME | DESCRIPTION | TYPE | DEFAULT
  27. :---|:---|---|:---
  28. HostName | Broker host address | string | localhost
  29. UserName | Broker user name | string | guest
  30. Password | Broker password | string | guest
  31. VirtualHost | Broker virtual host | string | /
  32. Port | Port | int | -1
  33. TopicExchangeName | Default exchange name of cap created | string | cap.default.topic
  34. QueueMessageExpires | Message expries after to delete, in milliseconds | int | (10 days) milliseconds
  35. #### ConnectionFactory Options
  36. If you need **more** native `ConnectionFactory` configuration options, you can set it by 'ConnectionFactoryOptions' option:
  37. ```csharp
  38. services.AddCap(x =>
  39. {
  40. x.UseRabbitMQ(o =>
  41. {
  42. o.HostName = "localhost";
  43. o.ConnectionFactoryOptions = opt => {
  44. //rabbitmq client ConnectionFactory config
  45. };
  46. });
  47. });
  48. ```