Bug fix in subscription processing
This commit is contained in:
parent
93bd018016
commit
98d794e30f
|
@ -177,10 +177,13 @@ public class SubscriptionActivatingSubscriber {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerSubscriptionUnlessAlreadyRegistered(IBaseResource theSubscription) {
|
private void registerSubscriptionUnlessAlreadyRegistered(IBaseResource theSubscription) {
|
||||||
if (!mySubscriptionInterceptor.hasSubscription(theSubscription.getIdElement())) {
|
if (mySubscriptionInterceptor.hasSubscription(theSubscription.getIdElement())) {
|
||||||
|
ourLog.info("Updating already-registered active subscription {}", theSubscription.getIdElement().toUnqualified().getValue());
|
||||||
|
mySubscriptionInterceptor.unregisterSubscription(theSubscription.getIdElement());
|
||||||
|
} else {
|
||||||
ourLog.info("Registering active subscription {}", theSubscription.getIdElement().toUnqualified().getValue());
|
ourLog.info("Registering active subscription {}", theSubscription.getIdElement().toUnqualified().getValue());
|
||||||
mySubscriptionInterceptor.registerSubscription(theSubscription.getIdElement(), theSubscription);
|
|
||||||
}
|
}
|
||||||
|
mySubscriptionInterceptor.registerSubscription(theSubscription.getIdElement(), theSubscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class TestR4Config extends BaseJavaConfigR4 {
|
||||||
|
|
||||||
DataSource dataSource = ProxyDataSourceBuilder
|
DataSource dataSource = ProxyDataSourceBuilder
|
||||||
.create(retVal)
|
.create(retVal)
|
||||||
.logQueryBySlf4j(SLF4JLogLevel.INFO, "SQL")
|
// .logQueryBySlf4j(SLF4JLogLevel.INFO, "SQL")
|
||||||
.logSlowQueryBySlf4j(10, TimeUnit.SECONDS)
|
.logSlowQueryBySlf4j(10, TimeUnit.SECONDS)
|
||||||
.countQuery(new ThreadQueryCountHolder())
|
.countQuery(new ThreadQueryCountHolder())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -355,6 +355,53 @@ public class RestHookTestR4Test extends BaseResourceProviderR4Test {
|
||||||
Assert.assertFalse(observation2.getId().isEmpty());
|
Assert.assertFalse(observation2.getId().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateSubscriptionToMatchLater() throws Exception {
|
||||||
|
String payload = "application/xml";
|
||||||
|
|
||||||
|
String code = "1000000050";
|
||||||
|
String criteriaBad = "Observation?code=SNOMED-CT|" + code + "111&_format=xml";
|
||||||
|
|
||||||
|
ourLog.info("** About to create non-matching subscription");
|
||||||
|
|
||||||
|
Subscription subscription2 = createSubscription(criteriaBad, payload, ourListenerServerBase);
|
||||||
|
|
||||||
|
ourLog.info("** About to send observation that wont match");
|
||||||
|
|
||||||
|
Observation observation1 = sendObservation(code, "SNOMED-CT");
|
||||||
|
|
||||||
|
// Criteria didn't match, shouldn't see any updates
|
||||||
|
waitForQueueToDrain();
|
||||||
|
Thread.sleep(1000);
|
||||||
|
assertEquals(0, ourUpdatedObservations.size());
|
||||||
|
|
||||||
|
Subscription subscriptionTemp = myClient.read().resource(Subscription.class).withId(subscription2.getId()).execute();
|
||||||
|
Assert.assertNotNull(subscriptionTemp);
|
||||||
|
String criteriaGood = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
|
||||||
|
subscriptionTemp.setCriteria(criteriaGood);
|
||||||
|
ourLog.info("** About to update subscription");
|
||||||
|
myClient.update().resource(subscriptionTemp).withId(subscriptionTemp.getIdElement()).execute();
|
||||||
|
waitForQueueToDrain();
|
||||||
|
|
||||||
|
ourLog.info("** About to send Observation 2");
|
||||||
|
Observation observation2 = sendObservation(code, "SNOMED-CT");
|
||||||
|
waitForQueueToDrain();
|
||||||
|
|
||||||
|
// Should see a subscription notification this time
|
||||||
|
waitForSize(0, ourCreatedObservations);
|
||||||
|
waitForSize(1, ourUpdatedObservations);
|
||||||
|
|
||||||
|
myClient.delete().resourceById(new IdType("Subscription/" + subscription2.getId())).execute();
|
||||||
|
|
||||||
|
Observation observationTemp3 = sendObservation(code, "SNOMED-CT");
|
||||||
|
|
||||||
|
// No more matches
|
||||||
|
Thread.sleep(1000);
|
||||||
|
assertEquals(1, ourUpdatedObservations.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRestHookSubscriptionApplicationXmlJson() throws Exception {
|
public void testRestHookSubscriptionApplicationXmlJson() throws Exception {
|
||||||
String payload = "application/fhir+xml";
|
String payload = "application/fhir+xml";
|
||||||
|
|
Loading…
Reference in New Issue