akka-persistence

Update actor state only after all events are persisted

﹥>﹥吖頭↗ 提交于 2021-02-07 08:55:43
问题 In the receive method of a persistent actor, I receive a bunch a events I want to persist, and only after all events are persisted, update again my state. How can I do that? def receive: Receive = { ... case NewEvents(events) => persist(events) { singleEvent => // Update state using this single event } // After every events are persisted, do one more thing } Note that the persist() call is not blocking so I cannot put my code just after that. Update: Why I need this These new events come from

Update actor state only after all events are persisted

爷,独闯天下 提交于 2021-02-07 08:53:46
问题 In the receive method of a persistent actor, I receive a bunch a events I want to persist, and only after all events are persisted, update again my state. How can I do that? def receive: Receive = { ... case NewEvents(events) => persist(events) { singleEvent => // Update state using this single event } // After every events are persisted, do one more thing } Note that the persist() call is not blocking so I cannot put my code just after that. Update: Why I need this These new events come from

Update actor state only after all events are persisted

我们两清 提交于 2021-02-07 08:53:42
问题 In the receive method of a persistent actor, I receive a bunch a events I want to persist, and only after all events are persisted, update again my state. How can I do that? def receive: Receive = { ... case NewEvents(events) => persist(events) { singleEvent => // Update state using this single event } // After every events are persisted, do one more thing } Note that the persist() call is not blocking so I cannot put my code just after that. Update: Why I need this These new events come from

How to increase default timeout for ScalaTestWithActorTestKit

时光总嘲笑我的痴心妄想 提交于 2021-01-07 02:42:20
问题 I have a test which constructs another event sourcing actor from inside message handler and this construction is taking more than 3 seconds. Below is current configuration, how can I increase default timeout? extends ScalaTestWithActorTestKit( ConfigFactory.parseString(""" akka.persistence.testkit.events.serialize = off akka.actor.allow-java-serialization = on akka.test.single-expect-default = 999s """).withFallback(PersistenceTestKitPlugin.config).withFallback(ManualTime.config) Here is the

How to increase default timeout for ScalaTestWithActorTestKit

柔情痞子 提交于 2021-01-07 02:41:11
问题 I have a test which constructs another event sourcing actor from inside message handler and this construction is taking more than 3 seconds. Below is current configuration, how can I increase default timeout? extends ScalaTestWithActorTestKit( ConfigFactory.parseString(""" akka.persistence.testkit.events.serialize = off akka.actor.allow-java-serialization = on akka.test.single-expect-default = 999s """).withFallback(PersistenceTestKitPlugin.config).withFallback(ManualTime.config) Here is the

Working with custom mailboxes and persistent actors with AtLeastOnceDelivery

天大地大妈咪最大 提交于 2019-12-24 15:14:42
问题 Questions How do you get the and log messages in the receiveCommand of a persistent actor with AtLeastOnceDelivery inside a custom mailbox enqueue and dequeue? How do you get the name of the persistent actor inside your custom mailbox enqueue and dequeue? I have a custom mailbox with the following MessageQueue: The issue is that messages received by a persistent actor in the receiveCommand are not logged at all in the dequeue or in the enqueue. Only the persisting is logged. Additionally, the

Can't connect to cassandra container via haproxy

对着背影说爱祢 提交于 2019-12-23 02:43:04
问题 I am trying to connect an external app to Cassandra which is running dockerized on a mesos cluster. These are the the apps I have running on mesos: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 137760ce852a cassandra:latest "/docker-entrypoint.s" 15 minutes ago Up 15 minutes 7000-7001/tcp, 7199/tcp, 9160/tcp, 0.0.0.0:31634->9042/tcp mesos-1b65f33a-3d36-4bf4-8a77-32077d8d234a-S1.0db174cc-2e0c-4790-9cd7-1f142d08c6e2 fec5fc93ccfd cassandra:latest "/docker-entrypoint.s" 22 minutes ago Up

How to serialize functions in Scala?

女生的网名这么多〃 提交于 2019-12-22 00:16:59
问题 I'm cutting my teeth on akka-persistence and came upon the quintessential problem of object serialization. My objects (shown below) have basic types, and functions. I read this, this and this, but none has helped me in making the following serializable. Test Util object SerializationUtil { def write(obj: Any): String = { val temp = Files.createTempFile(null, null).toFile val out = new ObjectOutputStream(new FileOutputStream(temp)) out.writeObject(obj) out.close() temp.deleteOnExit() temp

Akka persistence testing approaches

。_饼干妹妹 提交于 2019-12-13 02:06:56
问题 I am familiar with the Akka testing approaches defined here: http://doc.akka.io/docs/akka/snapshot/scala/testing.html I understand how to use TestKit, TestActorRef, TestProbe etc. I also understand that my core domain logic should be extracted and tested in isolation from Akka. My question is about strategies for doing TDD on Akka Persistence actors i.e. PersistentActor and PersistentView. I want to be able to test the following types of scenarios in a reasonably low overhead, efficient

Can't connect to cassandra container via haproxy

不羁岁月 提交于 2019-12-08 19:43:33
I am trying to connect an external app to Cassandra which is running dockerized on a mesos cluster. These are the the apps I have running on mesos: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 137760ce852a cassandra:latest "/docker-entrypoint.s" 15 minutes ago Up 15 minutes 7000-7001/tcp, 7199/tcp, 9160/tcp, 0.0.0.0:31634->9042/tcp mesos-1b65f33a-3d36-4bf4-8a77-32077d8d234a-S1.0db174cc-2e0c-4790-9cd7-1f142d08c6e2 fec5fc93ccfd cassandra:latest "/docker-entrypoint.s" 22 minutes ago Up 22 minutes 7000-7001/tcp, 7199/tcp, 9160/tcp, 0.0.0.0:31551->9042/tcp mesos-1b65f33a-3d36-4bf4-8a77