Fix for failing IT test in jpaserver-starter (#5435)

Co-authored-by: dotasek <dotasek.dev@gmail.com>
This commit is contained in:
TynerGjs 2023-11-07 13:30:27 -05:00 committed by GitHub
parent 0831e0f05e
commit 3062fad839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedJsonMessage;
import ca.uhn.fhir.jpa.subscription.model.ResourceModifiedMessage;
import ca.uhn.fhir.jpa.topic.filter.InMemoryTopicFilterMatcher;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.subscription.api.IResourceModifiedMessagePersistenceSvc;
import ca.uhn.fhir.util.Logs;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r5.model.SubscriptionTopic;
@ -42,6 +43,7 @@ import org.springframework.messaging.MessagingException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
public class SubscriptionTopicMatchingSubscriber implements MessageHandler {
@ -73,6 +75,9 @@ public class SubscriptionTopicMatchingSubscriber implements MessageHandler {
@Autowired
private InMemoryTopicFilterMatcher myInMemoryTopicFilterMatcher;
@Autowired
private IResourceModifiedMessagePersistenceSvc myResourceModifiedMessagePersistenceSvc;
public SubscriptionTopicMatchingSubscriber(FhirContext theFhirContext) {
myFhirContext = theFhirContext;
}
@ -88,6 +93,16 @@ public class SubscriptionTopicMatchingSubscriber implements MessageHandler {
ResourceModifiedMessage msg = ((ResourceModifiedJsonMessage) theMessage).getPayload();
if (msg.getPayload(myFhirContext) == null) {
// inflate the message and ignore any resource that cannot be found.
Optional<ResourceModifiedMessage> inflatedMsg =
myResourceModifiedMessagePersistenceSvc.inflatePersistedResourceModifiedMessageOrNull(msg);
if (inflatedMsg.isEmpty()) {
return;
}
msg = inflatedMsg.get();
}
// Interceptor call: SUBSCRIPTION_TOPIC_BEFORE_PERSISTED_RESOURCE_CHECKED
HookParams params = new HookParams().add(ResourceModifiedMessage.class, msg);
if (!myInterceptorBroadcaster.callHooks(