From 1afde7e2b56e5c31f540458f1e03b3c331a882f7 Mon Sep 17 00:00:00 2001 From: sagIoTPower Date: Mon, 13 May 2024 21:21:12 +0200 Subject: [PATCH] added partition information --- repository/blocks/EnhancedHttpOutputBlock.mon | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/repository/blocks/EnhancedHttpOutputBlock.mon b/repository/blocks/EnhancedHttpOutputBlock.mon index 10064e6..ba85abe 100644 --- a/repository/blocks/EnhancedHttpOutputBlock.mon +++ b/repository/blocks/EnhancedHttpOutputBlock.mon @@ -16,6 +16,7 @@ using apama.analyticsbuilder.Activation; using apama.analyticsbuilder.ABConstants; using apama.analyticsbuilder.L10N; using apama.analyticsbuilder.Value; +using apama.analyticsbuilder.TimerParams; using com.softwareag.connectivity.httpclient.HttpTransport; using com.softwareag.connectivity.httpclient.RequestType; @@ -23,6 +24,22 @@ using com.softwareag.connectivity.httpclient.Request; using com.softwareag.connectivity.httpclient.Response; +event HTTPHandler + { + string deviceId; + /** Handle the HTTP response.*/ + action handleResponse(Response res) { + // $base.createTimer(($parameters.timeout.toFloat() / 1000.0), res); // Creates a timer with the specified duration. + TimerParams tp := TimerParams.relative($parameters.timeout.toFloat() / 1000.0).withPayload(res) + .withPartition(deviceId)); + + log "Called handleResponse: " + res.payload.data.toString() at INFO; + if not res.isSuccess() { + log "Unable to connect " +$parameters.host+". Error code: " + res.statusMessage at WARN; + } + } + } + /** * Event definition of the parameters for the HTTP Output block. */ @@ -176,19 +193,12 @@ event EnhancedHTTPOutput { Request req := transport.createPOSTRequest($parameters.path, data); // Execute the request and pass the callback action. - req.execute(handleResponse); + string deviceId := $activation.partition.toString(); + log "Processing for partition: " + deviceId at INFO; + req.execute(HTTPHandler(deviceId).handleResponse); $base.profile(BlockBase.PROFILE_OUTPUT); } - /** Handle the HTTP response.*/ - action handleResponse(Response res) { - $base.createTimer(($parameters.timeout.toFloat() / 1000.0), res); // Creates a timer with the specified duration. - - log "Called handleResponse: " + res.payload.data.toString() at INFO; - if not res.isSuccess() { - log "Unable to connect " +$parameters.host+". Error code: " + res.statusMessage at WARN; - } - } /** * This action is called by the framework when the timer is triggered. The framework provides the value of the payload which was passed while creating the timer. @@ -206,7 +216,7 @@ event EnhancedHTTPOutput { } log "Response parsed: " + propertyValues.toString() at INFO; - + $setOutput_responseBody($activation, Value(true, $activation.timestamp, propertyValues)); $setOutput_statusCode($activation, response.statusCode.toFloat()); }