Xiaomi Galaxy Talos Book

Using SDK, Step By Step


This section is designed to provide a more detailed explanation of the Demo program. Please read the instructions below, and use Demo's sample program for comparison.

Prerequisite

  1. look for user managerment page at Xiaomi eco cloud Platform and find a set of accessKey and accessSecret from user team tag.

  2. Add the Talos SDK dependency to the program's POM. The coordinates are as follows:

     <groupId>com.xiaomi.infra.galaxy</groupId>
       <artifactId>galaxy-talos-sdk</artifactId>
       <version>2.1.6</version>
    

Using TalosProducer

  1. Configure Server Address: Use the configuration file to create TalosProducerConfig, and configure Talos's service URI. We provide http and https; for specific URI see [clinfo]. Many configurations are configurable, and users can configure them to fit the needs of their personal business data circumstances by following the instructions below.

  2. Create Credential: Use the accessKey and accessSecret provided by Open Platform to create a legitimate Credential. Authentication success is only possible once you have a legitimate Credential.

  3. Obtain TopicTalosResourceName: Create or obtain a Topic for the data you want to write in. As mentioned earlier, all reading and writing of data must be identified only with TopicTalosResourceName, the corresponding CreateOrGetTopic() function within Demo uses TalosAdmin's describeTopic interface in order to obtain TopicTalosResourceName.

  4. Implement UserMessageCallback interface: Implement this interface to process successful submission and failure of messages. Please note, generally Producer announcements are static, during a Callback onError function, it uses its Retry Submission Failure message.

  5. Transmit Data: Instantiate TalosProducer, call send message interface addUserMessage(List messageList)

Using TalosConsumer

  1. Steps 1, 2, and 3 are the same as Producer: Just like with TalosProducer, first configure the server address, create a legitimate Credential, and obtain TopicTalosResourceName. What you need to be careful about is, Consumer only uses the describeTopic interface to obtain the Topic message, so in Producer it may catch an exception; thinking the Topic doesn't exist, Producer will create a Topic. As for Consumer, if the Topic doesn't exist, it doesn't need to create one, if it's unable to consume data, it immediately exits.

  2. Implement the MessageProcessor and MessageProcessorFactory Interface: Implement this interface to process the data read from the server.

  3. Read Data: Just instantiate TalosConsumer, it can automatically read the data, and process rebalance and record offset problems, etc.

Using TalosAdmin

  1. Steps 1, 2, and 3 are the same as Producer: Configure the server address, create a Credential.

  2. Operate Topic: CreateTopic and describeTopic interfaces use topicName, other interfaces such as changeTopicAttribute, deleteTopic, addPartitionNumber, etc. all use topicTalosResourceName.