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.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: rocketmq-pubsub
  5. spec:
  6. type: pubsub.rocketmq
  7. version: v1
  8. metadata:
  9. - name: nameServer
  10. value: "http://localhost:9876"
  11. - name: accessKey
  12. value: "admin"
  13. - name: secretKey
  14. value: "password"
  15. - name: consumerGroup
  16. value: "GID_0001"
  17. - name: retries
  18. value: 10

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Spec metadata fields

FieldRequiredDetailsExample
accessKeyNAccess Key (Username)“admin”
secretKeyNSecret Key (Password)“password”
nameServerNName server address“127.0.0.1:9876;127.0.0.2:9877”
nameServerDomainNName server domainhttps://my-app.net:8080/nsaddr
nameSpaceNNamespace of the producer/consumer“namespace”
groupNameNProducer group name for RocketMQ publishers“my_unique_group_name”
consumerGroupNConsumer group name for RocketMQ subscribers“my_unique_group_name”
content-typeNMessage content-type, e.g., “application/cloudevents+json; charset=utf-8”, “application/octet-stream”“text/plain”
retriesNNumber of times to retry to connect rocketmq’s broker, optional0
sendTimeOutNTimeout duration for publishing a message in nanoseconds0

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:

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

Last modified July 27, 2022: Remove namespace element from component examples (#2647) (ff9de5c8)