Commit 05cace31 authored by Ina Curdt's avatar Ina Curdt
Browse files

SI-388, SI-389, SI-391 In beiden Backend-Services Konfiguration für RabbitMQ...

SI-388, SI-389, SI-391 In beiden Backend-Services Konfiguration für RabbitMQ angepasst, importDTO im Hauptservice geändert
parent 0c1bef1b
......@@ -46,6 +46,7 @@
<openfeign.version>2.2.0.RELEASE</openfeign.version>
<keycloak-core.version>3.4.2.Final</keycloak-core.version>
<greenmail.version>1.5.11</greenmail.version>
<rabbitmq.version>5.2.0</rabbitmq.version>
</properties>
<dependencies>
......@@ -53,6 +54,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
......@@ -161,6 +167,12 @@
<version>${greenmail.version}</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>${rabbitmq.version}</version>
</dependency>
</dependencies>
......
......@@ -5,10 +5,13 @@ import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
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;
import org.springframework.data.domain.AuditorAware;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
......@@ -19,26 +22,30 @@ import java.util.Optional;
@Log4j2
public class RabbitMqConfig {
@Value("${rabbitmqconfig.routing-key}")
@Value("${spring.rabbitmq.routingkey}")
public String routingKey;
@Value("${rabbitmqconfig.exchange-name}")
@Value("${spring.rabbitmq.exchangename}")
public String exchangeName;
@Value("${spring.rabbitmq.queuename}")
public String queueName;
// Initialisisation of RabbitMQ eexchange, queue and binding
/*@Bean
public DirectExchange e1() {
@Autowired
private org.springframework.amqp.rabbit.core.RabbitTemplate template;
@Bean
public DirectExchange exchange() {
return new DirectExchange(exchangeName);
}
@Bean
public Queue messageImportQueue() {
return new Queue(queueName);
public MessageChannel messageImportChannel() {
return new DirectChannel();
}
@Bean
public Binding b1() {
return BindingBuilder.bind(messageImportQueue()).to(e1()).with(routingKey);
}*/
public Queue messageImportQueue() { return new Queue(queueName); }
@Bean
public Binding binding() { return BindingBuilder.bind(messageImportQueue()).to(exchange()).with(routingKey); }
}
\ No newline at end of file
package org.eclipse.openk.gridfailureinformation.config.jobs;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.SimpleMessageConverter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.amqp.core.Message;
import java.nio.charset.Charset;
import java.util.Random;
......@@ -20,13 +22,15 @@ import java.util.Random;
@Log4j2
public class JobManager {
@Value("${rabbitmqconfig.routing-key}")
public String routingKey;
@Value("${rabbitmqconfig.exchange-name}")
public String exchangeName;
@Autowired
private RabbitTemplate template;
// @Value("${rabbitmqconfig.routing-key}")
// public String routingKey;
// @Value("${rabbitmqconfig.exchange-name}")
// public String exchangeName;
//
// @Autowired
// private RabbitTemplate template;
// Testjob for sending data into queue
/*@Scheduled(initialDelay = 1000, fixedRate = 5000)
......
......@@ -24,10 +24,10 @@ import java.util.UUID;
public class ImportDataDto implements Serializable {
@JsonProperty("id")
private UUID uuid;
private String name;
private String colorCode;
private String metaId;
private String description;
private String source;
private String messageContent;
}
......@@ -22,11 +22,10 @@ spring:
port: 5672
username: guest
password: guest
queuename: messageImportQueue
queuename: failureImportQueue
routingkey: failureImportChannel.failureImportKey
exchangename: failureImportChannel
rabbitmqconfig:
routing-key: messageImportChannel.process
exchange-name: messageImportChannel
server:
max-http-header-size: 262144
......
......@@ -22,11 +22,10 @@ spring:
port: 5672
username: guest
password: guest
queuename: messageImportQueue
queuename: failureImportQueueTest
routingkey: failureImportChannelTest.failureImportKeyTest
exchangename: failureImportChannel
rabbitmqconfig:
routing-key: messageImportChannel.process
exchange-name: messageImportChannel
server:
port: 9165
......
......@@ -35,19 +35,16 @@ public class EventProducerConfig {
}
@Bean
public MessageChannel messageImportChannel() {
return new DirectChannel();
}
public MessageChannel failureImportChannel() { return new DirectChannel(); }
@Bean
public Queue messageImportQueue() { return new Queue(queueName); }
public Queue failureImportQueue() { return new Queue(queueName); }
@Bean
public Binding binding() { return BindingBuilder.bind(messageImportQueue()).to(exchange()).with(routingKey); }
public Binding binding() { return BindingBuilder.bind(failureImportQueue()).to(exchange()).with(routingKey); }
@Bean
@ServiceActivator(inputChannel = "messageImportChannel")
@ServiceActivator(inputChannel = "failureImportChannel")
public MessageHandler messageHandler() {
return message -> rabbitTemplate.convertAndSend(exchangeName, routingKey, message.getPayload(), message1 -> {
......
......@@ -33,12 +33,12 @@ import org.springframework.messaging.MessageChannel;
public class ImportService {
@Autowired
private MessageChannel messageImportChannel;
private MessageChannel failureImportChannel;
public void pushForeignFailure(ForeignFailureDto foreignFailureDto) {
try {
messageImportChannel.send(MessageBuilder.withPayload(foreignFailureDto.getPayload())
failureImportChannel.send(MessageBuilder.withPayload(foreignFailureDto.getPayload())
.setHeader("metaId", foreignFailureDto.getMetaId())
.setHeader("description", foreignFailureDto.getDescription())
.setHeader("source", foreignFailureDto.getSource())
......
......@@ -22,9 +22,9 @@ spring:
port: 5672
username: guest
password: guest
routingkey: messageImportChannel.process
exchangename: messageImportChannel
queuename: messageImportQueue
queuename: failureImportQueue
routingkey: failureImportChannel.failureImportKey
exchangename: failureImportChannel
server:
max-http-header-size: 262144
......@@ -121,9 +121,9 @@ spring:
port: 5672
username: guest
password: guest
routingkey: messageImportChannel.process
exchangename: messageImportChannel
queuename: messageImportQueue
queuename: failureImportQueue
routingkey: failureImportChannel.failureImportKey
exchangename: failureImportChannel
server:
port: 9175
......
......@@ -22,10 +22,9 @@ spring:
port: 5672
username: guest
password: guest
routingkey: messageImportChannel.process
exchangename: messageImportChannel
queuename: messageImportQueue
queuename: failureImportQueueTest
routingkey: failureImportChannelTest.failureImportKeyTest
exchangename: failureImportChannel
eureka:
client:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment