AEM6.2
I have a Osgi Service where in org.apache.sling.event.jobs.JobManager
referenced and job is added to it.
The code is something like:
Map dataSourceMap = new HashMap<String, DataSource>
dataSourceMap.put(fileName, new ByteArrayDataSource(byte[], mimeTypeOfFile))
final Map<String, Object> props = new HashMap<String, Object>();
props.put("item1", "/something");
props.put("count", 5);
props.put("files", dataSourceMap)
jobManager.addJob("my/special/jobtopic", props);
When this job gets executed it shows some error
org.apache.sling.api.resource.PersistenceException: Value can't be stored in the repository: {<<filename>>=org.apache.commons.mail.ByteArrayDataSource@3f0f234c}
Question: Is there any solution to this exception? Or am I doing something wrong? can we add a ByteArrayInputStream to the jobmanager?
Thank you !
Just a info, If I remove the line props.put("files", dataSourceMap)
, it works fine.
Please let me know if you need more info on it.
Sling will store the job as a node in the repository and it looks like it only supports the "standard" types like String
, Boolean
, Integer
etc. and not files/blobs.
I can not think of a way to add a file to the job, but what you could do is to create temporary node in the repository yourself, which contains the files/blobs.
Sling stores jobs here:
/var/eventing/jobs
You might do something similar:
/var/<project-name>/jobs
And the payload of the Sling job then contains the path to this job node.