Apama 9.12.0.5 Community Edition release announcement

The latest release of Apama Community Edition provides a new connectivity plug-in which is a transport allowing the Apama correlator to access REST or other web services. The transport is a client for other webservices, rather than allowing the correlator to act as a web service itself. In order to use the HTTP client transport, you need to configure a chain within the connectivity system using the correlator configuration YAML. This chain provides the mapping between Apama events inside the correlator and HTTP requests/responses to the external web service. Each event sent from Apama is converted to one request to the webservice and a corresponding response (or error) is sent back to Apama.

For example, for these events:

event PutData {
    integer requestId;
    string requestString;
}
 
event PutDataResponse {
    integer requestId;
    string responseString;
}

You would create a chain like:

startChains:
  simpleRestService:
    - apama.eventMap:
        defaultChannel: SRS-response # Channel that responses are delivered on
    - mapperCodec:
        PutData: # requests 
          towardsTransport:
            mapFrom:
              - metadata.requestId: payload.requestId
              - payload: payload.requestString
            defaultValue:
              - metadata.http.method: PUT
              - metadata.http.path: /path/to/service
        PutDataResponse:
          towardsHost:
            mapFrom:
              - payload.responseString: payload
              - payload.requestId: metadata.requestId
    - classifierCodec:
        rules:
          - PutDataResponse:
    - stringCodec
    - httpClient:
        host: foo.com

Once you have created an appropriate chain you then just need to send events to the correct channel from EPL and wait for responses. The requestId is used to tie a particular request to a particular response:

integer id := integer.getUnique();
on PutDataResponse(requestId=id) as pdr {
    // handle response
}
 
send PutData(id, "Request Data") to "SimpleRestService";

This chain is assuming that the data from the web service is a simple string. As with all connectivity plug-in transports, you can use other codecs and mapper rules to transform the data from different formats. For example, the product also contains a JSON codec which lets you communicate with a web-service where the data is encoded in the JSON format.

You can find the full documentation at Using HTTP and REST