Created
December 2, 2021 15:28
-
-
Save miluna/2bf1a04a55b0950d661d1cc28c2f6c8d to your computer and use it in GitHub Desktop.
Sample Rabbitmq Event Handler java
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
@Service | |
@AllArgsConstructor | |
public class SampleRabbitmqEventHandler implements EventHandler<SampleDomainEvent> { | |
private final SampleService service; | |
@RabbitListener( | |
bindings = @QueueBinding( | |
value = @Queue(value = QUEUE_NAME, durable = "true", | |
arguments = {@Argument( | |
name = DEAD_LETTER_EXCHANGE_ARGUMENT, | |
value = DEAD_LETTER_EXCHANGE_NAME)} | |
), | |
exchange = @Exchange(value = SampleDomainEvent.EXCHANGE_NAME, type = "topic"), | |
key = SampleDomainEvent.ROUTING_KEY | |
) | |
) | |
@Override | |
public void on(@Payload SampleDomainEvent event, | |
@Headers Map<String, String> headers) { | |
service.doSomething(event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment