I am using Spring Boot framework. I want to send an object from a service to another service via RabbitMQ like this:
Service A:
rabbitTemplate.convertAndSend("queue", createAccountRequestMessage);
Service B:
@RabbitListener(queues = "queue")
public void onAccountRequested(@Valid CreateAccountRequestMessage createAccountRequestMessage, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG, long tag) throws IOException
{
}
In CreateAccountRequestMessage class I have defined some validation annotations like @NotEmpty, @NotNull and etc, but when I'm sending wrong message from service A to service B, @Valid annotation doesn't work and CreateAccountRequestMessage object is not validated before invoke onAccountRequested method.