How to use entity parameters

An entity parameter is used to filter a query according to a specific instance. Once you've created an entity parameter, you can use it to filter the dimension of a query. The filtering value is chosen from a route at runtime.

Create an Entity Parameter

 

Add filter on dimension

  1. Click the Add dimension button and select Payment
  2. Edit the Payment dimension and filter its instances by using the previously created parameter.

Set runtime value in route

Create a new Route with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
	<route>
		<!-- This route receives a new message each time a payment is created -->
		<from uri="tnd-event:paymentCreated"/>
		<!-- We store the instanceId of the payment in a header to be used later on -->
		<setHeader headerName="paymentId">
			<simple>body.instanceId</simple>
		</setHeader>
		<split>
			<simple>${body}</simple>
			<!-- For each change, we execute a sub-routine -->
			<to uri="direct:line"/>
		</split>
	</route>
	<route>
		<from uri="direct:line"/>
		<!-- Build the parameter map for the query -->
		<setProperty propertyName="tnd-query.parameters">
			<u:map-create>
				<u:map-entry key="tnd-query.referenceTime">
					 <constant>NOW</constant>
				</u:map-entry>
				<u:map-entry key="Payment_EntityParameter">
					<header>paymentId</header>
					<!-- filter by instance id -->
				</u:map-entry>
			</u:map-create>
		</setProperty>
		<to uri="tnd-query:paymentDetails"/>                        
	</route>
</routes>


Related Links