Last active
August 22, 2018 20:31
-
-
Save jaocamp/3057b7ea85a56f9eb68aad3fb02e2b8a to your computer and use it in GitHub Desktop.
CQRS e Event Sourcing com Axon Framework e Spring Boot - AmqpConfiguration.java
This file contains hidden or 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 br.com.coderef.configuration; | |
import com.rabbitmq.client.Channel; | |
import lombok.extern.slf4j.Slf4j; | |
import org.axonframework.amqp.eventhandling.DefaultAMQPMessageConverter; | |
import org.axonframework.amqp.eventhandling.spring.SpringAMQPMessageSource; | |
import org.axonframework.serialization.Serializer; | |
import org.springframework.amqp.core.Message; | |
import org.springframework.amqp.rabbit.annotation.RabbitListener; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
@Slf4j | |
@Configuration | |
public class AmqpConfiguration { | |
@Bean | |
public SpringAMQPMessageSource complaintEventsMethod(Serializer serializer) { | |
return new SpringAMQPMessageSource(new DefaultAMQPMessageConverter(serializer)) { | |
@RabbitListener(queues = "${axon.amqp.exchange}") | |
@Override | |
public void onMessage(Message message, Channel channel) { | |
log.debug("Event Received: {}", message.getBody().toString()); | |
super.onMessage(message, channel); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment