On Tue, Oct 11, 2016 at 11:24 AM, Ian Grima <iangr...@gmail.com> wrote:
> I am still looking for an opinion on this matter if anyone could help :)
> On Saturday, 8 October 2016 15:31:32 UTC+2, Ian Grima wrote:
>> 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/
>> Specifically this line : "If there are failures when storing any of the
>> messages in the batch the returned `Future` must be completed with
>> 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
>> 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.
Rejections are not failure to store them, but it can be seen as a
validation error, i.e. something that is performed before the database is
involved, e.g. serialization error.
> 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>>>
>> 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.
That looks correct.
You can also consider to not support rejections at all. It's an optional
feature, and many of the existing implementations doesn't support it.
Rejections will result in gaps in the sequence numbers. Gapless sequence
numbers is a very nice feature, much more important than rejections in my
>> Ian Grima
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/
> >>>>>>>>>> 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 firstname.lastname@example.org.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
Akka Tech Lead
Lightbend <http://www.lightbend.com/> - Reactive apps on the JVM
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> 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 post to this group, send email to email@example.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.