Apama 10.7.2 | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The HTTP Server Transport Connectivity Plug-in | Mapping events between EPL and HTTP server requests | Distinguishing request types
 
Distinguishing request types
A single chain will often deal with multiple event types received within requests. For messages towards the host, the event type will not yet have been set. The Mapper and Classifier codecs can use fields in the message (payload or metadata) to set the event type.
You can write the configuration to behave in whatever way you like. There are several ways of determining to which event type the request corresponds. In the default configuration that we supply, the event type is provided as part of the request, but it is also possible to infer the event type from the content of the request.
Below are some examples of what is possible.
You can use the Mapper codec to set the type and channel from the payload as shown below. The type is part of the request. The Mapper code assigns it to metadata.sag.type.
- mapperCodec:
"*":
towardsHost:
mapFrom:
- metadata.sag.type: payload.type
- metadata.sag.channel: payload.channel
- payload: payload.data
You can use the Classifier codec to determine the event type based on incidental fields in the event, such as the method and path:
- classifierCodec:
rules:
- KickEvent:
- metadata.http.method: GET
- metadata.http.path: /kick
- DocumentSubmissionEvent:
- metadata.http.method: PUT
- metadata.http.path: /submit
- DocumentUpdateEvent:
- metadata.http.method: PUT
- metadata.http.path: /update
The default event type is generally used if all events received in requests are the same:
- apama.eventMap:
defaultEventType: TestEvent
You can use regular expressions with the Classifier codec to match more than one REST URL to a single event type. The following example shows a rule that matches two different REST URLs such as /database/emptable/78451339 and /database/managertable/50044897:
- classifierCodec:
rules:
- com.apama.swagger.ISSPositionResponse:
- regex:metadata.http.path: /database/[a-zA-Z0-9]*/[0-9]*
For detailed information on these codecs, see The Mapper codec connectivity plug-in and The Classifier codec connectivity plug-in.