--
You received this message because you are subscribed to the Google Groups "Bootique User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bootique-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bootique-user/728251d1-cfe9-4ec9-ae11-78c6e18e53cbn%40googlegroups.com.
public class TypeBConsumer {
@Inject
KafkaConsumerFactory factory;
public void runConsumer() {
try {
// this will start consumer in the background
KafkaPollingTracker poll = factory
// configure consumer
.charValueConsumer()
.cluster("localhost:9092")
.group("test1")
.topics("my-other-topic")
// start consumption in the background
.consume((c, data) -> {
data.forEach(
r -> System.out.println("consumerB" + r.topic() + "_" + r.offset() + ": " + r.value()));
}, Duration.ofSeconds(10));
// Close when we need to stop consumption. With no explicit Bootique will
// close the consumer before the app exit
// poll.close();
} catch (Exception e) {
System.out.println(e.getStackTrace());
}
}
}
public static void main(String[] args) {
BQModule typeAConsumerModule = binder ->
JerseyModule.extend(binder).addResource(TypeAConsumer.class);
BQModule typeBConsumerModule = binder ->
JerseyModule.extend(binder).addResource(TypeAConsumer.class);
BQModule helloResource = binder ->
JerseyModule.extend(binder).addResource(HelloResource.class);
Bootique
.app(args)
.module(helloResource)
.module(typeAConsumerModule)
.module(typeBConsumerModule)
.autoLoadModules()
.exec()
.exit();
}
public class TypeAConsumer extends BaseJob {
@Inject
KafkaConsumerFactory factory;
public TypeAConsumer() {
super(JobMetadata.build(TypeAConsumer.class));
}
@Override
public JobResult run(Map<String, Object> params) {
try {
// this will start consumer in the background
KafkaPollingTracker poll = factory
// configure consumer
.charValueConsumer()
.cluster("localhost:9092")
.group("test1")
.topics("my-topic")
// start consumption in the background
.consume((c, data) -> {
data.forEach(
r -> System.out.println("consumerA" + r.topic() + "_" + r.offset() + ": " + r.value()));
}, Duration.ofSeconds(10));
// Close when we need to stop consumption. With no explicit Bootique will
// close the consumer before the app exit
// poll.close();
} catch (Exception e) {
System.out.println(e.getStackTrace());
}
return JobResult.success(getMetadata());
}
@Override
public void configure(Binder binder) {
// contribute available jobs to the JobModule
JobModule.extend(binder)
.addJob(TypeAConsumer.class)
// .addJob(TypeBConsumer.class)
;
}
To view this discussion on the web visit https://groups.google.com/d/msgid/bootique-user/353E6D2C-BFB9-4444-830A-21564487C7FE%40objectstyle.com.
public void configure(Binder binder) {
BQCoreModule.extend(binder)
.addCommand(StartConsumersCommand.class);
}
You received this message because you are subscribed to a topic in the Google Groups "Bootique User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bootique-user/EVe9tGYwQc4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bootique-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bootique-user/DF67146F-3747-4B9F-B44B-00D124A5BA82%40objectstyle.com.