Search in sources :

Example 1 with EzyKafkaProxy

use of com.tvd12.ezymq.kafka.EzyKafkaProxy in project ezyfox-server-example by tvd12.

the class KafkaConfig method config.

@Override
public void config() {
    EzyKafkaProxy kafkaProxy = EzyKafkaProxy.builder().scan("org.youngmonkeys.example.push_message.gateway.api.kafka").ignoreUnknownComponents(true).build();
    singletonFactory.addSingleton("messageProducer", kafkaProxy.getProducer("message"));
}
Also used : EzyKafkaProxy(com.tvd12.ezymq.kafka.EzyKafkaProxy)

Example 2 with EzyKafkaProxy

use of com.tvd12.ezymq.kafka.EzyKafkaProxy in project ezyfox-server-example by tvd12.

the class KafkaConfig method config.

@Override
public void config() {
    EzyKafkaProxy kafkaProxy = EzyKafkaProxy.builder().scan("org.youngmonkeys.example.push_message.kafka").ignoreUnknownComponents(true).addSingleton(responseFactory).build();
    EzyKafkaConsumer consumer = kafkaProxy.getConsumer("message");
    EzyProcessor.processWithException(consumer::start);
}
Also used : EzyKafkaConsumer(com.tvd12.ezymq.kafka.EzyKafkaConsumer) EzyKafkaProxy(com.tvd12.ezymq.kafka.EzyKafkaProxy)

Example 3 with EzyKafkaProxy

use of com.tvd12.ezymq.kafka.EzyKafkaProxy in project ezyfox-examples by tvd12.

the class KafkaConsumer method main.

public static void main(String[] args) throws Exception {
    EzyKafkaProxy kafkaProxy = EzyKafkaProxy.builder().scan("com.tvd12.ezymq.example.kafka").build();
    EzyKafkaConsumer consumer = kafkaProxy.getConsumer("hello-world");
    consumer.start();
    while (true) {
        Thread.sleep(1000);
    }
}
Also used : EzyKafkaConsumer(com.tvd12.ezymq.kafka.EzyKafkaConsumer) EzyKafkaProxy(com.tvd12.ezymq.kafka.EzyKafkaProxy)

Example 4 with EzyKafkaProxy

use of com.tvd12.ezymq.kafka.EzyKafkaProxy in project ezyfox-examples by tvd12.

the class KafkaProducer method main.

public static void main(String[] args) {
    EzyKafkaProxy kafkaProxy = EzyKafkaProxy.builder().build();
    EzyKafkaProducer producer = kafkaProxy.getProducer("hello-world");
    ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
    executorService.scheduleAtFixedRate(() -> {
        producer.send("hello", "Hello World");
    }, 1, 3, TimeUnit.SECONDS);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyKafkaProxy(com.tvd12.ezymq.kafka.EzyKafkaProxy) EzyKafkaProducer(com.tvd12.ezymq.kafka.EzyKafkaProducer)

Aggregations

EzyKafkaProxy (com.tvd12.ezymq.kafka.EzyKafkaProxy)4 EzyKafkaConsumer (com.tvd12.ezymq.kafka.EzyKafkaConsumer)2 EzyKafkaProducer (com.tvd12.ezymq.kafka.EzyKafkaProducer)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1