Issue
Below is the code with both types of kafka consumers which I try to use .
@SpringBootApplication
@EnableBinding(MixApplication.IncomingBinding.class)
@Slf4j
public class MixApplication {
public static void main(String[] args) {
final ConfigurableApplicationContext application
= new SpringApplicationBuilder(MixApplication.class).web(WebApplicationType.SERVLET).run(args);
}
@StreamListener(IncomingBinding.INPUT)
public void listen(Object obj){
log.info("hello1");
}
@Bean("output2")
public Consumer<Object> output2() {
return obj -> {
log.info("hello2");
};
}
public interface IncomingBinding {
String INPUT = "output1";
@Input(INPUT)
SubscribableChannel input();
}
}
with configuration
spring:
application:
name: MixApplication
cloud:
stream:
function:
definition: output2
kafka:
binder:
brokers: localhost:9092
bindings:
output2-in-0:
destination: test2
group: "test"
consumer:
concurrency: 10
max-attempts: 3
output1:
destination: test1
group: "test"
consumer:
concurrency: 10
max-attempts: 3
But only consumer with @StreamListener annotation is working.
When I remove @StreamListener realization then "output2" consumer works. Is it possible to make them both work together? Also I have seen similar item, but it was without answer. Use Spring Cloud Function and Spring Cloud Stream together?
Solution
No, you could only use one or the other, but since version 4.0 annotation-based programming model is completely removed which means you can only use function-based.
What is it that you want to do that you can not do with function-based model?
Answered By - Oleg Zhurakousky
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.