added fix for subscription in default partition when default partitio… (#3670)

* added fix for subscription in default partition when default partition's id is null

* added changelog

Co-authored-by: Long Ma <long@smilecdr.com>
This commit is contained in:
longma1 2022-06-03 12:54:54 -06:00 committed by GitHub
parent 72823b730d
commit 1a90c7e9ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
type: fix
issue: 2669
title: "Previously subscriptions in a partition with the id null will be matched against incoming resources from all partitions.
Changed to subscriptions will only match against incoming resources in the partition the subscription exists in unless
cross partition subscription is enabled and the subscription has the appropriate extension."

View File

@ -127,7 +127,7 @@ public class SubscriptionMatchingSubscriber implements MessageHandler {
for (ActiveSubscription nextActiveSubscription : subscriptions) { for (ActiveSubscription nextActiveSubscription : subscriptions) {
// skip if the partitions don't match // skip if the partitions don't match
CanonicalSubscription subscription = nextActiveSubscription.getSubscription(); CanonicalSubscription subscription = nextActiveSubscription.getSubscription();
if (subscription != null && subscription.getRequestPartitionId() != null && theMsg.getPartitionId() != null && if (subscription != null && theMsg.getPartitionId() != null &&
theMsg.getPartitionId().hasPartitionIds() && !subscription.getCrossPartitionEnabled() && theMsg.getPartitionId().hasPartitionIds() && !subscription.getCrossPartitionEnabled() &&
!theMsg.getPartitionId().hasPartitionId(subscription.getRequestPartitionId())) { !theMsg.getPartitionId().hasPartitionId(subscription.getRequestPartitionId())) {
continue; continue;

View File

@ -245,6 +245,42 @@ public class SubscriptionMatchingSubscriberTest extends BaseBlockingQueueSubscri
mySubscriptionResourceNotMatched.awaitExpected(); mySubscriptionResourceNotMatched.awaitExpected();
} }
@Test
public void testSubscriptionOnDefaultPartitionAndResourceOnDiffPartitionNotMatch() throws InterruptedException {
myPartitionSettings.setPartitioningEnabled(true);
String payload = "application/fhir+json";
String code = "1000000050";
String criteria = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
RequestPartitionId requestPartitionId = RequestPartitionId.defaultPartition();
Subscription subscription = makeActiveSubscription(criteria, payload, ourListenerServerBase);
mockSubscriptionRead(requestPartitionId, subscription);
sendSubscription(subscription, requestPartitionId, true);
mySubscriptionResourceNotMatched.setExpectedCount(1);
sendObservation(code, "SNOMED-CT", RequestPartitionId.fromPartitionId(1));
mySubscriptionResourceNotMatched.awaitExpected();
}
@Test
public void testSubscriptionOnAPartitionAndResourceOnDefaultPartitionNotMatch() throws InterruptedException {
myPartitionSettings.setPartitioningEnabled(true);
String payload = "application/fhir+json";
String code = "1000000050";
String criteria = "Observation?code=SNOMED-CT|" + code + "&_format=xml";
RequestPartitionId requestPartitionId = RequestPartitionId.fromPartitionId(1);
Subscription subscription = makeActiveSubscription(criteria, payload, ourListenerServerBase);
mockSubscriptionRead(requestPartitionId, subscription);
sendSubscription(subscription, requestPartitionId, true);
mySubscriptionResourceNotMatched.setExpectedCount(1);
sendObservation(code, "SNOMED-CT", RequestPartitionId.defaultPartition());
mySubscriptionResourceNotMatched.awaitExpected();
}
@Test @Test
public void testSubscriptionOnOnePartitionMatchResourceOnMultiplePartitions() throws InterruptedException { public void testSubscriptionOnOnePartitionMatchResourceOnMultiplePartitions() throws InterruptedException {
myPartitionSettings.setPartitioningEnabled(true); myPartitionSettings.setPartitioningEnabled(true);