Is your feature request related to a problem? Please describe.
If writing an audit record fails, the request should fail (and the transaction rolled back). However, for best performance, writing audit records to streams like Kafka should be asynchronous (so you don't have to wait each time for ACKs from each required replica.
Describe the solution you'd like
Use the async API to write the audit record, but capture a Future and add it to the TransactionData implementation class. The Futures can be resolved in the TransactionData#persist() method. If any of the writes failed, the transaction can be marked for rollback.
Describe alternatives you've considered
Use synchronous API and accept the performance impact.
Acceptance Criteria
At least one acceptance criteria is included.
GIVEN a bundle write request
WHEN the audit writes are successful
THEN the request is success
GIVEN a bundle write request
WHEN an audit write fails
THEN the request fails and the database is not changed
Additional context
See com.ibm.fhir.persistence.jdbc.impl.ParameterTransactionDataImpl. The name of this class could probably be changed to something more general if it is going to support more than just parameter data.
Is your feature request related to a problem? Please describe. If writing an audit record fails, the request should fail (and the transaction rolled back). However, for best performance, writing audit records to streams like Kafka should be asynchronous (so you don't have to wait each time for ACKs from each required replica.
Describe the solution you'd like Use the async API to write the audit record, but capture a Future and add it to the TransactionData implementation class. The Futures can be resolved in the TransactionData#persist() method. If any of the writes failed, the transaction can be marked for rollback.
Describe alternatives you've considered Use synchronous API and accept the performance impact.
Acceptance Criteria At least one acceptance criteria is included.
GIVEN a bundle write request WHEN the audit writes are successful THEN the request is success
GIVEN a bundle write request WHEN an audit write fails THEN the request fails and the database is not changed
Additional context See com.ibm.fhir.persistence.jdbc.impl.ParameterTransactionDataImpl. The name of this class could probably be changed to something more general if it is going to support more than just parameter data.