diff --git a/archiver/build.gradle b/archiver/build.gradle index aaac026..9f4c876 100644 --- a/archiver/build.gradle +++ b/archiver/build.gradle @@ -10,6 +10,7 @@ repositories { } dependencies { + implementation 'org.apache.kafka:kafka-clients:3.4.0' testImplementation platform('org.junit:junit-bom:5.9.1') testImplementation 'org.junit.jupiter:junit-jupiter' } diff --git a/archiver/src/main/java/org/student/Application.java b/archiver/src/main/java/org/student/Application.java index de20c6c..291fbc5 100644 --- a/archiver/src/main/java/org/student/Application.java +++ b/archiver/src/main/java/org/student/Application.java @@ -1,7 +1,10 @@ package org.student; +import org.student.messaging.MessageConsumer; + public class Application { public static void main(String[] args) { - System.out.println("Hello world!"); + MessageConsumer consumer = new MessageConsumer("localhost:9092", "core-file-garbage-group"); + consumer.consume("archiver-topic"); } } \ No newline at end of file diff --git a/archiver/src/main/java/org/student/messaging/MessageConsumer.java b/archiver/src/main/java/org/student/messaging/MessageConsumer.java new file mode 100644 index 0000000..aac83c3 --- /dev/null +++ b/archiver/src/main/java/org/student/messaging/MessageConsumer.java @@ -0,0 +1,44 @@ +package org.student.messaging; + +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.serialization.ByteArrayDeserializer; +import org.apache.kafka.common.serialization.StringDeserializer; + +import java.time.Duration; +import java.util.Arrays; +import java.util.Collections; +import java.util.Properties; + +public class MessageConsumer { + + private final KafkaConsumer consumer; + + public MessageConsumer(String bootstrapServers, String groupId) { + Properties properties = new Properties(); + properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + properties.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); + properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class); + this.consumer = new KafkaConsumer<>(properties); + } + + public void consume(String topic) { + TopicPartition partition = new TopicPartition(topic, 0); + consumer.assign(Collections.singletonList(partition)); + + while (true) { + ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); + if (!records.isEmpty()) { + for (ConsumerRecord record : records) { + System.out.println("Consumed message: " + new String(record.value())); + } + } else + System.out.println("No messages"); + } + + } +} diff --git a/archiver/src/main/java/org/student/messaging/MessageProducer.java b/archiver/src/main/java/org/student/messaging/MessageProducer.java new file mode 100644 index 0000000..713183d --- /dev/null +++ b/archiver/src/main/java/org/student/messaging/MessageProducer.java @@ -0,0 +1,26 @@ +package org.student.messaging; + +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.serialization.ByteArraySerializer; +import org.apache.kafka.common.serialization.StringSerializer; + +import java.util.Properties; + +public class MessageProducer { + + private final KafkaProducer producer; + + public MessageProducer(String bootstrapServers) { + Properties properties = new Properties(); + properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class); + this.producer = new KafkaProducer<>(properties); + } + + public void send(String topic, byte[] message) { + producer.send(new ProducerRecord<>(topic, 1, null, message)); + } +} diff --git a/artifact-processor/build.gradle b/artifact-processor/build.gradle index aaac026..9f4c876 100644 --- a/artifact-processor/build.gradle +++ b/artifact-processor/build.gradle @@ -10,6 +10,7 @@ repositories { } dependencies { + implementation 'org.apache.kafka:kafka-clients:3.4.0' testImplementation platform('org.junit:junit-bom:5.9.1') testImplementation 'org.junit.jupiter:junit-jupiter' } diff --git a/artifact-processor/src/main/java/org/student/Main.java b/artifact-processor/src/main/java/org/student/Application.java similarity index 79% rename from artifact-processor/src/main/java/org/student/Main.java rename to artifact-processor/src/main/java/org/student/Application.java index 5fd4e5a..de20c6c 100644 --- a/artifact-processor/src/main/java/org/student/Main.java +++ b/artifact-processor/src/main/java/org/student/Application.java @@ -1,6 +1,6 @@ package org.student; -public class Main { +public class Application { public static void main(String[] args) { System.out.println("Hello world!"); } diff --git a/artifact-processor/src/main/java/org/student/messaging/MessageConsumer.java b/artifact-processor/src/main/java/org/student/messaging/MessageConsumer.java new file mode 100644 index 0000000..d235831 --- /dev/null +++ b/artifact-processor/src/main/java/org/student/messaging/MessageConsumer.java @@ -0,0 +1,43 @@ +package org.student.messaging; + +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.serialization.ByteArrayDeserializer; +import org.apache.kafka.common.serialization.StringDeserializer; + +import java.time.Duration; +import java.util.Collections; +import java.util.Properties; + +public class MessageConsumer { + + private final KafkaConsumer consumer; + + public MessageConsumer(String bootstrapServers, String groupId) { + Properties properties = new Properties(); + properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + properties.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); + properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); + properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class); + this.consumer = new KafkaConsumer<>(properties); + } + + public void consume(String topic) { + TopicPartition partition = new TopicPartition(topic, 0); + consumer.assign(Collections.singletonList(partition)); + + while (true) { + ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); + if (!records.isEmpty()) { + for (ConsumerRecord record : records) { + System.out.println("Consumed message: " + new String(record.value())); + } + } else + System.out.println("No messages"); + } + + } +} diff --git a/artifact-processor/src/main/java/org/student/messaging/MessageProducer.java b/artifact-processor/src/main/java/org/student/messaging/MessageProducer.java new file mode 100644 index 0000000..713183d --- /dev/null +++ b/artifact-processor/src/main/java/org/student/messaging/MessageProducer.java @@ -0,0 +1,26 @@ +package org.student.messaging; + +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.serialization.ByteArraySerializer; +import org.apache.kafka.common.serialization.StringSerializer; + +import java.util.Properties; + +public class MessageProducer { + + private final KafkaProducer producer; + + public MessageProducer(String bootstrapServers) { + Properties properties = new Properties(); + properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class); + this.producer = new KafkaProducer<>(properties); + } + + public void send(String topic, byte[] message) { + producer.send(new ProducerRecord<>(topic, 1, null, message)); + } +} diff --git a/containers-errors/Errors.md b/containers-errors/Errors.md new file mode 100644 index 0000000..54d105b --- /dev/null +++ b/containers-errors/Errors.md @@ -0,0 +1 @@ +org.apache.kafka.common.network.InvalidReceiveException: Invalid receive (size = 1195725856 larger than 104857600) \ No newline at end of file diff --git a/core-back-end/build.gradle b/core-back-end/build.gradle index c3a7835..c80a545 100644 --- a/core-back-end/build.gradle +++ b/core-back-end/build.gradle @@ -18,11 +18,15 @@ configurations { } dependencies { + + implementation project(':messaging-api') + implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.boot:spring-boot-starter-security' - implementation group: 'org.keycloak', name: 'keycloak-spring-boot-adapter', version: '18.0.2' - implementation 'org.keycloak:keycloak-admin-client:23.0.3' +// implementation group: 'org.keycloak', name: 'keycloak-spring-boot-adapter', version: '23.0.3' +// implementation 'org.keycloak:keycloak-admin-client:23.0.3' + implementation 'org.springframework.kafka:spring-kafka' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'io.projectreactor:reactor-test' } @@ -30,3 +34,4 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + diff --git a/core-back-end/src/main/java/org/student/messaging/KafkaConfig.java b/core-back-end/src/main/java/org/student/messaging/KafkaConfig.java new file mode 100644 index 0000000..d9109ea --- /dev/null +++ b/core-back-end/src/main/java/org/student/messaging/KafkaConfig.java @@ -0,0 +1,35 @@ +package org.student.messaging; + +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.common.serialization.ByteArraySerializer; +import org.apache.kafka.common.serialization.StringSerializer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.core.DefaultKafkaProducerFactory; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.core.ProducerFactory; + +import java.util.HashMap; +import java.util.Map; + +@Configuration +public class KafkaConfig { + + @Value("${spring.kafka.bootstrap-servers}") + private String bootstrapServers; + + @Bean + public ProducerFactory producerFactory() { + Map configProp = new HashMap<>(); + configProp.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configProp.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configProp.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class); + return new DefaultKafkaProducerFactory<>(configProp); + } + + @Bean + public KafkaTemplate kafkaTemplate() { + return new KafkaTemplate<>(producerFactory()); + } +} diff --git a/core-back-end/src/main/java/org/student/messaging/archiver/ArchiverListener.java b/core-back-end/src/main/java/org/student/messaging/archiver/ArchiverListener.java new file mode 100644 index 0000000..f646c66 --- /dev/null +++ b/core-back-end/src/main/java/org/student/messaging/archiver/ArchiverListener.java @@ -0,0 +1,16 @@ +package org.student.messaging.archiver; + +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.kafka.annotation.TopicPartition; +import org.springframework.stereotype.Service; +import org.student.messaging.topics.KafkaTopics; + +@Service +public class ArchiverListener { + + @KafkaListener(id = "archiver-listener", topicPartitions = @TopicPartition(topic = KafkaTopics.ARCHIVER_TOPIC, partitions = {"1"}), groupId = "core-file-garbage-group") + public void consume(byte[] message) { + System.out.println("Consumed message: " + new String(message)); + } + +} diff --git a/core-back-end/src/main/java/org/student/messaging/archiver/ArchiverProducer.java b/core-back-end/src/main/java/org/student/messaging/archiver/ArchiverProducer.java new file mode 100644 index 0000000..ae1be63 --- /dev/null +++ b/core-back-end/src/main/java/org/student/messaging/archiver/ArchiverProducer.java @@ -0,0 +1,21 @@ +package org.student.messaging.archiver; + +import org.apache.kafka.clients.producer.ProducerRecord; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; +import org.student.messaging.topics.KafkaTopics; + +@Service +public class ArchiverProducer { + + private final KafkaTemplate template; + + ArchiverProducer(KafkaTemplate template) { + this.template = template; + } + + public void send(byte[] message) { + template.send(new ProducerRecord<>(KafkaTopics.ARCHIVER_TOPIC, 0, null, message)); + } + +} diff --git a/core-back-end/src/main/java/org/student/messaging/artifact_processor/ArtifactProcessorListener.java b/core-back-end/src/main/java/org/student/messaging/artifact_processor/ArtifactProcessorListener.java new file mode 100644 index 0000000..5d326dc --- /dev/null +++ b/core-back-end/src/main/java/org/student/messaging/artifact_processor/ArtifactProcessorListener.java @@ -0,0 +1,15 @@ +package org.student.messaging.artifact_processor; + +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.kafka.annotation.TopicPartition; +import org.springframework.stereotype.Service; +import org.student.messaging.topics.KafkaTopics; + +@Service +public class ArtifactProcessorListener { + @KafkaListener(id = "artifact-processor-listener", topicPartitions = @TopicPartition(topic = KafkaTopics.ARTIFACT_PROCESSOR_TOPIC, partitions = {"1"}), groupId = "core-file-garbage-group") + public void consume(byte[] message) { + System.out.println("Consumed message: " + new String(message)); + } + +} diff --git a/core-back-end/src/main/java/org/student/messaging/artifact_processor/ArtifactProcessorProducer.java b/core-back-end/src/main/java/org/student/messaging/artifact_processor/ArtifactProcessorProducer.java new file mode 100644 index 0000000..06a392a --- /dev/null +++ b/core-back-end/src/main/java/org/student/messaging/artifact_processor/ArtifactProcessorProducer.java @@ -0,0 +1,17 @@ +package org.student.messaging.artifact_processor; + +import org.apache.kafka.clients.producer.ProducerRecord; +import org.springframework.kafka.core.KafkaTemplate; +import org.student.messaging.topics.KafkaTopics; + +public class ArtifactProcessorProducer { + private final KafkaTemplate template; + + ArtifactProcessorProducer(KafkaTemplate template) { + this.template = template; + } + + public void send(byte[] message) { + template.send(new ProducerRecord<>(KafkaTopics.ARTIFACT_PROCESSOR_TOPIC, 0, null, message)); + } +} diff --git a/core-back-end/src/main/java/org/student/messaging/data_processor/DataProcessorListener.java b/core-back-end/src/main/java/org/student/messaging/data_processor/DataProcessorListener.java new file mode 100644 index 0000000..1021682 --- /dev/null +++ b/core-back-end/src/main/java/org/student/messaging/data_processor/DataProcessorListener.java @@ -0,0 +1,15 @@ +package org.student.messaging.data_processor; + +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.kafka.annotation.TopicPartition; +import org.springframework.stereotype.Service; +import org.student.messaging.topics.KafkaTopics; + +@Service +public class DataProcessorListener { + @KafkaListener(id = "data-processor-listener", topicPartitions = @TopicPartition(topic = KafkaTopics.DATA_PROCESSOR_TOPIC, partitions = {"1"}), groupId = "core-file-garbage-group") + public void consume(byte[] message) { + System.out.println("Consumed message: " + new String(message)); + } + +} diff --git a/core-back-end/src/main/java/org/student/messaging/data_processor/DataProcessorProducer.java b/core-back-end/src/main/java/org/student/messaging/data_processor/DataProcessorProducer.java new file mode 100644 index 0000000..df0ba77 --- /dev/null +++ b/core-back-end/src/main/java/org/student/messaging/data_processor/DataProcessorProducer.java @@ -0,0 +1,19 @@ +package org.student.messaging.data_processor; + +import org.apache.kafka.clients.producer.ProducerRecord; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; +import org.student.messaging.topics.KafkaTopics; + +@Service +public class DataProcessorProducer { + private final KafkaTemplate template; + + DataProcessorProducer(KafkaTemplate template) { + this.template = template; + } + + public void send(byte[] message) { + template.send(new ProducerRecord<>(KafkaTopics.DATA_PROCESSOR_TOPIC, 0, null, message)); + } +} diff --git a/core-back-end/src/main/resources/application.yaml b/core-back-end/src/main/resources/application.yaml index 7bc0f13..079f1c7 100644 --- a/core-back-end/src/main/resources/application.yaml +++ b/core-back-end/src/main/resources/application.yaml @@ -12,3 +12,15 @@ keycloak: patterns: - /secured/* cors: true + +spring: + kafka: + bootstrap-servers: localhost:9092 + consumer: + group-id: core-file-garbage-group + auto-offset-reset: earlier + key-deserializer: org.apache.kafka.common.serialization.StringDeserializer + value-deserializer: org.apache.kafka.common.serialization.ByteArrayDeserializer + producer: + key-serializer: org.apache.kafka.common.serialization.StringSerializer + value-serializer: org.apache.kafka.common.serialization.ByteArraySerializer \ No newline at end of file diff --git a/data-processor/build.gradle b/data-processor/build.gradle index aaac026..d02f5ae 100644 --- a/data-processor/build.gradle +++ b/data-processor/build.gradle @@ -1,19 +1,31 @@ plugins { id 'java' + id 'org.springframework.boot' version '3.2.0' + id 'io.spring.dependency-management' version '1.1.4' } -group = 'org.student' -version = '1.0-SNAPSHOT' +group = "org.student" +version = "1.0-SNAPSHOT" -repositories { - mavenCentral() +java { + sourceCompatibility = '17' +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } } dependencies { - testImplementation platform('org.junit:junit-bom:5.9.1') - testImplementation 'org.junit.jupiter:junit-jupiter' + implementation project(':messaging-api') + + implementation 'org.springframework.boot:spring-boot-starter:3.2.0' + implementation 'org.springframework.kafka:spring-kafka' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'io.projectreactor:reactor-test' } -test { +tasks.named('test') { useJUnitPlatform() } \ No newline at end of file diff --git a/data-processor/src/main/java/org/student/Application.java b/data-processor/src/main/java/org/student/Application.java new file mode 100644 index 0000000..3070c43 --- /dev/null +++ b/data-processor/src/main/java/org/student/Application.java @@ -0,0 +1,11 @@ +package org.student; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} \ No newline at end of file diff --git a/data-processor/src/main/java/org/student/Main.java b/data-processor/src/main/java/org/student/Main.java deleted file mode 100644 index 5fd4e5a..0000000 --- a/data-processor/src/main/java/org/student/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.student; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/data-processor/src/main/java/org/student/messaging/KafkaConfig.java b/data-processor/src/main/java/org/student/messaging/KafkaConfig.java new file mode 100644 index 0000000..d9109ea --- /dev/null +++ b/data-processor/src/main/java/org/student/messaging/KafkaConfig.java @@ -0,0 +1,35 @@ +package org.student.messaging; + +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.common.serialization.ByteArraySerializer; +import org.apache.kafka.common.serialization.StringSerializer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.core.DefaultKafkaProducerFactory; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.core.ProducerFactory; + +import java.util.HashMap; +import java.util.Map; + +@Configuration +public class KafkaConfig { + + @Value("${spring.kafka.bootstrap-servers}") + private String bootstrapServers; + + @Bean + public ProducerFactory producerFactory() { + Map configProp = new HashMap<>(); + configProp.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + configProp.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + configProp.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class); + return new DefaultKafkaProducerFactory<>(configProp); + } + + @Bean + public KafkaTemplate kafkaTemplate() { + return new KafkaTemplate<>(producerFactory()); + } +} diff --git a/data-processor/src/main/java/org/student/messaging/MessageConsumer.java b/data-processor/src/main/java/org/student/messaging/MessageConsumer.java new file mode 100644 index 0000000..ac3c53a --- /dev/null +++ b/data-processor/src/main/java/org/student/messaging/MessageConsumer.java @@ -0,0 +1,14 @@ +package org.student.messaging; + +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.kafka.annotation.TopicPartition; +import org.springframework.stereotype.Service; +import org.student.messaging.topics.KafkaTopics; + +@Service +public class MessageConsumer { + @KafkaListener(id = "data-processor-listener", topicPartitions = @TopicPartition(topic = KafkaTopics.DATA_PROCESSOR_TOPIC, partitions = {"0"}), groupId = "core-file-garbage-group") + public void consume(byte[] message) { + System.out.println("Consumed message: " + new String(message)); + } +} diff --git a/data-processor/src/main/java/org/student/messaging/MessageProducer.java b/data-processor/src/main/java/org/student/messaging/MessageProducer.java new file mode 100644 index 0000000..ae1819a --- /dev/null +++ b/data-processor/src/main/java/org/student/messaging/MessageProducer.java @@ -0,0 +1,19 @@ +package org.student.messaging; + +import org.apache.kafka.clients.producer.ProducerRecord; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; +import org.student.messaging.topics.KafkaTopics; + +@Service +public class MessageProducer { + private final KafkaTemplate template; + + MessageProducer(KafkaTemplate template) { + this.template = template; + } + + public void send(byte[] message) { + template.send(new ProducerRecord<>(KafkaTopics.DATA_PROCESSOR_TOPIC, 1, null, message)); + } +} diff --git a/data-processor/src/main/resources/application.yaml b/data-processor/src/main/resources/application.yaml new file mode 100644 index 0000000..902cc5c --- /dev/null +++ b/data-processor/src/main/resources/application.yaml @@ -0,0 +1,11 @@ +spring: + kafka: + bootstrap-servers: localhost:9092 + consumer: + group-id: core-file-garbage-group + auto-offset-reset: earlier + key-deserializer: org.apache.kafka.common.serialization.StringDeserializer + value-deserializer: org.apache.kafka.common.serialization.ByteArrayDeserializer + producer: + key-serializer: org.apache.kafka.common.serialization.StringSerializer + value-serializer: org.apache.kafka.common.serialization.ByteArraySerializer \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 017930c..840e69e 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,9 +2,6 @@ version: '3.7' services: keycloak: -# build: -# context: . -# dockerfile: Dockerfile image: jboss/keycloak environment: - KEYCLOAK_USER=admin @@ -28,5 +25,23 @@ services: volumes: - postgres_data:/var/lib/postgresql/data + zookeeper: + image: confluentinc/cp-zookeeper:latest + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + + kafka: + image: confluentinc/cp-kafka:latest + depends_on: + - zookeeper + restart: on-failure + environment: + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092 + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 + KAFKA_CREATE_TOPICS: "archiver-topic:2:1,data-processor-topic:2:1,artifact-processor-topic:2:1" + ports: + - "9092:9092" + volumes: postgres_data: diff --git a/messaging-api/build.gradle b/messaging-api/build.gradle new file mode 100644 index 0000000..f38c271 --- /dev/null +++ b/messaging-api/build.gradle @@ -0,0 +1,19 @@ +plugins { + id("java") +} + +group = "org.student" +version = "1.0-SNAPSHOT" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation(platform("org.junit:junit-bom:5.9.1")) + testImplementation("org.junit.jupiter:junit-jupiter") +} + +tasks.test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/messaging-api/src/main/java/org/student/messaging/topics/KafkaTopics.java b/messaging-api/src/main/java/org/student/messaging/topics/KafkaTopics.java new file mode 100644 index 0000000..244d53d --- /dev/null +++ b/messaging-api/src/main/java/org/student/messaging/topics/KafkaTopics.java @@ -0,0 +1,8 @@ +package org.student.messaging.topics; + +public class KafkaTopics { + public static final String ARCHIVER_TOPIC = "archiver-topic"; + public static final String DATA_PROCESSOR_TOPIC ="data-processor-topic"; + public static final String ARTIFACT_PROCESSOR_TOPIC = "artifact-processor-topic"; +} + diff --git a/settings.gradle b/settings.gradle index c161e9b..4405bff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,5 @@ include 'core-back-end' include 'archiver' include 'artifact-processor' include 'data-processor' +include 'messaging-api'