Update versions and switch to java 21
This commit is contained in:
parent
9e90c73de1
commit
2d328743ff
@ -37,7 +37,7 @@ jobs:
|
|||||||
- name: Set up java
|
- name: Set up java
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
id: tests
|
id: tests
|
||||||
@ -64,7 +64,7 @@ jobs:
|
|||||||
- name: Set up java
|
- name: Set up java
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
id: integration-tests
|
id: integration-tests
|
||||||
@ -91,7 +91,7 @@ jobs:
|
|||||||
- name: Set up java
|
- name: Set up java
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '21'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
- name: Build
|
- name: Build
|
||||||
id: build
|
id: build
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
This project holds all the examples of apache beam that are detailed on my blog at [https://barrelsofdata.com](https://barrelsofdata.com)
|
This project holds all the examples of apache beam that are detailed on my blog at [https://barrelsofdata.com](https://barrelsofdata.com)
|
||||||
|
|
||||||
## Build instructions
|
## Build instructions
|
||||||
This is a multi-module project and uses version catalogs. The dependencies can we viewed at [/barrelsofdata/apache-beam-examples/src/branch/main/gradle/libs.versions.toml](./gradle/libs.versions.toml)
|
This is a multi-module project and uses version catalogs. The dependencies can we viewed at [./gradle/libs.versions.toml](./gradle/libs.versions.toml)
|
||||||
|
|
||||||
To build project, execute the following commands from the project root
|
To build project, execute the following commands from the project root
|
||||||
- To clear all compiled classes, build and log directories
|
- To clear all compiled classes, build and log directories
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
[versions]
|
[versions]
|
||||||
apache-beam = "2.51.0"
|
apache-beam = "2.52.0"
|
||||||
apache-kafka = "3.3.2"
|
apache-kafka = "3.6.1"
|
||||||
h2-database = "2.2.224"
|
h2-database = "2.2.224"
|
||||||
hamcrest = "2.2"
|
hamcrest = "2.2"
|
||||||
jackson = "2.15.3"
|
jackson = "2.16.0"
|
||||||
java = "17"
|
java = "21"
|
||||||
junit-jupiter = "5.10.0"
|
junit-jupiter = "5.10.1"
|
||||||
postgresql-driver = "42.6.0"
|
postgresql-driver = "42.7.1"
|
||||||
spring-kafka-test = "3.0.12"
|
spring-kafka-test = "3.1.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
beam-core = { module = "org.apache.beam:beam-sdks-java-core", version.ref = "apache-beam" }
|
beam-core = { module = "org.apache.beam:beam-sdks-java-core", version.ref = "apache-beam" }
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
@ -5,16 +5,18 @@ import org.apache.kafka.clients.producer.ProducerConfig;
|
|||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
import org.apache.kafka.common.serialization.StringSerializer;
|
import org.apache.kafka.common.serialization.StringSerializer;
|
||||||
import org.springframework.kafka.test.EmbeddedKafkaBroker;
|
import org.springframework.kafka.test.EmbeddedKafkaBroker;
|
||||||
|
import org.springframework.kafka.test.EmbeddedKafkaKraftBroker;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class EmbeddedKafka {
|
public class EmbeddedKafka {
|
||||||
private static final int NUMBER_OF_BROKERS = 1;
|
private static final int NUMBER_OF_BROKERS = 2;
|
||||||
private final EmbeddedKafkaBroker embeddedKafkaBroker;
|
private final EmbeddedKafkaBroker embeddedKafkaBroker;
|
||||||
private final Producer kafkaProducer;
|
private Producer kafkaProducer;
|
||||||
|
|
||||||
public static EmbeddedKafka withDefaults() {
|
public static EmbeddedKafka withDefaults() {
|
||||||
return new EmbeddedKafka(NUMBER_OF_BROKERS);
|
return new EmbeddedKafka(NUMBER_OF_BROKERS);
|
||||||
@ -22,9 +24,8 @@ public class EmbeddedKafka {
|
|||||||
|
|
||||||
public EmbeddedKafka(int numBrokers) {
|
public EmbeddedKafka(int numBrokers) {
|
||||||
validate(numBrokers);
|
validate(numBrokers);
|
||||||
embeddedKafkaBroker = new EmbeddedKafkaBroker(numBrokers);
|
embeddedKafkaBroker = new EmbeddedKafkaKraftBroker(numBrokers, numBrokers);
|
||||||
embeddedKafkaBroker.brokerProperty("log.dir", "build/embedded-kafka/logs");
|
embeddedKafkaBroker.brokerProperties(Map.of("log.dir", "build/embedded-kafka/logs"));
|
||||||
kafkaProducer = new Producer(embeddedKafkaBroker.getBrokersAsString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
@ -36,7 +37,7 @@ public class EmbeddedKafka {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void send(String topic, String key, String message) {
|
public void send(String topic, String key, String message) {
|
||||||
kafkaProducer.send(topic, key, message);
|
getKafkaProducer().send(topic, key, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendFile(String topic, String filepath, String delimiter) throws FileNotFoundException {
|
public void sendFile(String topic, String filepath, String delimiter) throws FileNotFoundException {
|
||||||
@ -56,6 +57,12 @@ public class EmbeddedKafka {
|
|||||||
return embeddedKafkaBroker.getBrokersAsString();
|
return embeddedKafkaBroker.getBrokersAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Producer getKafkaProducer() {
|
||||||
|
if(kafkaProducer == null)
|
||||||
|
kafkaProducer = new Producer(embeddedKafkaBroker.getBrokersAsString());
|
||||||
|
return kafkaProducer;
|
||||||
|
}
|
||||||
|
|
||||||
private void validate(int numBrokers) {
|
private void validate(int numBrokers) {
|
||||||
if(numBrokers < 1)
|
if(numBrokers < 1)
|
||||||
throw new RuntimeException("Number of brokers should be atleast 1");
|
throw new RuntimeException("Number of brokers should be atleast 1");
|
||||||
|
Loading…
Reference in New Issue
Block a user