#!/bin/bash
-IMAGE=juplo/spring-producer:1.0-SNAPSHOT
+IMAGE=juplo/spring-producer:1.0-fixedsharding-SNAPSHOT
if [ "$1" = "cleanup" ]
then
- kafka-3
producer:
- image: juplo/spring-producer:1.0-SNAPSHOT
+ image: juplo/spring-producer:1.0-fixedsharding-SNAPSHOT
environment:
juplo.bootstrap-server: kafka:9092
juplo.client-id: producer
juplo.producer.topic: test
+ juplo.producer.partition: 0
consumer-1:
image: juplo/simple-consumer:1.0-SNAPSHOT
<artifactId>spring-producer</artifactId>
<name>Spring Producer</name>
<description>A Simple Spring-Boot-Producer, that takes messages via POST and confirms successs</description>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-fixedsharding-SNAPSHOT</version>
<properties>
<java.version>21</java.version>
new ExampleProducer(
properties.getClientId(),
properties.getProducerProperties().getTopic(),
+ properties.getProducerProperties().getPartition(),
properties.getProducerProperties().getThrottle() == null
? Duration.ofMillis(500)
: properties.getProducerProperties().getThrottle(),
@NotEmpty
private String topic;
@NotNull
+ private Integer partition;
+ @NotNull
@NotEmpty
private String acks;
@NotNull
{
private final String id;
private final String topic;
+ private final int partition;
private final Duration throttle;
private final Producer<String, String> producer;
private final Thread workerThread;
public ExampleProducer(
String id,
String topic,
+ int partition,
Duration throttle,
Producer<String, String> producer,
Runnable closeCallback)
{
this.id = id;
this.topic = topic;
+ this.partition = partition;
this.throttle = throttle;
this.producer = producer;
final ProducerRecord<String, String> record = new ProducerRecord<>(
topic, // Topic
+ partition, // Partition
key, // Key
value // Value
);
client-id: DEV
producer:
topic: test
+ partition: 0
acks: -1
delivery-timeout: 10s
max-block: 5s
client-id: ${juplo.client-id}
producer:
topic: ${juplo.producer.topic}
+ partition: ${juplo.producer.partition}
acks: ${juplo.producer.acks}
delivery-timeout: ${juplo.producer.delivery-timeout}
max-block: ${juplo.producer.max-block}