Add share-groups module: Kafka 4.3.1 share groups with Spring for Apache Kafka 4.1.1
Six consumers on two partitions under a consumer group, a share group with the default share.acquire.mode and a share group with record_limit; the three acknowledgement types and a record that is released until Kafka stops redelivering it; a new share group starting at latest; the ordering a share group gives up; and Spring Kafka's share containers in implicit and manual acknowledgement modes. Tests run against a real broker (scripts/broker-up.sh) and write output/. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Lm655hdgDo5xsSLNomgdsy
This commit is contained in:
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
# Stops the broker started by broker-up.sh (matched by its main class, not by a broad pattern).
|
||||
for p in $(ps -eo pid,cmd | grep '[k]afka.Kafka' | awk '{print $1}'); do kill "$p"; done
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Downloads Apache Kafka 4.3.1 (checksum-verified), formats a single-node KRaft cluster and starts it.
|
||||
# Usage: scripts/broker-up.sh [client-port] (default 9092; the controller uses client-port + 1)
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=4.3.1
|
||||
PORT="${1:-9092}"
|
||||
CTRL=$((PORT + 1))
|
||||
HOME_DIR="${KAFKA_DIR:-$(cd "$(dirname "$0")/.." && pwd)/.kafka}"
|
||||
TGZ="kafka_2.13-${VERSION}.tgz"
|
||||
mkdir -p "$HOME_DIR" && cd "$HOME_DIR"
|
||||
|
||||
if [ ! -d "kafka_2.13-${VERSION}" ]; then
|
||||
curl -fsSL -o "$TGZ" "https://downloads.apache.org/kafka/${VERSION}/${TGZ}"
|
||||
curl -fsSL -o "${TGZ}.sha512" "https://downloads.apache.org/kafka/${VERSION}/${TGZ}.sha512"
|
||||
# The .sha512 file is "name: HEX HEX HEX ..." in groups, so compare after stripping spaces and the name.
|
||||
expected="$(sed 's/^[^:]*: *//' "${TGZ}.sha512" | tr -d ' \n' | tr 'A-F' 'a-f')"
|
||||
actual="$(sha512sum "$TGZ" | cut -d' ' -f1)"
|
||||
[ "$expected" = "$actual" ] || { echo "checksum mismatch for $TGZ" >&2; exit 1; }
|
||||
tar -xzf "$TGZ"
|
||||
fi
|
||||
|
||||
cd "kafka_2.13-${VERSION}"
|
||||
sed -i "s#^listeners=.*#listeners=PLAINTEXT://:${PORT},CONTROLLER://:${CTRL}#" config/server.properties
|
||||
sed -i "s#^advertised.listeners=.*#advertised.listeners=PLAINTEXT://localhost:${PORT}#" config/server.properties
|
||||
sed -i "s#^controller.quorum.bootstrap.servers=.*#controller.quorum.bootstrap.servers=localhost:${CTRL}#" config/server.properties
|
||||
sed -i "s#^log.dirs=.*#log.dirs=${HOME_DIR}/data-${PORT}#" config/server.properties
|
||||
|
||||
if [ ! -d "${HOME_DIR}/data-${PORT}" ]; then
|
||||
bin/kafka-storage.sh format --standalone -t "$(bin/kafka-storage.sh random-uuid | tail -1)" -c config/server.properties
|
||||
fi
|
||||
export KAFKA_HEAP_OPTS="${KAFKA_HEAP_OPTS:--Xmx512m -Xms512m}"
|
||||
setsid nohup bin/kafka-server-start.sh config/server.properties > "${HOME_DIR}/broker-${PORT}.log" 2>&1 < /dev/null &
|
||||
|
||||
for _ in $(seq 1 60); do
|
||||
bin/kafka-topics.sh --bootstrap-server "localhost:${PORT}" --list > /dev/null 2>&1 && break
|
||||
sleep 2
|
||||
done
|
||||
echo "broker up on localhost:${PORT}; share.version feature:"
|
||||
bin/kafka-features.sh --bootstrap-server "localhost:${PORT}" describe | grep share.version
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates every file in output/ from the tests. Needs a broker: scripts/broker-up.sh [port], then
|
||||
# pass -Dbroker=localhost:<port> if it is not 9092.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mvn -B -q test "$@"
|
||||
ls -1 output
|
||||
Reference in New Issue
Block a user