Closed VaughnVernon closed 5 years ago
The default adapter is working. See the following test that uses Entity2
, which does not have a specific StateAdapter
registered.
Also note that although the StateAdapter
can now be defaulted (assuming that the state is of type TextState
) you must still register the store name:
But that now works just with the InMemoryStateStore
or does this work for other TextState
based stores too?
It should work for all. Can you please try it and let me know your results?
I've tested it with the PostgresJournalActor
and it does not work. If I skip registration of all Info
types containing the Adapters
the I'm getting a NPE from the lattice module:
vlingo/actors: DefaultSupervisorOverride: Failure of: Address[id=15, name=(none)]
vlingo/actors: java.lang.NullPointerException
at io.vlingo.lattice.model.sourcing.Sourced.restore(Sourced.java:353)
at io.vlingo.lattice.model.sourcing.Sourced.start(Sourced.java:78)
at io.vlingo.actors.LifeCycle.lambda$sendStart$0(LifeCycle.java:110)
at io.vlingo.actors.LocalMessage.internalDeliver(LocalMessage.java:116)
at io.vlingo.actors.LocalMessage.deliver(LocalMessage.java:49)
at io.vlingo.actors.plugin.mailbox.concurrentqueue.ConcurrentQueueMailbox.run(ConcurrentQueueMailbox.java:96)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
When I register an Info
for my test aggregate without any Adapter
I'm getting this Exception:
at io.vlingo.lattice.model.sourcing.Sourced.lambda$appendAllResultedIn$3(Sourced.java:307)
at io.vlingo.common.Failure.otherwise(Failure.java:45)
at io.vlingo.lattice.model.sourcing.Sourced.appendAllResultedIn(Sourced.java:303)
at io.vlingo.symbio.store.journal.JournalAppendResultInterest__Proxy.lambda$appendAllResultedIn$1(JournalAppendResultInterest__Proxy.java:40)
at io.vlingo.actors.LocalMessage.internalDeliver(LocalMessage.java:116)
at io.vlingo.actors.LocalMessage.deliver(LocalMessage.java:49)
at io.vlingo.actors.ResumingMailbox.run(ResumingMailbox.java:19)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: io.vlingo.symbio.store.StorageException: Adapter not registrered for: de.test.TestCreated
at io.vlingo.symbio.store.journal.jdbc.postgres.PostgresJournalActor.appendAllResultedInFailure(PostgresJournalActor.java:299)
at io.vlingo.symbio.store.journal.jdbc.postgres.PostgresJournalActor.lambda$appendAllWith$5(PostgresJournalActor.java:128)
at io.vlingo.symbio.store.journal.jdbc.postgres.PostgresJournalActor.asEntry(PostgresJournalActor.java:175)
at io.vlingo.symbio.store.journal.jdbc.postgres.PostgresJournalActor.asEntries(PostgresJournalActor.java:163)
at io.vlingo.symbio.store.journal.jdbc.postgres.PostgresJournalActor.appendAllWith(PostgresJournalActor.java:129)
at io.vlingo.symbio.store.journal.Journal__Proxy.lambda$appendAllWith$2(Journal__Proxy.java:57)
at io.vlingo.actors.LocalMessage.internalDeliver(LocalMessage.java:116)
at io.vlingo.actors.LocalMessage.deliver(LocalMessage.java:49)
at io.vlingo.actors.plugin.mailbox.concurrentqueue.ConcurrentQueueMailbox.run(ConcurrentQueueMailbox.java:96)
... 3 more
Caused by: java.lang.IllegalStateException: Adapter not registrered for: de.test.TestCreated
at io.vlingo.symbio.store.journal.jdbc.postgres.PostgresJournalActor.adapter(PostgresJournalActor.java:157)
at io.vlingo.symbio.store.journal.jdbc.postgres.PostgresJournalActor.asEntry(PostgresJournalActor.java:171)
... 9 more
I will add a StateStore
version to my test but for a Journal it does seem work. But I assume that the changes you made are not intended to work with a Journal
@RoadRunner120485 Sorry, my fault. This has been fixed/implemented in the PostgresJournalActor
.
git pull
and build, or get the latest binaries from Bintray; these are considered snapshots.
@VaughnVernon it is working now. I just need to register an empty Info
in the SourceTypeRegistry
but then it works without providing any custom Adapter
. I like the AdapterProvider
s as they allow to mix up custom and default adapter implementations.
@RoadRunner120485 Great, I am glad it works and that you like how it works! The SourceTypeRegistry
is necessary to tell the Sourced
entity which Journal
it uses even if you don't register any adapters.
Is it ok to close this issue?
Closing as fixed.
Adapters do more than just serialize and deserialize, but at the beginning in most cases you don't need these extra functions as your events have version 1 and upcasting, etc., is not necessary. Therefore, you could have a factory that could be either overridden to create customized Adapters or the factory just comes into play if no custom adapter has been registered.