I am playing with Spring-cloud-stream and RabbitMQ.
I have a REST endpoint which produces the messages.
@SpringBootApplication
@EnableBinding(MyProcessor.class)
public class ProducerDemoApplication {
public static void main(String[] args) {
SpringApplication.run(ProducerDemoApplication.class, args);
}
}
@RestController
class ProducerController {
@Autowired
MyProcessor myProcessor;
@RequestMapping(value = "sendmessage/{message}", method = RequestMethod.GET)
public String sendMessage(@PathVariable("message") String message) {
myProcessor.anOutput().send(MessageBuilder.withPayload(message).build());
return "sent";
}
}
interface MyProcessor {
String INPUT = "myInput";
@Output("myOutput")
MessageChannel anOutput();
}
Through another application I am consuming these messages.
@StreamListener(MyProcessor.INPUT)
public void eventHandler(String message) {
System.out.println("************** Message received => "+message);
}
When both applications are UP and running. I am able to publish the message and consume it at the consumer.
The problem I am facing in the following scenario:
I am purposefully making the consumer down and publishing the message through the producer. Now when the consumer starts it is receiving no message.
I suppose RabbitMQ guarantees message delivery.
Github links
https://github.com/govi20/producer-demo
https://github.com/govi20/consumer-demo
String INPUT = "myInput";
- I don't see and@Input
configuration, etc – Oleg Zhurakousky