Package io.meeds.deeds.service
Class ListenerService
java.lang.Object
io.meeds.deeds.service.ListenerService
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Component
public class ListenerService
extends Object
implements org.springframework.context.ApplicationContextAware
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(EventListener<?> listener) Add manually a listener for a dedicated event.voidAn INTERNAL method that is used to be triggered periodically through the Scheduled TaskListenerEventCleanupTask.protected voiddestroy()protected Map<String,List<EventListener<?>>> protected voidinit()voidpublishEvent(String eventName, Object data) Triggers an event locally and remotely using persistent event listening based on a dedicated Elasticsearch index to persist the event and generates a unique identifier for it.voidremoveListsner(String listenerName) Removes allEventListenerthat haveEventListener.getName()the designated name in paramvoidremoveListsner(String eventName, String listenerName) Removes allEventListenerthat haveEventListener.getName()the designated name in param and aEventListener.getSupportedEvents()as designated in param namevoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidAn INTERNAL method that is used to be triggered periodically through the Scheduled TaskListenerEventTriggerTask.
-
Field Details
-
ES_LAST_SCANNED_DATE_SETTING_NAME
- See Also:
-
LOG
public static final org.slf4j.Logger LOG -
subscriptionConnection
-
publicationConnection
-
-
Constructor Details
-
ListenerService
public ListenerService()
-
-
Method Details
-
publishEvent
Triggers an event locally and remotely using persistent event listening based on a dedicated Elasticsearch index to persist the event and generates a unique identifier for it. This event id will be published on Redis as well in order to instantly inform all consumers that a new event has been published in Elasticsearch. If redis is down or out of service, a Scheduled JobListenerEventTriggerTaskon each consumer will retrieve events periodically.- Parameters:
eventName- Event Name as configured for listeners inEventListener.getSupportedEvents()data- Data Object to pass to listeners when executingEventListener.onEvent(String, Object)
-
addListener
Add manually a listener for a dedicated event. This method is useless in general case since the listeners are added automatically when defined as any regular Spring BeanComponentand that it inherits fromEventListener- Parameters:
listener- localEventListener
-
removeListsner
Removes allEventListenerthat haveEventListener.getName()the designated name in param- Parameters:
listenerName- name of listeners to remove
-
removeListsner
Removes allEventListenerthat haveEventListener.getName()the designated name in param and aEventListener.getSupportedEvents()as designated in param name- Parameters:
eventName-EventListener.getSupportedEvents()event namelistenerName-EventListener.getName()name
-
triggerElasticSearchEvents
public void triggerElasticSearchEvents()An INTERNAL method that is used to be triggered periodically through the Scheduled TaskListenerEventTriggerTask. In general case, this must not be used outside this provided Task. -
cleanupElasticsearchEvents
public void cleanupElasticsearchEvents()An INTERNAL method that is used to be triggered periodically through the Scheduled TaskListenerEventCleanupTask. In general case, this must not be used outside this provided Scheduled Task. This cleanup will be triggered on one single instance which has made a configuration of its periodicity, which is by default, the dApp only. -
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
init
@PostConstruct protected void init() -
destroy
@PreDestroy protected void destroy() -
getListeners
-