我正在尝试根据一些评估将数据发送到不同的主题。我正在使用SPring CLoud Streams和Kafka
如何有条件地转发kafka主题。我需要在我特别评论的地方插入SCS-kafka相关的代码。
谢谢。
@EnableBinding(Sink.class)
public class SampleSink {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private SomeService someService;
@ServiceActivator(inputChannel = Sink.INPUT)
public void processor(Message<?> message1) {
EvaluateData evaluateData = someService.evaluateData(message1);
String Result = String.valueOf(evaluateData.getResult());
try {
if(validationResult.equalsIgnoreCase("allgood")){
//Send message1 to Topic1
}
else if (validationResult.equalsIgnoreCase("notgood")){
new SomeException("topic1");
//将数据发送到topic2
}
else {
throw new SomeException("topic3");
}
}
catch (SomeException e){
//something
//分别将数据发送到topic2和3 }
}
}