יום שישי, 9 במאי 2014

asyncRequestBody con’t 1

I wanted to check the asyncRequestBody method in more complicated scenarios from the last post.
I Created the following route

   public void configure() {
        
        from("direct:cafeEnterence").to("bean:hostess?method=getTable").to("seda:nextStage");
        
        from("seda:nextStage").to("bean:hostess?method=getVipTable");

and I changed the hostess class to


public class hostess {
    public CafeTable getTable (Guest pGuest)
    {
       System.out.println ("No of people  :" + Integer.toString(pGuest.getmNoOfP()));
        
        return new CafeTable ("Not in the smoking Zone");
    }    
    public CafeTable getVipTable (CafeTable pCafeTable)
    {
        return new CafeTable (pCafeTable.getmLocation() + " and in vip area." );
    }
}

Executing the code:
No of people  :4
The table :CafeTable{mLocation=Not in the smoking Zone and in vip area.}

The future waits for the route to end until it executes its code.

Now lets split the route
Add the guestspliter


public class GuestSplitter {
      public List<Guest> split(Guest pGuest) {
          List<Guest> RetValue = new ArrayList<Guest>();
          for ( int i = 0 ; i < pGuest.getmNoOfP() ; i ++)
          {
              RetValue.add(new Guest ( i) );
          }
          
          return RetValue;
    }
}

Change the route


 from("direct:cafeEnterence").split().method("GuestSplitter").to("bean:hostess?method=getTable");

Now the response of
CafeTable response = future.get(1, TimeUnit.MINUTES);
is null




אין תגובות:

הוסף רשומת תגובה