cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How is listener configured to trigger an event in Hybris?

Former Member
0 Likes
4,762

Hi ,

I am trying to understand how a listener will find when an event is triggered by "eventService.publichEvent()" ??

Thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member624549
Participant
0 Likes

hybris is using spring events under the hood. You can just as well use the spring mechanism directly. In addition to what spring provides hybris offers the possibility to send an event to other nodes in the cluster.

andyfletcher
Active Contributor
0 Likes

The Hybris EventService is just a wrapper around Spring Application Events.

If you follow the calls down through org.springframework.context.support.AbstractApplicationContext.publishEvent to org.springframework.context.event.AbstractApplicationEventMulticaster you can see how it loops over registered listeners to find ones that support the type you are looking for and then invokes the listeners returned. Internally the lookup is cached so that it doesn't need to look through the entire list of registered listeners each time.

https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/spr... https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/spr... https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/spr...

Former Member
0 Likes

Hi

Listeners are the objects that are notified of events and perform business logic depending on the event that occured. Listeners are registered with the event service.

Whenever you register an event listener, the event system will scan the application context and automatically register all event listeners.

For more details, please check the below link: https://wiki.hybris.com/display/release5/Event+System#EventSystem-RegisteringEventListeners

Former Member
0 Likes

HI Sorav,

Thank you for the response. I am new to Hybris so i am bit struggling to understand how listener knows which kind of event it is and how it needs to be processed.

For example, Consider user places and order and order Model is save. Now i would like to send a notification to user via email with the order details.

To achieve this there must be a listener associated with the Order model ? is this how it works? and how do i implement the listener to make it associated with the Order and triggers a email process?

Many thanks in advance.