This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bin/kafka-console-producer --broker-list localhost:9092 --topic blogpost | |
{"title":"The Matrix","year":1999,"cast":["Keanu Reeves","Laurence Fishburne","Carrie-Anne Moss","Hugo Weaving","Joe Pantoliano"],"genres":["Science Fiction"]} | |
{"title":"Die Hard","year":1988,"cast":["Bruce Willis","Alan Rickman","Bonnie Bedelia","William Atherton","Paul Gleason","Reginald VelJohnson","Alexander Godunov"],"genres":["Action"]} | |
{"title":"Toy Story","year":1995,"cast":["Tim Allen","Tom Hanks","(voices)"],"genres":["Animated"]} | |
{"title":"Jurassic Park","year":1993,"cast":["Sam Neill","Laura Dern","Jeff Goldblum","Richard Attenborough"],"genres":["Adventure"]} | |
{"title":"The Lord of the Rings: The Fellowship of the Ring","year":2001,"cast":["Elijah Wood","Ian McKellen","Liv Tyler","Sean Astin","Viggo Mortensen","Orlando Bloom","Sean Bean","Hugo Weaving","Ian Holm"],"genres":["Fantasy"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
zookeeper: | |
image: debezium/zookeeper:0.8 | |
ports: | |
- 2181:2181 | |
- 2888:2888 | |
- 3888:3888 | |
kafka: | |
image: debezium/kafka:0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"before": { | |
"dbserver1.outbox_demo.outbox_event.Value": { | |
"id": "6c810398-4b25-42ca-b18a-7428e16fefae", | |
"aggregate_id": "1", | |
"aggregate_type": "com.github.hpgrahsl.ms.outbox.sample.model.PurchaseOrder", | |
"payload": "{\"id\":1,\"customerId\":1234,\"orderDate\":\"2019-07-19T10:50:15.528\",\"lineItems\":[{\"id\":1,\"item\":\"ABC\",\"quantity\":12,\"totalPrice\":49.25,\"status\":\"ENTERED\"},{\"id\":2,\"item\":\"XYZ\",\"quantity\":98,\"totalPrice\":99.25,\"status\":\"ENTERED\"}],\"totalValue\":148.5}", | |
"timestamp": 1563526215, | |
"type": "com.github.hpgrahsl.ms.outbox.sample.event.OrderUpsertedEvent" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"before": null, | |
"after": { | |
"dbserver1.outbox_demo.outbox_event.Value": { | |
"id": "6c810398-4b25-42ca-b18a-7428e16fefae", | |
"aggregate_id": "1", | |
"aggregate_type": "com.github.hpgrahsl.ms.outbox.sample.model.PurchaseOrder", | |
"payload": "{\"id\":1,\"customerId\":1234,\"orderDate\":\"2019-07-19T10:50:15.528\",\"lineItems\":[{\"id\":1,\"item\":\"ABC\",\"quantity\":12,\"totalPrice\":49.25,\"status\":\"ENTERED\"},{\"id\":2,\"item\":\"XYZ\",\"quantity\":98,\"totalPrice\":99.25,\"status\":\"ENTERED\"}],\"totalValue\":148.5}", | |
"timestamp": 1563526215, | |
"type": "com.github.hpgrahsl.ms.outbox.sample.event.OrderUpsertedEvent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mdb-sink-outbox-raw", | |
"config": { | |
"key.converter":"io.confluent.connect.avro.AvroConverter", | |
"key.converter.schema.registry.url":"http://localhost:8081", | |
"value.converter":"io.confluent.connect.avro.AvroConverter", | |
"value.converter.schema.registry.url":"http://localhost:8081", | |
"connector.class": "at.grahsl.kafka.connect.mongodb.MongoDbSinkConnector", | |
"topics": "dbserver1.outbox-demo.outbox_event", | |
"mongodb.connection.uri": "mongodb://localhost:27017/outboxed", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/kafka-avro-console-consumer --bootstrap-server localhost:9092 --topic dbserver1.outbox-demo.outbox_event --from-beginning | jq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mysql-outbox-src-connector-01", | |
"config": { | |
"connector.class": "io.debezium.connector.mysql.MySqlConnector", | |
"tasks.max": "1", | |
"database.hostname": "localhost", | |
"database.port": "3306", | |
"database.user": "debezium", | |
"database.password": "dbz", | |
"database.server.id": "12345", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class OrderService { | |
//... | |
@Transactional | |
public PurchaseOrder updateOrderLineStatus(long orderId, long orderLineId, OrderLineStatus newStatus) { | |
PurchaseOrder po = repository.findById(orderId) | |
.orElseThrow(() -> new EntityNotFoundException("order with id " + orderId + " doesn't exist!")); | |
OrderLineStatus oldStatus = po.updateOrderLine(orderLineId, newStatus); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class OrderService { | |
//... | |
@Transactional | |
public PurchaseOrder placeOrder(PurchaseOrder order) { | |
repository.save(order); //NOTE: OrderUpsertedEvent automatically published behind the scenes | |
return order; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderUpsertedEvent implements Outboxable { | |
private static ObjectMapper MAPPER = new ObjectMapper(); | |
private final Long id; | |
private final JsonNode payload; | |
private final Long timestamp; | |
static { | |
MAPPER.registerModule(new JavaTimeModule()); |
NewerOlder