4 Replies Latest reply on Jan 4, 2011 3:16 AM by jbuechel

    Buffering values between actions


      Hi there,


      First of all, I'm fairly new to JBoss ESB.


      We came across the following scenario:


      System1 has to consume a Webservice of System2. Though System1 can't understand the Webservice structure of System2's Webservice.

      Therefore we need to implement an ESB Service which:

      - provides a WS to System1

      - consumes the WS from System2

      - maps the response from System2 to System1


      This all works so far.


      The actual issue we ran into is the following:

      We would need to

      - buffer a request parameter value sent from System1 and span between several actions

      - before the response is being sent back to System1 the buffered value should be merged into the response


      Can anybody tell us how this could be achieved in an easy way?


      Thanks in advance!


        • 1. Re: Buffering values between actions

          I got a bit further.. A possible approach could be:


          1. Saving the original request message body to another payload location (e.g. test-payload).

          2. Before sending the response back to System1 the relevant value could be read from the test-payload and written to the message body of org.jboss.soa.esb.message.defaultEntry.


          Step 1 is done.


          How could be done step 2?

          - e.g. read from test-payload and write/merge the relevant data to org.jboss.soa.esb.message.defaultEntry location using an XSLT or smooks action?

          • 2. Re: Buffering values between actions

            I finally came up with the following solution (if somebody knows a simpler approach, please let us know):


            Smooks configuration:

            <?xml version="1.0" encoding="UTF-8"?>
            <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
            This freemaker configuration adds the value of the bean
            ${ncoInstanceIdBean} to the relevant ESB message. The bean
            ${ncoInstanceIdBean} is actually of type String and is being created
            and populated within
            <ftl:freemarker applyOnElement="ncoInstanceId">
            <ftl:inline directive="addto" />
            <?xml version="1.0" encoding="UTF-8"?>
            <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
             <ftl:freemarker applyOnElement="ncoInstanceId">
               <ftl:inline directive="addto" />


            ESB action implementation:

                 public Message process(Message message) throws ActionProcessingException {
                      try {
                           // Get the original request from the name body
                           ConfigTree treeOrigRequest = ConfigTree.fromXml(message.getBody()
                           // Extract the ncoInstanceId
                           String ncoInstanceId = treeOrigRequest
                           // Smook transformation using a freemaker template
                           Smooks smooks = new Smooks(getClass().getResourceAsStream(
                           ExecutionContext executionContext = smooks.createExecutionContext();
                                     NCO_INSTANCE_ID_BEAN, ncoInstanceId);
                           StringResult result = new StringResult();
                           smooks.filterSource(executionContext, new StringSource(message
                                     .getBody().get().toString()), result);
                           // Add the result to the message body
                      } catch (IOException e1) {
                      } catch (SAXException e1) {
                      return message;
            • 3. Re: Buffering values between actions

              Hi Jonas,


              just a note about performance. You can safely cache and reuse the Smooks Object. Initialization of Smooks takes some time and therefore it is important that it is reused.





              • 4. Re: Buffering values between actions

                Hi Daniel,


                thanks for your hint! That makes sense..


                Very appreciated!


                Kind regards