Thursday, July 4, 2013

[WSO2 ESB] How to set an enclosing element for Aggregated Messages

In this post I am describing how we can add an enclosing element (root element) for the aggregated message of the Aggregate mediator.

To explain the scenario I am using the sample 400 which is shipped with WSO2 ESB.
Setup and run the sample following the instruction given in this link.

Inspect the response received to the axis2Client by placing TCPMon in between axis2Client and ESB.

Following is a sample response message.

  
      
         
            
               4.090953902529174
               12.85037561648507
               82.1992668503766
               79.11591459453155
               Thu Jul 04 19:12:12 IST 2013
               82.07587397906588
               -6710370.759280889
               IBM Company
               82.63216328626984
               -17.95776979490757
               -5.425366866770642
               -75.40418930165814
               IBM
               18847
            
         
         
            
               -2.7046470446807556
               12.566122355911308
               95.09065335757121
               90.75101849376846
               Thu Jul 04 19:12:12 IST 2013
               -90.38486186977777
               4.217188439214337E7
               IBM Company
               94.37670271591331
               25.37945343517513
               3.0241695702614373
               -89.43437138172582
               IBM
               19672
            
         
         
            
               4.170662251407396
               12.24073118459008
               57.80396418762341
               55.33092046169671
               Thu Jul 04 19:12:12 IST 2013
               -54.950295275739805
               6356550.833371431
               IBM Company
               -54.49917237967579
               -17.964379539768633
               -8.124197423811651
               -51.336298637738366
               IBM
               18228
            
         
         
            
               -2.298457196037509
               13.480896570232673
               59.92552901947371
               58.08646649831848
               Thu Jul 04 19:12:12 IST 2013
               60.343852005584246
               1528927.6138464957
               IBM Company
               -57.030367770791436
               24.09552605569928
               -3.6045836945736744
               63.76484473082417
               IBM
               8436
            
        


You can see this message contains multiple root elements (getQuoteResponse).
Having message in this format causes difficulties in mediating the message further using other mediators.
To overcome this we have to enclose these elements with a single root element.

In ESB 4.7.0 a new configuration option for aggregate mediator has introduced to simply achieve this requirement.
We can define the root element in a property of type "OM" in the mediation follow.
To refer to it, we have the configuration option in the aggregate mediator called "enclosingElementProperty". Following is the modified configuration of sample 400 with setting the enclosingElementProperty.



   
      
         
            
         
         
            
               
                  
                     
                        


Following is the new response after specifying the enclosing element.


      
         
            
               
                  3.9054693448138935
                  12.335281253927821
                  -177.97866140275778
                  180.6047969462028
                  Thu Jul 04 20:16:43 IST 2013
                  -178.7391258359091
                  1.3120681155222666E7
                  IBM Company
                  188.41308732511013
                  -18.48633858561689
                  -2.1801479505634216
                  -179.1378123583123
                  IBM
                  17410
               
            
            
               
                  4.335889120902175
                  13.604356794261104
                  91.1089618318819
                  87.11090922338691
                  Thu Jul 04 20:16:43 IST 2013
                  91.25197685882299
                  -9612036.072947197
                  IBM Company
                  89.76683766211949
                  23.079190443619655
                  4.535561151210772
                  95.59763337651628
                  IBM
                  19489
               
            
            
               
                  3.904415274394834
                  -9.582989781384908
                  164.68152083949627
                  159.73864569317885
                  Thu Jul 04 20:16:43 IST 2013
                  165.07866093659734
                  1.4527017539759804E7
                  IBM Company
                  164.61880563666864
                  -18.161817565866475
                  -2.4852000517090636
                  -157.1066792675214
                  IBM
                  7699
               
            
            
               
                  -2.457821949254824
                  -8.469473263282257
                  87.5648992841946
                  83.84165661337398
                  Thu Jul 04 20:16:43 IST 2013
                  87.65683642867681
                  5.546665982864492E7
                  IBM Company
                  -81.82301069483687
                  -18.228056188981697
                  -2.6735315383132683
                  91.93166095229475
                  IBM
                  19549
               
            
         
      
   

No comments:

Post a Comment