Deze pagina is nog niet beschikbaar in uw eigen taal. We werken er hard aan om meer taalversies toe te voegen. Bedankt voor uw steun.
- What's New
- Function Overview
- Product Bulletin
- Service Overview
- Getting Started
-
User Guide
- Process of Using RocketMQ
- Creating a User and Granting DMS for RocketMQ Permissions
- Buying a RocketMQ Instance
- Configuring a Topic
- Accessing an Instance
- Managing Messages
- Managing Consumer Groups
-
Managing Instances
- Viewing and Modifying Basic Information of a RocketMQ Instance
- Viewing Background Tasks of a RocketMQ Instance
- Configuring Tags for a RocketMQ Instance
- Exporting RocketMQ Instances
- Diagnosing a RocketMQ Instance
- Restarting Brokers of a RocketMQ Instance
- Deleting a RocketMQ Instance
- Configuring SSL of a RocketMQ Instance
- Modifying RocketMQ Specifications
- Migrating Metadata
- Viewing Monitoring Metrics and Configuring Alarms
- Viewing RocketMQ Audit Logs
- Best Practices
- Developer Guide
- API Reference
- SDK Reference
- FAQs
- Videos
Controlling Access with ACL
After ACL is enabled for an instance, user authentication information must be added to both the producer and consumer configurations.
Preparing the Environment
You can connect open-source Java clients to DMS for RocketMQ. The recommended Java client version is 4.9.8.
- Using Maven
<dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>rocketmq-client</artifactId> <version>4.9.8</version> </dependency> <dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>rocketmq-acl</artifactId> <version>4.9.8</version> </dependency>
- Downloading the dependency.
Adding User Authentication Information to the Producer
- For normal, ordered, and scheduled messages, add the following code:
RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials("ACL_ACCESS_KEY", "ACL_SECRET_KEY")); DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName", rpcHook);
- For transactional messages, add the following code:
RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials("ACL_ACCESS_KEY", "ACL_SECRET_KEY")); TransactionMQProducer producer = new TransactionMQProducer("ProducerGroupName", rpcHook);
ACL_ACCESS_KEY indicates the username, and ACL_SECRET_KEY indicates the user secret key. For details about how to create a user, see Creating a User. Encrypt the username and key for security.
Adding User Authentication Information to the Consumer
RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials("ACL_ACCESS_KEY", "ACL_SECRET_KEY")); DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(null, "ConsumerGroupName", rpcHook);
ACL_ACCESS_KEY indicates the username, and ACL_SECRET_KEY indicates the user secret key. For details about how to create a user, see Creating a User. Encrypt the username and key for security.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.