Axon Framework Message Dispatch Interceptor

81 views
Skip to first unread message

Giorgos Ginis

unread,
Jul 3, 2020, 8:05:47 PM7/3/20
to Axon Framework Users
Dear Axon Team,

I downloaded one of your demos after looking at your documentation for a POC for one of the projects I am currently working on, in order to use event sourcing and Axon/CQRS. 

As far as I understand the cross cutting concerns in an Axon/CQRS Application are handled via the use of Message Dispatch Interceptors.

What I am trying to figure out is how to register multiple interceptors that are part of different microservices at a specific order. 

Driven from one of your examples, image a situation where for the 'AxonBank' example we added one microservice lets call it 'A' that was responsible for checking if a user had the authority to perform the withdraw action, and is in general responsible for proving authorization of users' actions.
Another microservice lets call it 'B' that was responsible for checking that the withdraw amount is not over a certain limit set by 'AxonBank' and in general in control of any limits set by the 'AxonBank' on any transactions

In that situation the configuration demanded that the user should 1st be checked if he/she can perform the action before checking if the amount is over the limit.

How would we setup the application to register interceptor from microservice 'A' before the interceptor from microservice 'B'.

Thank you in advance for your help.

George Ginis  

Giorgos Ginis

unread,
Aug 12, 2020, 1:26:48 PM8/12/20
to Axon Framework Users
I just thought I would post a kind reminder for this question. 
Any information will be greatly appreciated.

Thank you in advance.

George Ginis

Ben Runchey

unread,
Aug 12, 2020, 4:26:48 PM8/12/20
to Axon Framework Users
I am thinking that the order you register them in when building the CommandGateway is the order they are applied.  That is how it is working for us.

Giorgos Ginis

unread,
Aug 13, 2020, 11:35:12 AM8/13/20
to axonfr...@googlegroups.com
Yes this works fine if all interceptors are registered in one module only. If you deploy separate services that each play its part in the interceptor chain then I am not sure how you guarantee the order. 
That is the case I was wondering how solve 

On Wed, 12 Aug 2020, 23:26 Ben Runchey, <ben.r...@gmail.com> wrote:
I am thinking that the order you register them in when building the CommandGateway is the order they are applied.  That is how it is working for us.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/axonframework/2c5de13f-f4e8-4365-88e9-686df039d1f6o%40googlegroups.com.

Steven van Beelen

unread,
Sep 16, 2020, 7:11:24 AM9/16/20
to Axon Framework Users
Hi Giorgos,

The registration of interceptors is as Ben Runchey puts it: the order in which the register method is called or the ordering within the list provided during building of a messaging component is leading in which interceptor goes first.
Having a microservice which is the interceptor to me only makes sense if it is a service called by an interceptor.
So they are not really the same thing, but separate from another.
Doing see means you can simply register the interceptors in the desired order to the component handling or dispatching methods.
Then, a separate microservice A can be in charge of doing the authorization, through it's own API, invoked by the interceptor on microservice B.

Trusting this guidance will help you further Giorgos!

Cheers,
Steven

PS. It is important to note that this mailing list will be discontinued as specified in this thread.
Instead of this mailing list we have moved to use a forum style of communication, at https://discuss.axoniq.io/.
Hope to see you there!

Giorgos Ginis

unread,
Sep 16, 2020, 10:44:31 AM9/16/20
to axonfr...@googlegroups.com
Hi Steven,

Thank you very much for your input. I believe I understand what you mean. 
I believe I can have 'common service-to-service clients' if need to be reused by any microservice, and each one can register its own interceptor(s) and use them to perform any needed checks before/after the dispatching.

Please confirm that I understood correctly.

Thank you in advance

George 

  

Steven van Beelen

unread,
Sep 16, 2020, 10:49:03 AM9/16/20
to Axon Framework Users
Hi Giorgos,

That's indeed the direction I was trying to explain, happy to hear I did a fair job there!
So, in short: confirmed. ;-)

Cheers,
Steven

Reply all
Reply to author
Forward
0 new messages