New rider here ... please be gentle :-) ... making my way through the Manning 
book (a highly recommended publication for beginners!) ... read through section 
8.3 but still didn't find the answer I'm looking for.

I plan on writing a splitter bean that will extract multiple messages (using a 
custom business entity API call). My situation calls for me to decorate each 
message with different custom headers (based on additional business logic).

Assuming a Component is making BusinessEntity available :

public List<Exchange> pullMessages(@Body BusinessEntity businessObject, 
Exchange originalExchange)
{
   List<Exchange> newExchangeList = new ArrayList<Exchange>();
   Endpoint endPoint = originalExchange.getFromEndpoint();
   for(BusinessSubentity subEntity : businessObject.getChildren())
   {
      Exchange newExchange = endPoint.createExchange();

      newExchange.getIn().setBody(subEntity, BusinessSubentity.class);
      newExchange.getIn().setHeaders(originalExchange.getIn().getHeaders());
      newExchange.setExchangeId(originalExchange.getExchangeId());
      newExchange.getIn().setHeader("MessageSubtype", 
subEntity.getMessageType(businessObject.getPermissionSet()));
      newExchangeList.add(newExchange);
   }

   return newExchangeList;
}

Is this an acceptable Splitter implementation? Am I violating a Camel best 
practice? Does Camel support this (I assume it does)? Is there an easier way to 
do this?

My apologies for the length of the email and any help is deeply appreciated.

Thanks,
Mike G.
This communication, along with its attachments, is considered confidential and 
proprietary to Vistronix.  It is intended only for the use of the person(s) 
named above.  Note that unauthorized disclosure or distribution of information 
not generally known to the public is strictly prohibited.  If you are not the 
intended recipient, please notify the sender immediately.

Reply via email to