- Start Nats with Jetstream enabled
docker-compose up- Start application
iex -S mix- Create a bucket and start a jetstream replication
alias ActorNatsPoc.Statestore.KV, as: StatestoreKV
StatestoreKV.create_replication_bucket("test", "actors.mike")- Start Projection
opts = [name: "test", stream_name: "newtest", subjects: ["actors.*"], consumer_name: "projectionviewertest"]ActorNatsPoc.Projection.start_link(opts)- Put new key value into bucket
StatestoreKV.put("test", "mykey", "myvalue")- See the follow consumer logs in the iex console
Processing message: %Broadway.Message{data: "{\"action\":\"key_added\",\"key\":\"mykey\",\"value\":\"myvalue\"}", metadata: %{headers: [], topic: "actors.mike"}, acknowledger: {OffBroadway.Jetstream.Acknowledger, #Reference<0.4061493138.1171259399.101594>, %{reply_to: "$JS.ACK.newtest.projectionviewertest.1.161067.161063.1725488338796149600.5"}}, batcher: :default, batch_key: :default, batch_mode: :bulk, status: :ok}- To replay events do:
ActorNatsPoc.Projection.replay([])