Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmale committed Mar 19, 2024
1 parent ff7e89e commit 7a17001
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.jms.Message;

import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand All @@ -20,6 +21,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import ca.uhn.fhir.parser.DataFormatException;

@Component
public class PatientCreateUpdateListener implements EventListener {
Expand Down Expand Up @@ -98,7 +100,18 @@ private void processMessage(Message message) throws JMSException {
if (mapMessage.getJMSDestination().toString().equals(ClientRegistryConstants.UPDATE_MESSAGE_DESTINATION)) {
client.update().resource(patient).execute();
} else {
client.create().resource(patient).execute();
try {
client.create().resource(patient).execute();
}
catch (FhirClientConnectionException e) {
Throwable cause = e.getCause();
if (cause instanceof DataFormatException) {
// just warn if the CR responds with unsupported data format
log.warn(e.getMessage());
} else {
throw e;
}
}
}
}
}
Expand Down

0 comments on commit 7a17001

Please sign in to comment.