This page gives the instructions for deploying the Kafka Event Subscription plugin. Content contains: plugin compilation, Kafka deployment and event subscription examples.

# Recommended Configuration

  • CPU/ RAM: 16Core / 32G

  • DISK: 500G+

  • System: Ubuntu / CentOS 64

# 1. Compile Kafka event plugin

You can find in the event-plugin/build/plugins/ directory after compilation.

# 2. Deploy Kafka

## Install Kafka


## Start Kafka


# 3. Event Subscription

## 3.1 event subscribe configuration

Add items of 'event.plugin' to the configuration file of your fullnode to support event subscription with Kafka.

### 3.1.1 Plugin Configurations

  • The item 'native' contains configurations for TRON's built-in message queue. Please always keep 'useNativeQueue' as 'false' to subscribe events with Kafka.

  • 'path' is the local path for ''. Please ensure the path is correct.

  • 'server' is Kafka's server address in the format of IP:port, default port is 9092. Please use the correct port number and ensure that the Kafka service is accessible.

  • 'dbconfig' is for MongoDB. Ignore it.

### 3.1.2 Event Subscription Configuration Items

TRON Event Subscription supports seven types of events. They are: 'block', 'transaction', 'contractevent', 'contractlog', 'solidity', 'solidityevent' and 'soliditylog'.

Subscription of too many topics will cause performance degradation. Please subscribe 1-2 types of events according to your needs.

Take the block event subscription as an example:

  • triggerName: Built-in field. Can't be changed.

  • enable: Set as 'true' to subscribe the event of 'block'

  • topic: This field corresponds to the pre-created topic in Kafka. The topic name can either be default or customised.

The item of 'filter' works as the filter for subscribed events. For accurate subscription, according to your needs, you can customise the block range(fromblock ~ toblock), contract address(contractAddress) and specific contract topic(contractTopic) .

## 3.2 Create Subscription Topics in Kafka

The name of the Kafka subscription topic should be consistent with the configuration item in 3.1.2. E.g., To subscribe event 'block', please set 'topic' as 'block' in 'block trigger' and create topic 'block' in Kafka to receive 'block' events.


## 3.3 Start an Event Subscription Node

After completing the above configuration, please start your fullnode with '--es' to turn on the event subscription.

Check tron.log to see whether the Kafka Event Plugin has been successfully loaded.

The loading is successful when this reminder displayed:

## 3.4 Event Subscription Queries

Execute script to get messages of topic 'block' in Kafka.


You have successfully subscribed to the events when the following appears: