9 Replies Latest reply on Sep 5, 2007 10:28 AM by Kevin Conner

    Serializable problem, object makes a vanishing act.

    Arutha Belron Newbie

      Hey,

      I posted this on the jBPM part of the forum and was advised to go here, thus:

      I've got a question on sending Serializable objects over the bus. I know how this can be done, as I built an application creating a Pojo, sending it onto the bus, modifying it with JbossRules and spitting it out to another service off the bus.

      My problem is this: I tied in the jBPM orchestration with this very same application, and as soon as I send the Serializable over the bus through the process definition now, it comes out the other end in the message.getBody().getContents(), but the get() method, returning an object, is empty this time.

      I believe the cause is that I'm not converting the byte array the message holds in the get() to a jBPM format, as is done with the body contents :

      <variable esb-name="eVar1" jbpm-name="counter" value="45" />
      <variable esb-name="BODY_CONTENT" jbpm-name="theBody" />


      I'm not doing that, since I have no idea how to.

      Is this the cause, and if so, any way I can move the Serializable object in the message to the jBPM orchestration process and back to the ESB ?

        • 1. Re: Serializable problem, object makes a vanishing act.
          Arutha Belron Newbie



          This issue is really locking me down.
          Isn't there any suggestion at all ?

          • 2. Re: Serializable problem, object makes a vanishing act.
            Mark Little Master

            Have you looked at the jBPM quickstarts and tried modifying them?

            • 3. Re: Serializable problem, object makes a vanishing act.
              Mark Little Master

              Also, have you tried printing out the message? toString() on the Message should show you everything that is within your Message, no matter where it occurs.

              • 4. Re: Serializable problem, object makes a vanishing act.
                Kevin Conner Master

                 

                "Arutha" wrote:
                My problem is this: I tied in the jBPM orchestration with this very same application, and as soon as I send the Serializable over the bus through the process definition now, it comes out the other end in the message.getBody().getContents(), but the get() method, returning an object, is empty this time.


                If you are using BODY_CONTENT then this is how the ObjectMapper currently works.

                The only way to pass in an object and have it retrieved intact is to add it into the message body as a named object and then use this name in the mapping.

                message.getBody().add("MyObjectName", obj) ;
                
                and
                
                <variable esb-name="MyObjectName" jbpm-name="theBody" />
                


                • 5. Re: Serializable problem, object makes a vanishing act.
                  Arutha Belron Newbie

                  Yes, I walked through all the related quickstart samples.
                  And I printed the message body, so far I've called just about every Message getter to see what's where.

                  I'm not adding the Pojo in the way specified by Kevin, as in the tutorial, creating an ObjectMessage stores the object in the default 'first' location, calling message.getBody().get() retrieves this default object, which is in my case NULL.

                  • 6. Re: Serializable problem, object makes a vanishing act.
                    Mark Little Master

                    So what did you see when you printed out the message? Can you cut-and-paste it here?

                    • 7. Re: Serializable problem, object makes a vanishing act.
                      Arutha Belron Newbie


                      Right, bare in mind that the code-parts of this post are context-sensitive, but it's a clear before-after shot.

                      The first service, listening on the gateway and picking up the Serializable object picks it up with a smile and can deserialize it in proper fashion using:

                      MailObject mail = (MailObject)message.getBody().get();

                      (That's my Serializable, MailObject)

                      A printout of the message body
                      (message.getBody()
                      ) at this point is as follows:

                      body: [ byte[]: smtpserver.MailObject@1d9f748,
                       objects: {defaultEntry=smtpserver.MailObject@1e22acc, org.jboss.soa.esb.message
                      .transport.jms.messageID=ID:9-11889995042461} ]


                      Calling
                      get()
                      on the body gives the actual object, named "defaultEntry", thus the 'mail' variable is the instance I serialized. So far, so good.


                      The next node calling a different service, lost this object.
                      MailObject mail = (MailObject)message.getBody().get();
                      results in null.
                      A printout of the body:

                      body: [ byte[]: smtpserver.MailObject@1d9f748, objects: {jbpmTokenId=40, jbpmCurrentNodeName=ForwardResult1, jbpmProcessDefVersion=1, jbpmProcessDefName=ZorgRingConnectServicesDefinition, jbpmProcessDefId=1, jbpmProcessInstId=39} ]





                      And this is done using in the process definition:

                      <mapping jbpm-name="theBody" esb-name="BODY_CONTENT" />


                      <mapping jbpm-name="theBody" esb-name="BODY_CONTENT" />


                      And using in the jboss-esb.xml:


                      <variable esb-name="eVar1" jbpm-name="counter" value="45" />
                      <variable esb-name="BODY_CONTENT" jbpm-name="theBody" />






                      So, I'm 100% certain the handing of the Message to jBPM and back to ESB tramples, chews up and otherwise rm -f's my Serializable object. So, I'm clearly not passing the message between the ESB and BPM right ?

                      • 8. Re: Serializable problem, object makes a vanishing act.
                        Arutha Belron Newbie


                        ... and it seems the line

                        <variable esb-name="defaultEntry" jbpm-name="mailObject" />

                        on the right place in both process orchestration and ESB services definition file fixed the problem.

                        You were right, I had to call it by name, namely defaultEntry. It comes out the other end as specified now.



                        • 9. Re: Serializable problem, object makes a vanishing act.
                          Kevin Conner Master

                          Please be aware that this name has changed in the GA release, it has been qualified.

                          Have a look at the messagefilter quickstart for the correct syntax.