cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing Listener for DataHub Events in Hybris

Former Member
0 Kudos

Hi Experts,

Requirement: Trigger a notification once all the products are loaded in hybris through datahub i.e all publications are completed. I am trying to use PublicationCompletedEvent and write a listener for it to achieve the task. Can someone please provide me better clarity as how we can achieve this functionality and trigger a mail from hybris itself?

Thanks in advance!

Regards Rahul

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

I have written my event listener PublicationCompletedEventListener for PublicationCompletedEvent but unfortunately I am not able to invoke the Listener method handleEvent. I have added the bean and class in the spring.xml already.

Listener:

public class PublicationCompletedEventListener extends AbstractPoolEventListener implements DataHubEventListener {

 @Override
 public boolean executeInTransaction() {
     return true;
 }

 @Override
 public Class<PublicationCompletedEvent> getEventClass() {
     return PublicationCompletedEvent.class;
 }

 @Override
 public void handleEvent(PublicationCompletedEvent arg0) {

//
}

}

Do you have any inputs on how to achieve this?

Former Member
0 Kudos

Please can you share the name of your spring configuration file and the content. Also check the log to see if your extension containing the Listener is loaded successfully.

Former Member
0 Kudos

custom-saperpproduct-datahub-canonical-datahub-extension-spring.xml :

Is it necessary to create a separate extension for invoking the Listener class? I have tried to invoke the listener through one of the existing custom product extension.

The custom extension is getting invoked properly and loaded in the logs. However my listener is not getting called when publication completes.

Former Member
0 Kudos

yes you can use your existing custom extension. To further help you in finding out why your listener is not called I would need the information I asked above.

Former Member
0 Kudos

As the production procedure is assync the stage does not know when all information for a given distribution has arrived. It just knows it finished a subpublication in any status.

In this way no one but datahub can trigger such an email. Do this you have to actualize

open class PublicationCompletedEventListener actualizes DataHubEventListener < PublicationCompletedEvent> But in some cases it would be helpful. we need to restrict an email such that the implementation works accordingly with no issues raising.

Former Member
0 Kudos

Thanks for the insight. Quite helpful! What I understand here that we might need to write a separate extension for the event-listener logic. I am little confused here as how I can trigger mail from datahub, as I am not sure whether it has emailService in datahub like we have in hybris.

Can you help me forming my mail here and sending it through datahub after listener is activated.

Regards Rahul

Former Member
0 Kudos

You got it right in Datahub there is not email service and its up to you to implement the listener in any way you like in your extension. One option could be to trigger the platform to send emails if you already have knowledge and facilities on the platform side.

Former Member
0 Kudos

As the publication process is assync the platform does not know when all data for a given publication has arrived. It only knows it completed a subpublication in any status.

Therefore only datahub can trigger such an email. Do do this you need to implement

public class PublicationCompletedEventListener implements DataHubEventListener < PublicationCompletedEvent>