Connect to FastBee
1. Connect to FastBee
yml File Configuration
Configure the Kafka server address.
Change bootstrap-servers: localhost:9092 to your server's IP address.
yml
kafka:
bootstrap-servers: localhost:9092 # Kafka server cluster addresses, default is localhost:9092
template:
default-topic: property_post # Default topic for messages, KafkaTemplate.sendDefault
listener:
type: batchKafka Consumer
java
@KafkaListener(topics = KafkaConstant.FMQ_PROPERTY_POST, groupId = KafkaConstant.FMQ_PROPERTY_POST_GROUP,
containerFactory = "propertyPostFactory", batch = "true")
public void propertyPostListen(String data) {
try {
// omitted here
} catch (Exception e) {
}
}Kafka Producer
java
public Promise<Void> transmit(ProducerVO vo) {
final Promise<Void> promise = defaultEventExecutorGroup.next().newPromise();
try {
String key = vo.getKey();
String jKey = key != null ? key : "default";
ProducerRecord<String,Object> record;
if (Objects.isNull(key)){
record = new ProducerRecord<>(vo.getTopic(), vo.getData());
}else {
record = new ProducerRecord<>(vo.getTopic(),jKey, vo.getData());
}
producer.send(record,(data ,e) -> {
if (e!= null){
promise.setFailure(e);
}else {
promise.setSuccess(null);
}
});
}catch (Exception e){
}
return promise;
}Run the test.

