Skip to content

Instantly share code, notes, and snippets.

@harishb2k
Created July 8, 2022 18:38
Show Gist options
  • Save harishb2k/9a8188d30b1a2a4d0f59c9482f981fc5 to your computer and use it in GitHub Desktop.
Save harishb2k/9a8188d30b1a2a4d0f59c9482f981fc5 to your computer and use it in GitHub Desktop.
Send message to Kafka

In your class autowire (@@Autowired for Spring or @Inject for Guice)

@Autowired
private  IMessagingFactory messagingFactory;
import io.gitbub.devlibx.easy.helper.json.JsonUtils;

Object logEvent = ...
messagingFactory.getProducer("updateUserEvent")
        .ifPresent(producer -> producer.send(key, JsonUtils.asJson(logEvent)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment