Skip to content

Instantly share code, notes, and snippets.

@jaocamp
Last active August 22, 2018 20:32
Show Gist options
  • Save jaocamp/4c567acc679b6c992442b0a520ede7e7 to your computer and use it in GitHub Desktop.
Save jaocamp/4c567acc679b6c992442b0a520ede7e7 to your computer and use it in GitHub Desktop.
CQRS e Event Sourcing com Axon Framework e Spring Boot - AmqpEventPublicationConfiguration.java
package br.com.coderef.configuration;
import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.ExchangeBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AmqpEventPublicationConfiguration {
@Value("${axon.amqp.exchange:bank-account.events}")
String exchangeName;
@Bean
public Exchange exchange(){
return ExchangeBuilder.fanoutExchange(exchangeName).build();
}
@Bean
public Queue queue(){
return QueueBuilder.durable(exchangeName).build();
}
@Bean
public Binding binding(Queue queue, Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with("*").noargs();
}
@Autowired
public void configure(AmqpAdmin amqpAdmin, Exchange exchange, Queue queue, Binding binding){
amqpAdmin.declareExchange(exchange);
amqpAdmin.declareQueue(queue);
amqpAdmin.declareBinding(binding);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment