3 Replies Latest reply on Feb 8, 2013 7:05 PM by splram

    Setting workflow payload as Java object




      The documentation for CQ workflows indicates that a Java object can be passed as the payload data for a workflow process.  I have a Java class that implements the WorkflowProcess interface and have hooked it up so I can invoke it programmatically.


      However the documentation does not give any insight on the "payload type" options other than "JCR_PATH".  If I use JCR_PATH then it expects the Object passed to be a string (a node path obviously).  Passing anything else will cause a class cast exception. Using any payload type other than JCR_PATH results in the log message "com.day.cq.workflow.impl.jcr.WorkflowManager No payload set" and the process does not get invoked correctly.  They show up in the Workflow instances UI as RUNNING and have no payload (basically stuck).


      Any help?

        • 1. Re: Setting workflow payload as Java object
          Jörg Hoh Adobe Employee

          That's a reasonable limitation of the implementation behind the interface. Just serialize your payload into a JCR node (or a node structure) and then add this node as payload to the workflow. The WF steps then process this node.


          A possible explanation for this: A workflow is guaranteed to be executed exactly once. So at the end of every workflow step the payload must be serialized to the repository to ensure that the next step can be repeated if it fails for any reason. So you can either serialize it yourself and upfront (the workflow then just updates this node struecture) or you would need some OR mapper here, which does this job for you. I prefer the first approach :-)


          kind regards,


          • 2. Re: Setting workflow payload as Java object

            Have you tried using "JAVA_OBJECT" as payload type?

            • 3. Re: Setting workflow payload as Java object
              splram Level 1

              I would rely by setting my java object as one of the property in metadata (which is kind of hashmap) and use it in my subsequeny workflow steps.