Event-Triggered Route

Overview

Pricefx fires events when certain operations complete (e.g., PA data load, CFS calculation). IM can listen for these events and trigger routes automatically.

Configuration: config/application.properties

Enable event polling and map event types to route IDs:

integration.events.enabled=true
integration.events.scheduler-delay=60000
integration.events.delay=10000
integration.events.event-to-route-mapping.PADATALOAD_COMPLETED=direct:onPADataLoadCompleted
integration.events.event-to-route-mapping.CALCULATION_COMPLETED_CFS=direct:onCFSCalculated

Route: routes/event-handlers.xml

XML
<routes xmlns="http://camel.apache.org/schema/spring">

    <!-- Triggered when PA data load completes -->
    <route id="onPADataLoadCompleted">
        <from uri="direct:onPADataLoadCompleted"/>
        <!-- event body is a Map with key "data" containing a list of target info -->
        <setHeader headerName="targetName">
            <simple>${body[data][0][targetName]}</simple>
        </setHeader>
        <choice>
            <when>
                <simple>${headers.targetName} == 'DMDS.Product'</simple>
                <!-- Flush the data feed after the data source is loaded -->
                <to uri="pfx-api:flush?dataFeedName=DMF.Product&amp;dataSourceName=DMDS.Product"/>
            </when>
            <when>
                <simple>${headers.targetName} == 'DMDS.Customer'</simple>
                <to uri="pfx-api:flush?dataFeedName=DMF.Customer&amp;dataSourceName=DMDS.Customer"/>
            </when>
            <otherwise>
                <log message="Unhandled PA data load target: ${headers.targetName}"/>
            </otherwise>
        </choice>
    </route>

    <!-- Triggered when CFS calculation completes -->
    <route id="onCFSCalculated">
        <from uri="direct:onCFSCalculated"/>
        <log message="CFS calculation completed: ${body}"/>
        <!-- Add downstream actions here, e.g. export results -->
    </route>

</routes>

How It Works

  1. IM polls Pricefx for new events every scheduler-delay milliseconds

  2. When an event arrives matching a configured type, IM calls the mapped direct: route

  3. The event payload (body) is a Map — body[data][0][targetName] contains the affected object name

  4. The route processes the event synchronously

Common Event Types

Event Type

When It Fires

PADATALOAD_COMPLETED

After pfx-api:flush completes for a PA data source

CALCULATION_COMPLETED_CFS

After a CFS (Customer Fact Sheet) calculation finishes

CALCULATION_COMPLETED_RV

After a rebate version calculation finishes

Common Pitfalls

  • Event polling requires integration.events.enabled=true — it is false by default

  • Route IDs in event-to-route-mapping must exactly match the <route id="..."> in your XML

  • The direct: prefix is required — events call synchronous routes

  • If the event handler route fails, the event is not retried automatically — add error handling