Skip to content

Instantly share code, notes, and snippets.

@brunoborges
Created October 2, 2019 05:45
Show Gist options
  • Save brunoborges/e066b4a92fc02cab7a03edee0d414c49 to your computer and use it in GitHub Desktop.
Save brunoborges/e066b4a92fc02cab7a03edee0d414c49 to your computer and use it in GitHub Desktop.
package com.seroter.confluentboot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@EnableBinding(Source.class)
@RestController
@SpringBootApplication
public class ConfluentBootApplication {
public static void main(String[] args) {
SpringApplication.run(ConfluentBootApplication.class, args);
}
@Autowired
private Source source;
@PostMapping("/messages")
public String postMsg(@RequestBody String msg) {
this.source.output().send(new GenericMessage<&gt;(msg));
return "success";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment