FoodCart | This project was generated with Angular CLI version | Generator Utils library
kandi X-RAY | FoodCart Summary
kandi X-RAY | FoodCart Summary
This project was generated with Angular CLI version 9.1.2.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of FoodCart
FoodCart Key Features
FoodCart Examples and Code Snippets
Community Discussions
Trending Discussions on FoodCart
QUESTION
I'm writing my first Axon tutorials, and I'd like to provide Logger
as a bean, so I can easily mock/spy it:
ANSWER
Answered 2020-May-28 at 07:57Answer
The reason for that is likely how the SpringBeanParameterResolverFactory
and it's SpringBeanParameterResolver
are used to retrieve Spring beans to inject in message handling functions.
At the moment a message handling function like your @CommandHandler public void handle(DeselectProductCommand ...)
is called. The SpringBeanParameterResolver#resolveParameterValue
method will be called, which in turn calls the AutowireCapableBeanFactory#getBean(String)
. As you might have noticed there, it doesn't use any notion of an InjectionPoint
.
Implementing this wouldn't be hard I believe. The AutowireCapableBeanFactory#resolveDependency(DependencyDescriptor, String)
method would be sufficient at a quick glance (DependencyDescriptor
is an implementation of InjectionPoint
). Might be worth providing an issue on Axon's GitHub for this, or even better, a PR.
Suggestions
However, I do have another suggestion to achieve the same non-functional requirement of logging without injecting it in every message handling function. To achieve this form of logging in an Axon application, you can go two ways:
- Use
MessageHandlerInterceptor
s andMessageDispatchInterceptor
s which log upon ingestion and handling of any message. Quick solution would be to use Axon'sLoggingInterceptor
for this, which implements both interfaces. From there, you would register it to every message dispatching and handling component (thus theCommandBus
,EventBus
, allEventProcessor
s and theQueryBus
). - Provide a
HandlerEnhancerDefintion
which wraps every message handling function with your logging logic. Providing a Bean for this should be sufficient for Axon to pick it up and automatically wrap all@MessageHandler
annotated methods.
Doing either of these means you are not obstructing the logic of handling commands, events and queries, with the rather dull logic of logging.
That's my two cents, hope it helps Andre!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install FoodCart
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page