Hi Allard,
Thanks for the explanations, please read in-line:
> the trick is to use a synchronous dispatching mechanism to a
> messaging system, ...
Yes that would work, This is what I called synchronous
message distribution in my post. The best example of
this approach is the excellent Axon Auction sample provided
by Michael. He is using JMS as the protocol and ActiveMQ
as the messaging broker. This approach is the (only) way
to go when the application is big and distributed among
many computers and/or processes.
But, there are many cases where having asynchronous local
event distribution is a must within a single process
(even in a process which is a part of a distributed application).
Examples are when a long task such as a CPU-heavy task
or i-o heavy task such as sending email is part of the
transaction.
In these situations,
to make the response time shorter, using a lightweight GoF
observer-pattern type of message distributor is much better
because a heavyweight message-broker brings with it
a lot of unnecessary complexities and expenses for
additional CPU and memory and management they require.
Which goes against the lean and mean nature of Axon.
In addition, in the case of RabbitMQ it definitely requires
2PC using Spring Transaction or similar (I'm aware of some
tricks which in some case can optimize away the 2PC in
this case but not without introducing extra complexities
in the application itself)
In the case of ActiveMQ, because it can use the same
JDBC-based SQL engine used by the event-store, it is
possible to use a local common transaction. But ActiveMQ
is a CPU-hungry memory-monster which needs a lot of
nurturing to survive.
What I wished was to enhance the currently existing
asynchronous subsystem of Axon to make it transactional,
by switching the currently memory-based que with a
disk-based que. This would provide Axon applications
with a lightweight local observer pattern class of message
distribution out of the box.
Off course it is always possible to have a heavy-weight
message-broker as one of the local asynchronous event
listeners for distributing the events over and beyond the
current process while local CPU- and IO-heavy
event-listeners can also benefit from less network latency
and no reliance on exogenous message brokers at the
same time.
Best wishes,
Esfand