From 7c21cb3dab1974fd8f9b229df8bc829704923170 Mon Sep 17 00:00:00 2001 From: saberwang Date: Fri, 27 May 2022 10:25:27 +0800 Subject: [PATCH 1/5] Add an example of binding multiple routingKeys Signed-off-by: saberwang --- .../supported-pubsub/setup-rabbitmq.md | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md index 90fe5a9bf..e08ee4a5c 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md @@ -54,6 +54,7 @@ spec: - name: exchangeKind value: fanout ``` + {{% alert title="Warning" color="warning" %}} The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}} @@ -85,13 +86,12 @@ The above example uses secrets as plain strings. It is recommended to use a secr | maxLenBytes | N | Maximum length in bytes of a queue and its dead letter queue (if dead letter enabled). If both `maxLen` and `maxLenBytes` are set then both will apply; whichever limit is hit first will be enforced. Defaults to no limit. | `"1048576"` | | exchangeKind | N | Exchange kind of the rabbitmq exchange. Defaults to `"fanout"`. | `"fanout"`,`"topic"` | - ### Backoff policy introduction + Backoff retry strategy can instruct the dapr sidecar how to resend the message. By default, the retry strategy is turned off, which means that the sidecar will send a message to the service once. When the service returns a result, the message will be marked as consumption regardless of whether it is correct or not. The above is based on the condition of `autoAck` and `requeueInFailure` is setting to false(if `requeueInFailure` is set to true, the message will get a second chance). But in some cases, you may want dapr to retry pushing message with an (exponential or constant) backoff strategy until the message is processed normally or the number of retries is exhausted. This maybe useful when your service breaks down abnormally but the sidecar is not stopped together. Adding backoff policy will retry the message pushing during the service downtime, instead of marking these message as consumed. - ## Create a RabbitMQ server {{< tabs "Self-Hosted" "Kubernetes" >}} @@ -126,9 +126,11 @@ For example, if installing using the example above, the RabbitMQ server client a {{< /tabs >}} ## Use topic exchange to route messages -Setting `exchangeKind` to `"topic"` uses the topic exchanges, which are commonly used for the multicast routing of messages. + +Setting `exchangeKind` to `"topic"` uses the topic exchanges, which are commonly used for the multicast routing of messages. Messages with a `routing key` will be routed to one or many queues based on the `routing key` defined in the metadata when subscribing. The routing key is defined by the `routingKey` metadata. For example, if an app is configured with a routing key `keyA`: + ``` apiVersion: dapr.io/v1alpha1 kind: Subscription @@ -141,7 +143,9 @@ spec: metadata: routingKey: keyA ``` + It will receive messages with routing key `keyA`, and messages with other routing keys are not received. + ``` // publish messages with routing key `keyA`, and these will be received by the above example. client.PublishEvent(context.Background(), "pubsub", "B", []byte("this is a message"), dapr.PublishEventWithMetadata(map[string]string{"routingKey": "keyA"})) @@ -149,9 +153,27 @@ client.PublishEvent(context.Background(), "pubsub", "B", []byte("this is a messa client.PublishEvent(context.Background(), "pubsub", "B", []byte("this is another message"), dapr.PublishEventWithMetadata(map[string]string{"routingKey": "keyB"})) ``` +### Bind multiple `routingKey` + +In the example, three "routingkey" including `keyA`, `keyB` and `""` will be bind. + +``` +apiVersion: dapr.io/v1alpha1 +kind: Subscription +metadata: + name: order_pub_sub +spec: + topic: B + route: /B + pubsubname: pubsub + metadata: + routingKey: keyA,keyB, +``` + For more information see [rabbitmq exchanges](https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchanges). ## Related links + - [Basic schema for a Dapr component]({{< ref component-schema >}}) in the Related links section - Read [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components - [Pub/Sub building block]({{< ref pubsub >}}) From 4c627530b224b45e1814fb7e48d8f4b671290c2b Mon Sep 17 00:00:00 2001 From: saber-wang <45062099+saber-wang@users.noreply.github.com> Date: Sat, 11 Jun 2022 13:18:06 +0800 Subject: [PATCH 2/5] Update setup-rabbitmq.md Signed-off-by: saberwang --- .../components-reference/supported-pubsub/setup-rabbitmq.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md index e08ee4a5c..d07d384f3 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md @@ -155,6 +155,7 @@ client.PublishEvent(context.Background(), "pubsub", "B", []byte("this is another ### Bind multiple `routingKey` +Multiple routing Keys can be separated by commas. In the example, three "routingkey" including `keyA`, `keyB` and `""` will be bind. ``` @@ -170,6 +171,8 @@ spec: routingKey: keyA,keyB, ``` +Note:the binding method of empty keys + For more information see [rabbitmq exchanges](https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchanges). ## Related links From 44a98401163e7418ec78e16ecb7974b7bab6c827 Mon Sep 17 00:00:00 2001 From: saber-wang <45062099+saber-wang@users.noreply.github.com> Date: Fri, 24 Jun 2022 07:06:09 +0800 Subject: [PATCH 3/5] Update daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Signed-off-by: saberwang --- .../components-reference/supported-pubsub/setup-rabbitmq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md index edb89526a..61a4556a4 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md @@ -158,7 +158,7 @@ client.PublishEvent(context.Background(), "pubsub", "B", []byte("this is another ### Bind multiple `routingKey` -Multiple routing Keys can be separated by commas. +Multiple routing keys can be separated by commas. In the example, three "routingkey" including `keyA`, `keyB` and `""` will be bind. ``` From 05e9fc07dd9acb8f106667789fad2513499628ee Mon Sep 17 00:00:00 2001 From: saber-wang <45062099+saber-wang@users.noreply.github.com> Date: Fri, 24 Jun 2022 07:08:21 +0800 Subject: [PATCH 4/5] Update daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Signed-off-by: saberwang --- .../components-reference/supported-pubsub/setup-rabbitmq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md index 61a4556a4..a4467009c 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md @@ -159,7 +159,7 @@ client.PublishEvent(context.Background(), "pubsub", "B", []byte("this is another ### Bind multiple `routingKey` Multiple routing keys can be separated by commas. -In the example, three "routingkey" including `keyA`, `keyB` and `""` will be bind. +The example below binds three `routingKey`: `keyA`, `keyB`, and `""`. Note the binding method of empty keys. ``` apiVersion: dapr.io/v1alpha1 From 861dcb7a03727286435977af3995975a5a66d06b Mon Sep 17 00:00:00 2001 From: saber-wang <45062099+saber-wang@users.noreply.github.com> Date: Fri, 24 Jun 2022 07:08:39 +0800 Subject: [PATCH 5/5] Update daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Signed-off-by: saberwang --- .../components-reference/supported-pubsub/setup-rabbitmq.md | 1 - 1 file changed, 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md index a4467009c..f3c964f05 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rabbitmq.md @@ -174,7 +174,6 @@ spec: routingKey: keyA,keyB, ``` -Note:the binding method of empty keys For more information see [rabbitmq exchanges](https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchanges).