Overview
TDMQ for Pulsar provides the same JWT authentication method used by native Pulsar, which allows you to access TDMQ for Pulsar resources by configuring the token in the client parameters. For directions on how to configure the relationships between different role tokens and TDMQ for Pulsar resources in the console, see Roles and Permissions.
This document describes how to configure JWT authentication in a TDMQ for Pulsar client, so that you can securely use the client to produce and consume messages. You can also add a token when creating a client.
Authentication Configuration
Java Client
Configure JWT authentication in the Java client:
PulsarClient client = PulsarClient.builder()//Access address, copy from the access address in the Cluster Management operation column.serviceUrl("http://*")//Replace with the role token, located on the Role Management page.authentication(AuthenticationFactory.token("eyJh****")).build();
PulsarClient client = PulsarClient.builder()//Access address, fully copy from the access point list in Cluster Management.serviceUrl("pulsar://*.*.*.*:6000/")//Replace with the role token, located on the Role Management page.authentication(AuthenticationFactory.token("eyJh****"))//Replace the value ofcustom:with the route ID in the access point list in Cluster Management.listenerName("custom:1******0/vpc-**/subnet-******").build();
Go Client
Configure JWT authentication in the Go client:
client, err := NewClient(ClientOptions{//Access address, fully copy from the access point list in Cluster ManagementURL: "http://*",//Replace with the role token, located on the Role Management pageAuthentication: NewAuthenticationToken("eyJh****"),})
client, err := NewClient(ClientOptions{//Access address, fully copy from the access point list in Cluster ManagementURL: "pulsar://*.*.*.*:6000",//Replace with the role token, located on the Role Management pageAuthentication: NewAuthenticationToken("eyJh****"),//Replace the value ofcustom:with the route ID in the access point list in Cluster ManagementListenerName: "custom:1300***0/vpc-**/subnet-******",})