Here are the examples of the java api lib.KafkaService.sendMessageAsync() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : ChatController.java
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
@RequestMapping(value = "/message", consumes = { "application/json" }, produces = { MediaType.APPLICATION_JSON_VALUE }, method = RequestMethod.POST)
public ResponseEnreplacedy<Message> postMessage(@RequestBody Message msg) throws Exception {
msg.init();
System.out.println("Received message: " + msg);
if ("async1".equals(sendMode)) {
kafka.sendMessageAsync(msg, executor1);
System.out.println("Message sent async (executor1) to Kafka");
} else if ("async2".equals(sendMode)) {
kafka.sendMessageAsync(msg, executor2);
System.out.println("Message sent async (executor2) to Kafka");
} else {
kafka.sendMessage(msg);
System.out.println("Message sent sync to Kafka");
}
return new ResponseEnreplacedy<Message>(msg, HttpStatus.OK);
}