liveBook · Manning

Translate agent

As explained in Event Processing in Action

A translate agent is a stateless transformation agent that derives one output event from one input event using a derivation formula.

A translate agent is a stateless transformation event processing agent (EPA). For each input event, it uses a derivation formula to produce one derived event, independently of preceding or subsequent events. section 2.3.4 section 6.2.4

The derivation expression specifies how to compute each output attribute. A translation can copy, add, remove, or change attributes, or convert an event from one type to another. section 6.2.4 section 8.2.1

Translating an order event

An input event has numItems 10 and price 17. A translation produces an event with orderType “Low”, an adjusted price of 14.78, and total 170, computed from the input price and number of items. The output need not retain every input attribute. section 8.2.1

Listing 8.1. XSLT stylesheet performing the transformation
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match="/event"> <event> <orderType> Low </orderType> <price> <xsl:value-of select="round (100*//price div 1.15) div 100" /> </price> <total> <xsl:value-of select="//price * //numItems" /> </total> </event> </xsl:template> </xsl:stylesheet>

An XSLT stylesheet implements the order-event translation, setting orderType and calculating price and total. section 8.2.1

Two special cases of translation are useful building blocks:

  • A project agent produces an event containing a subset of the input attributes. For example, it can retain a stock ticker and volume-weighted average price while leaving out minimum and maximum prices. section 6.2.4 section 8.2.1
  • An enrich agent queries a global state element using the input event, then uses the result to add or modify attributes. For example, it can use a customer number to add a name and address. section 6.2.4

Unlike a translate agent’s one-input, one-output operation, a split agent produces multiple events from one input, while an aggregate agent produces one event from multiple inputs. A compose agent combines two event streams. section 2.3.4

How Event Processing in Action covers it

How deep it goes
Explains attribute-level derivation and illustrates an XSLT implementation alongside related transformation types.
Examples
Uses an order event with adjusted price and computed total, plus customer-data enrichment and stock-attribute projection.
What you can do after
Evaluate and understand how a derivation expression constructs an output event from input attributes.
How it connects
Connects translation to projection, enrichment, aggregation, splitting, and event streams.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Event Processing in Action. The section links point to the parts of the book it draws on.