Acknowledging Receipt Before Processing¶
When an HTTP, HL7 MLLP, or other request/response source needs to return a fast 200/ACK on receipt and then continue processing the message through the channel (database insert, downstream call, transformation), use the From Acknowledgement Script response option. The script runs and posts the response before the message enters the channel, so the client is released as soon as QIE has the bytes, the rest of the pipeline runs in the background.
The alternative response option, From Mapping or Destination node, holds the request open until a channel node calls qie.postMessageResponse() (or the response times out). Use that when the response body must reflect the result of processing; use the acknowledgement-script option when the client only needs to know the message was received.
HTTP Listener¶
On the source node, set Response to From Acknowledgement Script, then write a Response Script that posts the reply:
qie.postMessageResponse('HTTP Status: 200\r\n' +
'http.header.Content-Type=application/json\r\n' +
'\r\n' +
'{"status":"received"}');
After the script returns, QIE flushes the response to the client and submits the message into the channel for normal processing. Any downstream mapping or destination work runs without the client waiting.
The response body may begin with HTTP Status:, http.header.<name>=<value>, and Content-Type: prefix lines; see HTTP Source Response Body Format for the full set.
HL7 MLLP¶
The same option is available on the HL7 MLLP receiver. Build the ACK in the Response Script by reading MSH from the parsed source message and posting the constructed MSH+MSA segments. The MLLP framing (<VT> … <FS><CR>) is added by the receiver, not by the script:
var sendingApp = source.getNode('MSH-3');
var sendingFac = source.getNode('MSH-4');
var receivingApp = source.getNode('MSH-5');
var receivingFac = source.getNode('MSH-6');
var controlId = source.getNode('MSH-10');
var ack =
'MSH|^~\\&|' + receivingApp + '|' + receivingFac + '|' +
sendingApp + '|' + sendingFac + '|' +
qie.formatDate('yyyyMMddHHmmss') + '||ACK|' + controlId + '|P|2.3\r' +
'MSA|AA|' + controlId + '\r';
qie.postMessageResponse(ack);
The acknowledgement code in MSA-1 is AA (accept), AE (error), or AR (reject). Mirror MSH-3/MSH-4 and MSH-5/MSH-6 between the inbound message and the ACK as shown so the sender can route the reply.
When NOT to use this pattern¶
If the client expects the response body to carry information that depends on processing, for example, an HTTP 201 Created whose body must include the new database row's primary key, or an HL7 ACK whose MSA-3 must reflect a validation failure raised by a mapping node. Leave Response set to From Mapping or Destination node and call qie.postMessageResponse() from the mapping or destination script that produced the result. The client waits, but the response is accurate.
Caveats¶
- The acknowledgement is final. Once the script returns the response, QIE has already told the client the message was received. A later error in the channel (database insert failure, transformation exception) lands in the error queue but does not be communicated back to the sender. Make sure the error queue is monitored or paired with an Automated Error Queue Remediation script.
- Persistence matters. Channels with persistence level 0 do not write the message to disk on receive. If the engine restarts between the acknowledgement and the channel finishing, the message is lost. For acknowledge-before-process flows, use persistence level 1 or higher so the message survives a restart.
- Cancelling the response. Calling
qie.cancelMessageResponse()instead ofpostMessageResponseskips sending any reply (the client sees a closed connection). Use it sparingly. Most senders interpret a missing response as a transport failure and retry.