The documentation you are viewing is for Dapr v1.9 which is an older version of Dapr. For up-to-date documentation, see the latest version.

RocketMQ

Detailed documentation on the RocketMQ pubsub component

Component format

To setup RocketMQ pubsub, create a component of type pubsub.rocketmq. See this guide on how to create and apply a pubsub configuration.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: rocketmq-pubsub
spec:
  type: pubsub.rocketmq
  version: v1
  metadata:
    - name: nameServer
      value: "http://localhost:9876"
    - name: accessKey
      value: "admin"
    - name: secretKey
      value: "password"
    - name: consumerGroup
      value: "GID_0001"
    - name: retries
      value: 10

Spec metadata fields

Field Required Details Example
accessKey N Access Key (Username) "admin"
secretKey N Secret Key (Password) "password"
nameServer N Name server address "127.0.0.1:9876;127.0.0.2:9877"
nameServerDomain N Name server domain "https://my-app.net:8080/nsaddr"
nameSpace N Namespace of the producer/consumer "namespace"
producerGroup N Producer group name for RocketMQ publishers "my_unique_group_name"
consumerGroup N Consumer group name for RocketMQ subscribers "my_unique_group_name"
content-type N Message content-type, e.g., "application/cloudevents+json; charset=utf-8", "application/octet-stream" "text/plain"
retries N Number of times to retry to connect rocketmq’s broker, optional 0
sendTimeOutSec N Timeout duration for publishing a message in seconds 0

For backwards-compatibility reasons, the following values in the metadata are supported, although their use is discouraged.

Field (supported but deprecated) Required Details Example
groupName N Producer group name for RocketMQ publishers "my_unique_group_name"
sendTimeOut N Timeout duration for publishing a message in nanoseconds 0

Setup RocketMQ

See https://rocketmq.apache.org/docs/quick-start/ to setup a local RocketMQ instance.

Per-call metadata fields

Partition Key

When invoking the RocketMQ pub/sub, it’s possible to provide an optional partition key by using the metadata query param in the request url.

You need to specify rocketmq-tag,"rocketmq-key" in metadata

Example:

curl -X POST http://localhost:3500/v1.0/publish/myRocketMQ/myTopic?metadata.rocketmq-tag=?&metadata.rocketmq-key=? \
  -H "Content-Type: application/json" \
  -d '{
        "data": {
          "message": "Hi"
        }
      }'

Last modified October 7, 2022: update rocketmq docs (#2740) (82eb8ecd)