replay on the AbstractAnnotatedAggregateRoot does not seem to work

129 views
Skip to first unread message

Olger Warnier

unread,
Oct 11, 2014, 4:48:36 PM10/11/14
to axonfr...@googlegroups.com
Hi List, 

I've been using axon for quite a while now in a setup with scala and scynapse - some code to glue scala and axon together in a  friendly way. 
This setup uses 2 replay clusters that update the views and a cluster that does not replay (for sending mails and stuff)
The default cluster (  <axon:cluster id="default" default="true"/> ) has no additional replay config. 

As far as I am aware, this setup used to replay events on the Aggregate Root. Somehow, the @EventHandler isn't called anymore. 
Did someone see this behaviour before - or - has a hint in what direction I may look for a solution ?

Kind regards, 
Olger

bui...@gmail.com

unread,
Oct 12, 2014, 2:57:53 PM10/12/14
to axonfr...@googlegroups.com
Hi,

aggregates aren't (re)constructed through a Cluster. An Aggregate's event handlers are only invoked when it is loaded from the event store.
Only beans that don't implement EventListener or AggregateRoot are automatically subscribed to an Event Bus. If you implement EventListener, you must subscribe it yourself. Subscribing an Aggregate to an EventBus wouldn't make much sense, as aggregates should only react to commands (and their own events, if they're event sourced). 

Cheers,

Allard

Cheers,

Allard
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Olger Warnier

unread,
Oct 12, 2014, 3:01:08 PM10/12/14
to axonfr...@googlegroups.com, axonfr...@googlegroups.com
Hi Allard,

Intresting as it seems that my aggregate root is not reacting on its own events during a replay (it is when it is handling commands in a normal way)

 What are the options to check what is going on ?

Kind regards,

Olger



--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/Xp_6SygKOxk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframewor...@googlegroups.com.

bui...@gmail.com

unread,
Oct 12, 2014, 3:05:48 PM10/12/14
to axonfr...@googlegroups.com
What do you mean with 'the replay'? Are you replaying on a cluster?

Olger Warnier

unread,
Oct 12, 2014, 3:17:55 PM10/12/14
to axonfr...@googlegroups.com, axonfr...@googlegroups.com
Hi Allard, 

Let's see if I am able to explain this without getting into definition problems.

When my app is started, all events are replayed based on this configuration:

   <axon:cluster id="default" default="true"/>

    <axon:cluster id="identityCluster" order="0">
      <axon:replay-config event-store="eventStore" />
      <axon:selectors>
        <axon:package prefix="com.giffdiff.identity.view"/>
      </axon:selectors>
    </axon:cluster>

    <axon:cluster id="projectCluster" order="0">
        <axon:replay-config event-store="eventStore" />
        <axon:selectors>
            <axon:package prefix="com.giffdiff.project.view"/>
        </axon:selectors>
    </axon:cluster>

    <!-- Clusters with no replay -->

    <axon:cluster id="invitationMailerCluster" order="0">
        <!-- do not replay, thus no config -->
        <axon:selectors>
            <axon:package prefix="com.giffdiff.identity.usercommunication"/>
            <axon:package prefix="com.giffdiff.project.usercommunication"/>
        </axon:selectors>
    </axon:cluster>

This works fine for the views (found in the *.view sub packages) 

The events are not re-send to the AggregateRoot instance though, this instance contains some event handling like: (Aggregate is named UserAccount)

  @EventHandler
  def on(e : AccountCreated) {
   log.debug(“called “ + e)
    id = e.accountId
    email = e.email
    fullName = e.name
    bcryptedPassword = e.password
  }

that expects the id, email, fullName and password to be kept with the state of the specific instance of this aggregate. 

Now, after startup, it seems that these events were not called and the internal state of the aggregate is not as it should be. 

Till now, my assumptions comes from the debug log message that is shown when you have the application in normal running mode and a command fires an AccountCreated event (CreateAccount command), the log message is shown. 
When you re-start the application (Event stored via JPA in mysql, JVM process gone and created again), the log message is not shown. 

Does this help to explain the issue ?

Kind regards, 

Olger





On Sun, Oct 12, 2014 at 8:57 PM, bui...@gmail.com <bui...@gmail.com> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/Xp_6SygKOxk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframewor...@googlegroups.com.

bui...@gmail.com

unread,
Oct 12, 2014, 3:25:57 PM10/12/14
to axonfr...@googlegroups.com
That's because aggregates aren't reconstructed by replaying a cluster. Aggregate state is constructed when it is loaded from the repository. And that happens when a command is sent that targets it. 

Olger Warnier

unread,
Oct 12, 2014, 3:30:00 PM10/12/14
to axonfr...@googlegroups.com, axonfr...@googlegroups.com
Ah, clear. Thanks for your explanation. Must say that it makes me wonder how snaphots work


Reply all
Reply to author
Forward
0 new messages