Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Spring Boot 3 #190

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI build

on:
pull_request:
branches:
- master
jobs:
build:
name: Maven build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Build with Maven
run: ./mvnw package -B -V
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,23 @@ You may of course always setup a fresh system with the newest version.

## Prerequisites

This library was tested with Java 11 (starting with 21.0.0), Spring Boot 2.5.6.RELEASE and Flyway 7.
It relies on an existing configured PostgreSQL DataSource.
**If you are still using Spring Boot 1.x, please use versions < 20.0.0, they are still actively maintained ([Documentation](https://github.com/zalando-nakadi/nakadi-producer-spring-boot-starter/tree/spring-boot-1)).**
Your Spring Boot version must be compatible with the version of this library you want to use.

| Spring Boot | nakadi-producer-spring-boot-starter |
|---|---|
| 3.x | >= 30.0.0 |
| 2.x | >= 20.0.0 but < 30.0.0 |
Comment on lines +48 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is no way of having a version of the library which works with both Spring boot 2 and 3?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in my understanding - the 'small' changes in Spring Boot 3 (namely the Jakarta EE 10 + Flyway 9 adoption, and the lack of support for the old way of specifying autoconfiguration) are incompatible between the two versions.

| 1.x | < 20.0.0 |

Additionally, this library was tested with:

| nakadi-producer-spring-boot-starter | Java | Spring Boot | Flyway | |
|---|---|---|---|---|
| 30.0.0 | 21 | 3.2.5.RELEASE | 9 ||
| 21.0.0 | 11 | 2.5.6.RELEASE | 7 ||
| 4.5.0 | 8 | 1.5.3.RELEASE | 4 |[Documentation](https://github.com/zalando-nakadi/nakadi-producer-spring-boot-starter/tree/spring-boot-1)|

It relies on an existing configured PostgreSQL DataSource.
This library also uses:

* flyway-core
Expand Down Expand Up @@ -466,7 +479,7 @@ We (the [maintainers](MAINTAINERS)) want to thank our main contributors:

* Alexander Libin (@qlibin), who created a similar predecessor library (tarbela-producer-spring-boot-starter,
now not public anymore), from which this one was forked.
* Lucas Medeiros de Azevedo (@wormangel), who added support for business events.
* Lucas Medeiros de Azevedo (@wormangel), who added support for business events and support for Spring Boot 3.
* Benjamin Gehrels (@BGehrels), who co-maintained this project from its inception in 2017 until 2019, contributing many features and ideas.

### Contact
Expand Down
6 changes: 3 additions & 3 deletions nakadi-producer-loadtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.zalando</groupId>
<artifactId>nakadi-producer-reactor</artifactId>
<version>21.0.0</version>
<version>30.0.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down Expand Up @@ -50,13 +50,13 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.16.0</version>
<version>1.19.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ private void fireBusinessEvents(int amount) {
private void sendEvents() {
eventTransmitter.sendEvents();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '2'
services:

nakadi:
image: adyach/nakadi-docker:3.0.8
image: ghcr.io/adyach/nakadi-docker/nakadi:3.5
ports:
- "8080:8080"
depends_on:
Expand All @@ -16,7 +16,7 @@ services:
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres_nakadi:5432/local_nakadi_db

postgres_nakadi:
image: adyach/nakadi-postgres:latest
image: ghcr.io/adyach/nakadi-docker/postgres:latest
ports:
- "5432:5432"
environment:
Expand All @@ -25,12 +25,12 @@ services:
POSTGRES_DB: local_nakadi_db

zookeeper:
image: wurstmeister/zookeeper:3.4.6
image: bitnami/zookeeper:3.7.2
ports:
- "2181:2181"

kafka:
image: wurstmeister/kafka:0.10.1.0
image: bitnami/kafka:0.10.2.1
ports:
- "9092:9092"
depends_on:
Expand All @@ -43,4 +43,4 @@ services:
KAFKA_DELETE_TOPIC_ENABLE: 'true'
KAFKA_BROKER_ID: 0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/run/docker.sock:/var/run/docker.sock
27 changes: 11 additions & 16 deletions nakadi-producer-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.zalando</groupId>
<artifactId>nakadi-producer-reactor</artifactId>
<version>21.0.0</version>
<version>30.0.0-SNAPSHOT</version>
</parent>

<artifactId>nakadi-producer-spring-boot-starter</artifactId>
Expand All @@ -19,9 +19,9 @@
<description>Spring Boot Auto Configuration for Nakadi event producer</description>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<java.version>11</java.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>
</properties>

<dependencies>
Expand All @@ -41,6 +41,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -65,12 +66,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-postgres</artifactId>
Expand All @@ -84,9 +79,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.4.0</version>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -128,7 +123,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -141,9 +136,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.6.3</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<doclint>none</doclint>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -171,7 +166,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.zalando.nakadiproducer;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

import jakarta.annotation.PostConstruct;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.callback.BaseCallback;
import org.flywaydb.core.api.callback.Context;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.zalando.nakadiproducer.NakadiProducerAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.zalando.nakadiproducer.eventlog.EventLogWriter;
import org.zalando.nakadiproducer.eventlog.impl.EventLog;
import org.zalando.nakadiproducer.eventlog.impl.EventLogRepository;
import org.zalando.nakadiproducer.transmission.MockNakadiPublishingClient;
import org.zalando.nakadiproducer.transmission.impl.EventTransmissionService;
import org.zalando.nakadiproducer.transmission.impl.EventTransmitter;
Expand All @@ -30,6 +31,9 @@ public class LockingIT extends BaseMockedExternalCommunicationIT {
@Autowired
private EventTransmitter eventTransmitter;

@Autowired
private EventLogRepository eventLogRepository;

@Autowired
private EventTransmissionService eventTransmissionService;

Expand All @@ -41,6 +45,7 @@ public class LockingIT extends BaseMockedExternalCommunicationIT {
public void clearNakadiEvents() {
eventTransmitter.sendEvents();
nakadiClient.clearSentEvents();
eventLogRepository.deleteAll();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.zalando.nakadiproducer;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.inOrder;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.zalando.nakadiproducer;

import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.core.Is.is;

import javax.transaction.Transactional;
import jakarta.transaction.Transactional;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.zalando.nakadiproducer.snapshots;

import static com.jayway.restassured.RestAssured.given;
import static io.restassured.RestAssured.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
Expand All @@ -9,8 +9,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalManagementPort;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ActiveProfiles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>nakadi-producer-starter-spring-boot-2-test</artifactId>
<artifactId>nakadi-producer-starter-spring-boot-3-test</artifactId>
<groupId>org.zalando</groupId>


<parent>
<groupId>org.zalando</groupId>
<artifactId>nakadi-producer-reactor</artifactId>
<version>21.0.0</version>
<version>30.0.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand All @@ -31,18 +31,11 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>com.opentable.components</groupId>
<artifactId>otj-pg-embedded</artifactId>
<version>0.12.0</version>
<exclusions>
<exclusion>
<artifactId>postgresql</artifactId>
<groupId>postgresql</groupId>
</exclusion>
</exclusions>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-postgres</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -62,13 +55,30 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.4.0</version>
<version>5.4.0</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens java.base/java.util=ALL-UNNAMED</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.zalando.nakadiproducer.tests;

import com.opentable.db.postgres.embedded.EmbeddedPostgres;
import io.zonky.test.db.postgres.embedded.EmbeddedPostgres;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
Expand Down
Copy link
Member

@ePaul ePaul Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just was looking at this again, and noticed that this test isn't actually executed when building the project (e.g. with mvnw clean install).

I was just going to complain, but then I also ran the build in master, and found that the test isn't run spring-boot 2 either :-/

I don't remember anymore whether we intentionally disabled this to get the build running faster ... but in effect I can't get it to run now. Any ideas?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try to fix this myself (could try later if needed) but it smells to me like mixup between JUnit 4 and 5 (and/or JUnit 4 vs. recent Spring Boot issues) - I faced similar things in the past and it was related to that (the fix was to move everything to JUnit 5 instead of having this versions spaghetti (e.g. get rid of @RunWith(SpringRunner) in favor of only @SpringBootTest, etc)

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalManagementPort;
import org.springframework.test.context.junit4.SpringRunner;
import org.zalando.nakadiproducer.transmission.MockNakadiPublishingClient;
import org.zalando.nakadiproducer.transmission.impl.EventTransmitter;
Expand Down
Loading