Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- broker
- ${BACKEND}
environment:
E2E_APP_MODE: REGRESSION_BATCH
E2E_APP_MODE: REGRESSION_ST_JOIN
CONFIG_PATH: "/app.properties"
JAVA_OPTS: "-Dlog4j2.configurationFile=/log4j2.properties"
volumes:
Expand All @@ -28,7 +28,7 @@ services:
- broker
- ${BACKEND}
environment:
E2E_APP_MODE: REGRESSION_BATCH_BASELINE
E2E_APP_MODE: REGRESSION_ST_BASELINE
CONFIG_PATH: "/app.properties"
JAVA_OPTS: "-Dlog4j2.configurationFile=/log4j2.properties"
volumes:
Expand All @@ -46,7 +46,7 @@ services:
- broker
- ${BACKEND}
environment:
E2E_APP_MODE: REGRESSION_BATCH_DRIVER
E2E_APP_MODE: REGRESSION_ST_DRIVER
CONFIG_PATH: "/app.properties"
JAVA_OPTS: "-Dlog4j2.configurationFile=/log4j2.properties"
volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ public int compareTo(final EnrichedOrder o) {
.thenComparing(r -> customer.customerName())
.compare(this, o);
}

public EnrichedOrder combineWith(final EnrichedOrder other) {
final double totalAmount = order.amount() + other.order.amount();
return new EnrichedOrder(
new Order(order().orderId(), order.customerId(), totalAmount),
customer
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import dev.responsive.examples.regression.model.Customer;
import dev.responsive.examples.regression.model.EnrichedOrder;
import dev.responsive.examples.regression.model.Order;
import java.time.Duration;
import java.util.Map;
import org.apache.kafka.common.serialization.Serdes;
import org.apache.kafka.streams.StreamsBuilder;
Expand All @@ -35,6 +36,7 @@
import org.apache.kafka.streams.kstream.KStream;
import org.apache.kafka.streams.kstream.KTable;
import org.apache.kafka.streams.kstream.Produced;
import org.apache.kafka.streams.kstream.TimeWindows;

public class STJoinExample extends AbstractKSExampleService {

Expand All @@ -59,6 +61,7 @@ protected Topology buildTopology() {
final KStream<String, Order> orders =
builder.stream(ORDERS, Consumed.with(Serdes.String(), RegressionSchema.orderSerde()));


// Read customers from the customers topic
final KTable<String, Customer> customers =
builder.table(CUSTOMERS, Consumed.with(Serdes.String(), RegressionSchema.customerSerde()));
Expand Down Expand Up @@ -86,6 +89,11 @@ protected Topology buildTopology() {
}
}
})
.groupByKey()
.windowedBy(TimeWindows.ofSizeAndGrace(Duration.ofDays(1), Duration.ofHours(12)))
.reduce(EnrichedOrder::combineWith)
.toStream()
.selectKey((w, v) -> w.key())
.to(
resultsTopic(),
Produced.with(Serdes.String(), RegressionSchema.enrichedOrderSerde())
Expand Down
Loading