Hi, I was reading up on the API of implementing a custom journal plugin in Java. Could you please tell me if I have understood this section correctly.
With regards to the following API: Future<Iterable<Optional<Exception>>> doAsyncWriteMessages(Iterable< AtomicWrite> messages); whose Java docs can be found here: http://doc.akka.io/docs/akka/snapshot/java/persistence.html#Journal_plugin_API <http://doc.akka.io/docs/akka/snapshot/java/persistence.html#Journal_plugin_API> Specifically this line : "If there are failures when storing any of the messages in the batch the returned `Future` must be completed with failure." and this section: "The journal can also signal that it rejects individual messages(`AtomicWrite`) by the returned `Iterable<Optional<Exception>>`. The returned `Iterable` must have as many elements as the input `messages` `Iterable`. Each `Optional` element signals if the corresponding `AtomicWrite` is rejected or not, with an exception describing the problem. Rejecting a message means it was not stored, i.e. it must not be included in a later replay. Rejecting a message is typically done before attempting to store it, e.g. because of serialization error." I had difficulty understanding how it would be possible to reject an individual atomic write when the first line states that the future must be completed with failure if storing a single message fails. Returning the Iterable<Optional<Exception>>> result would imply that the future would have to be completed successfully. If I ended up implementing it in this manner would it be correct? : - Iterate over all messages validating and serializing each one, during this process I would be building an Iterable<Optional<Exception>>> with an Optional.empty for each successfully validated and serialized message and an Optional containing an exception if one of the messages fails validation and serialization. - I would then attempt to persist the successfully serialized batch of messages in a single shot (given it is more optimal to do it in batch for my data store). - If the persist succeed i would complete the future successfully by returning the previously constructed Iterable<Optional<Exception>>> containing possible rejections. - If the persist fails i would simply fail the future with an exception indicating why the persist for the entire set of AtomicWrites failed. We would be loosing information with regards to if any of the AtomicWrites were rejected but I imagine this is somewhat irrelevant since none of them got persisted anyway. Thanks, Ian Grima -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.