Integration – of one interface or a complex job – consists of a list of routes which are linked together and which process, manipulate and transform received data to an output format. A route is a set of rules which describe how to react to a specific event (incoming SOAP call, uploaded CSV file), in particular how to extract, transform and load the incoming data.
Routes are usually defined (in the Spring DSL language) per integration flows.
In Camel terms, a route wires endpoints with processors. The payload in the form of Exchange goes from the consumer endpoint, being transformed with processors, to the producer endpoint.
The first route (public route) in the integration chain always needs initialization for startup. Others routes (private routes) are initialized by receiving an input from the previous route (public or private).
The public route can be initialized mainly in the following ways:
Realtime
The route listens to events / input data and processes this input immediately. There is no delay. For example, event listeners (based on the Rest WebService listener), WebService listener, Socket listener, JMS listener, etc.
Events – The realtime integration is used for receiving a Pricefx event. Based on this event, for example, a price list is imported to the customer system.
<route id="eventItemUpdateManualPriceList"> <from uri="direct:eventItemUpdateManualPriceList"/> <log message="ITEM_UPDATE_MPL event received with info - operation: ${body[operation]} - priceListId: ${body[data][0][typedId]}"/> <choice> <when> <groovy>body.operation != 'DELETE' && body.data[0].status != 'INACTIVE'</groovy> <to uri="direct:manualPriceListExport"/> </when> <otherwise> <log message="Manual price list export is skipped because of operation or status. Operation is ${body[operation]} and status is ${body[data][0][status]}"/> </otherwise> </choice> </route>
Web Service – Via a webService endpoint, you can receive realtime data from other systems.
<cxf:cxfEndpoint id="sapInboundIDOCsServiceEndpoint" wsdlURL="wsdl/InboundIDOCsService.wsdl" serviceClass="eu.pricefx.webservices.aaglobal.inboundidocsservice.InboundIDOCsPort" endpointName="InboundIDOCsPort" address="{{sap-pi.url.InboundIDOCsService}}"> </cxf:cxfEndpoint> <route id="sapWebServicesRoute"> <from uri="cxf:bean:sapInboundIDOCsServiceEndpoint"/> <log message="Received SOAP request for InboundIDOCsService"/> <log message="SOAP request ${body}" loggingLevel="DEBUG" logName="custom.sapWebServicesRoute"/> <convertBodyTo type="java.lang.String" charset="utf-8"/> <to uri="direct:processSOAPRequest"/> </route>
Scheduler / Trigger
The route periodically checks if the input data was delivered at a given location or if it is the correct time to start a route.
This type of public routes is most used. The integration (in this case a scheduled job) usually starts by detecting whether the input data (CSV or XML file) was delivered into a source folder or whether it is the correct time to start an action, e.g. export records from Pricefx to a customer system.
Check input data – Check if the file was delivered. In this case, the folder is periodically checked whether it contains a new file.
<route id="customerMasterData"> <from uri="file:/home/customer?include=Customer.*.csv&sortBy=file:name&delay=60000"/> <log message="Loading customer master data from file ${header[CamelFileNameOnly]}" loggingLevel="INFO" logName="custom.trigger"/> <to uri="direct:loadCustomerMasterCSV"/> <log message="Customer master data from file ${header[CamelFileNameOnly]} have been saved. Total input records count : ${header.PfxTotalInputRecordsCount}"/> </route>
Timer – The start of the route is initialized by a timer.
<route id="timerBasedUpdate"> <from uri="quartz2://inboundServicesTimer?cron=0 0 10-22 1/1 * ? *&stateful=true"/> <log message="Starting timer based update data" loggingLevel="INFO"/> <to uri="direct:ZPBP_960"/> <log message="Done timer based update of data" loggingLevel="INFO"/> </route>
Routes Types
In the from uri
and to uri
sections the following components are most used:
direct
– For details see the Apache documentation https://camel.apache.org/components/4.0.x/direct-component.html.file
– For details see the Apache documentation on https://camel.apache.org/components/4.0.x/file-component.html.timer
– For details see the Apache documentation on https://camel.apache.org/components/4.0.x/timer-component.html.quartz
– For details see the Apache documentation on https://camel.apache.org/components/4.0.x/quartz-component.html.
Further reading: