‎2019 Jul 11 3:07 PM - edited ‎2024 Feb 04 6:51 AM
Hi Experts,
We have one requirement where an email should be triggered automatically, listing the errors occurred during load, composition and publication stages of data hub. We just need the list of errors which we can see in backoffice inside Errors & Failures menu in an email after respective stage is completed.
For above requirement I have following questions:
1) How to extend existing classes in data hub?
2) Where should the extended classes be created(do we need to create new extension)?
3) Which classes need to be extended?
We are using Hybris 1808.
A detailed answer would be great.
Thanks
Request clarification before answering.
Kaushik,
1) I would leave class extension as the last resort, when absolutely there is no other way to achieve your requirement. Generally composition (vs inheritance) is much more preferred way and leads to fewer problems in future.
2) Yes, you will need a new extension.
3) Hopefully none. You will write your own classes providing this functionality.
Here is what you can do. First, you will need listeners for DataLoadingCompletedEvent, CompositionCompletedEvent and for TargetSystemPublicationCompletedEvent to be notified whenever the corresponding processes finish and to kick off your custom logic for sending emails. Use this example to write them.
Then, you will need some service, which takes a list of ErrorDatas, maybe some context information, e.g. process name (data load, composition or publication), etc. This service will compose an email out of provided data and will send that email according to its configuration. In reality this service can be split into several classes to divide responsibilities but that's implementation details. it's really up to you how you design this service.
Finally, you will need some services, which will retrieve errors for the corresponding processes:
call DataHubPoolActionFacade.getCompositionErrors(long actionId, DataHubPageable pageable) to retrieve composition errors for the specified composition action ID (comes from the CompositionCompletedEvent).
call PublicationFacade.getTargetSystemPublicationErrors(long publicationId, DataHubPageable pageable) to retrieve publication errors for the specified publication ID (comes from the TargetSystemPublicationCompletedEvent).
Data loading is a special case. The event has the action ID and the status, so in case of an error you know that loading action failed. The simplest thing is to create an ErrorData instance with a generic message, e.g. "Data load #... failed" to the email service. We do not get good messages during the data load anyway. it's more of everything in the load is failed or succeeded.
So, at the end you will have listeners catching the events, then calling the services, which retrieve the data and pass to the email service, which sends the email. All classes are new. Register all your listeners/services as Spring beans in the spring.xml configuration. Inject required dependencies into your services through the spring configuration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Thanks for the detailed answer. I still have few more questions:
We have already created one extension for datahub which has following structure: myprojectdatahub -> myprojectdatahub-canonical -> myprojectdatahub-raw -> myprojectdatahub-target
1) Should I create one more module under myprojectdatahub or create a new project altogether?
2) Can you please provide detailed steps for creating this module/project through mvn?
3) I tried creating one listener class inside myprojectdatahub-canonical source folder, but was not able to get reference to DataHubPoolActionFacade interface. Which API does this interface/ implementation class belong to? and how do I add its dependency?
Thanks in advance.
It's up to you. Seems like sending email functionality has value by itself regardless of other details in your project. It probably can be reused by other team or referred to for other teams. So, I would start that extension as a completely independent project.
As to starting a new maven project, it's very standard and you'll find plenty documents and help on the web for working with maven. It could be too much for me to explain here. However, if you try it and have very specific questions, I can try to help. Also, specific steps would depend on whether you have access to the hybris artifactory or not.
Generally, you can leverage your IDE to create the maven project. Start new maven project, the IDE will prompt you for needed input. There is no special maven archetype to use. Then you will need to configure dependencies on the DataHub libraries, which you already should have in your current project. Just copy them into the new project's pom.xml. And then write code.
Write an extension in that write an event. whenever you get exception trigger this event to send email.
if you are using hybris cloud. logs will be available from splunk. so without doing code changes you can create alerts on splunk. For this we really dont need to do any code change.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.