Hello,
I am getting an exception when processing DamEvent events on my Job manager that implements EventHandler. I am using code guidelines from references below. My code works fine when processing PageEvent but it does not process the job for DamEvent.
the 23.06.2023 16:43:12.938 *WARN* [EventAdminThread #20] org.apache.sling.event.impl.jobs.JobManagerImpl Discarding job - properties must be serializable: aem/solr/indexing/job : {damEvent=com.day.cq.dam.api.DamEvent@733fc832}
I see this note in the Sling documentation which I don't quite understand: "The job topic follows the conventions for the topic of an OSGi event. All objects in the payload must be serializable and publically available (exported by a bundle). This is required as the job is persisted and unmarshalled before processing."
Also, I see there is a checkJob in the API (https://github.com/apache/sling-org-apache-sling-event/blob/master/src/main/java/org/apache/sling/ev...) which describes the exception I am getting.
Is this a bug? I am working on AEM 6.5.15.0
References:
https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html
https://sling.apache.org/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html
Solved! Go to Solution.
Views
Replies
Total Likes
By default objects on aem are not serialized and your payload need to be serialized as explained on https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html
you need to deserialized your payload object(damevent)as explained https://helpx.adobe.com/experience-manager/kb/deserialization-not-allowed-error.html
https://www.linkedin.com/pulse/aem-sling-jobs-processed-nurbek-umirov
By default objects on aem are not serialized and your payload need to be serialized as explained on https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html
you need to deserialized your payload object(damevent)as explained https://helpx.adobe.com/experience-manager/kb/deserialization-not-allowed-error.html
https://www.linkedin.com/pulse/aem-sling-jobs-processed-nurbek-umirov
Hello @Lucas_Reyes -
As per the Apache Sling documentation :
All objects in the payload of a job must be serializable. This is because the job is persisted and unmarshalled before processing. Serialization allows the objects to be converted into a format that can be stored and reconstructed later.
Issue : You are trying to add it directly to the payload using payload.put("damEvent", damEvent);. However, the DamEvent class might not implement the Serializable interface, causing the serialization error.
import java.io.Serializable;
public class CustomDamEventData implements Serializable {
// Define necessary fields to hold the extracted information from DamEvent
private String eventId;
private String eventPath;
// Constructors, getters, and setters for the fields
// ...
@Override
public String toString() {
return "CustomDamEventData{" +
"eventId='" + eventId + '\'' +
", eventPath='" + eventPath + '\'' +
'}';
}
}
Thank you for your replies DPrakashRaj and Tanika02.
I was missing the fact that DamEvent does not implement Serializable, but DamEvent.Type does. So a little bit of refactoring fixed my issue while sending the payload:
Views
Likes
Replies