Created
October 2, 2019 05:45
-
-
Save brunoborges/e066b4a92fc02cab7a03edee0d414c49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<>(msg)); | |
return "success"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment