Commit 07ec0e0b authored by zhoushiguang's avatar zhoushiguang

事件插入通知

parent b8f16883
......@@ -4,6 +4,7 @@ import org.apache.kafka.clients.producer.ProducerConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
......@@ -61,13 +62,13 @@ public class KafkaProducerConfig {
public ProducerFactory<String, String> producerFactory2() {
return new DefaultKafkaProducerFactory<>(producerConfigs2());
}
@Bean
@Primary
@Bean("kafkaTemplate1")
public KafkaTemplate<String, String> kafkaTemplate1() {
return new KafkaTemplate<>(producerFactory1());
}
@Bean
@Bean("kafkaTemplate2")
public KafkaTemplate<String, String> kafkaTemplate2() {
return new KafkaTemplate<>(producerFactory2());
}
......
......@@ -15,7 +15,7 @@ public class KafkaProducerServiceHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
@Resource(name = "kafkaTemplate2")
private KafkaTemplate<String, String> kafkaTemplate;
public boolean send(String topic, String dataKey, String data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment