Iniciado a implementacao do rabbit para enviar notificacoes para a fila inves de enviar direto para o DC.
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -43,6 +43,17 @@
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package br.com.stackpanel.duck_api.config;
|
||||
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static br.com.stackpanel.duck_api.entity.enums.QueueNames.QUEUE_NOTIFICATION_CAD;
|
||||
import static br.com.stackpanel.duck_api.entity.enums.QueueNames.QUEUE_NOTIFICATION_ERROR;
|
||||
|
||||
@Configuration
|
||||
public class RabbitConfig {
|
||||
|
||||
@Bean
|
||||
public Queue queueNotificationError() {
|
||||
return new Queue(QUEUE_NOTIFICATION_ERROR.label, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue queueNotificationCad() {
|
||||
return new Queue(QUEUE_NOTIFICATION_CAD.label, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package br.com.stackpanel.duck_api.entity.enums;
|
||||
|
||||
public enum QueueNames {
|
||||
|
||||
QUEUE_NOTIFICATION_ERROR("QUEUE_NOTIFICATION_ERROR"),
|
||||
QUEUE_NOTIFICATION_CAD("QUEUE_NOTIFICATION_CAD");
|
||||
|
||||
|
||||
public final String label;
|
||||
|
||||
private QueueNames(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package br.com.stackpanel.duck_api.service;
|
||||
|
||||
public interface RabbitPublisherService {
|
||||
|
||||
void sendNotificationCad(String notificationCad);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package br.com.stackpanel.duck_api.service.impl;
|
||||
|
||||
import br.com.stackpanel.duck_api.service.RabbitPublisherService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
|
||||
import static br.com.stackpanel.duck_api.entity.enums.QueueNames.QUEUE_NOTIFICATION_ERROR;
|
||||
|
||||
public class RabbitPublisherServiceImpl implements RabbitPublisherService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RabbitPublisherServiceImpl.class);
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
public RabbitPublisherServiceImpl(RabbitTemplate rabbitTemplate) {
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendNotificationCad(String notificationCad) {
|
||||
log.info("Sending notification Cad: {}", notificationCad);
|
||||
rabbitTemplate.convertAndSend(QUEUE_NOTIFICATION_ERROR.label, notificationCad);
|
||||
}
|
||||
}
|
||||
@@ -6,3 +6,9 @@ spring.datasource.username=${db_user}
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
|
||||
|
||||
spring.rabbitmq.host=rabbit.stackpanel.com.br
|
||||
spring.rabbitmq.port=5672
|
||||
spring.rabbitmq.username=${rabbit_username}
|
||||
spring.rabbitmq.password=${rabbit_password}
|
||||
@@ -4,3 +4,9 @@ spring.datasource.url=${db_host:jdbc:postgresql://db.stackpanel.com.br:5432/nexu
|
||||
spring.datasource.password=${db_pass}
|
||||
spring.datasource.username=${db_user}
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
|
||||
spring.rabbitmq.host=rabbit.stackpanel.com.br
|
||||
spring.rabbitmq.port=5672
|
||||
spring.rabbitmq.username=${rabbit_username}
|
||||
spring.rabbitmq.password=${rabbit_password}
|
||||
Reference in New Issue
Block a user