Part B - Message Splitting

RH_Icon_Compass_Shiny.png In this lab you will add a Split component, to split a multiple-instance message into separate messages and process them individually.
  1. Open the blueprint.xml file under Camel Context.
  2. Create a new route in the same project

  3. Routes Menu -> Add Route

  1. Add a File component from the Components palette to the new empty route.
  2. Click on the Properties tab and enter the following values:

  3. Advanced->Path -> Directory Name: MultipleInput

  4. Consumer->Delete: True

  5. Add a Split component from the Routing palette:

  1. Edit Split properties:

  2. Language: xpath

  3. Expression: //stocktrading

  4. Add a link between the File component and Split component.

  5. Add a Log component from the Components palette, next to Split.

  6. Message: Processing element: ${body}

  7. Add a SetHeader component next to Log.

  8. headerName: CamelFileName

  9. language: simple
  10. expression: ${date:now:yyyyMMddhhmmssSSS}-read.xml

  11. Add a File endpoint next to setHeader.

  12. Advanced -> Path -> Directory Name:InputDir

  13. Create a link between Split and Log.

  14. Create a link between Log and setHeader.
  15. Create a link between setHeader and File.
  16. Save the file (Ctrl+S).
  17. Inspect the contents of ~/FuseWorkshop/support/Lab3/File3.xml.
general_info_polished.png For each element in the XML document, the splitter will generate a new Message, which will be processed by the subsequent nodes in the route. If we set the “parallelProcessing” option to true in the splitter component, all the splitted messages would be processed concurrently.
  1. Run the routes by right-clicking blueprint.xml -> Run As -> Local Camel Context (without tests)
  2. Right-click on the automatically created “MultipleInput” folder in the Project Explorer.
  3. Select Import -> File System.
  4. Browse to ~/FuseWorkshop/support/Lab3/ ,select File3.xml and click Finish.
  5. This should fire route #2, which will generate a file for each element in the incoming XML file.
  6. Then, each generated file (in the InputDir folder) should trigger an instance of route#1 to process it.
  7. Close all open files.
  8. Stop the camel routes by clicking the stop button.

results matching ""

    No results matching ""