Add config

This commit is contained in:
jamesagnew 2018-02-18 11:11:35 -05:00
parent 2f4ac42edb
commit a60e5cab2a
1 changed files with 19 additions and 12 deletions

View File

@ -31,6 +31,7 @@ import org.springframework.messaging.MessagingException;
public abstract class BaseSubscriptionDeliverySubscriber extends BaseSubscriptionSubscriber { public abstract class BaseSubscriptionDeliverySubscriber extends BaseSubscriptionSubscriber {
private static final Logger ourLog = LoggerFactory.getLogger(BaseSubscriptionDeliverySubscriber.class); private static final Logger ourLog = LoggerFactory.getLogger(BaseSubscriptionDeliverySubscriber.class);
private boolean myReloadResourceBeforeDelivery = true;
public BaseSubscriptionDeliverySubscriber(IFhirResourceDao<?> theSubscriptionDao, Subscription.SubscriptionChannelType theChannelType, BaseSubscriptionInterceptor theSubscriptionInterceptor) { public BaseSubscriptionDeliverySubscriber(IFhirResourceDao<?> theSubscriptionDao, Subscription.SubscriptionChannelType theChannelType, BaseSubscriptionInterceptor theSubscriptionInterceptor) {
super(theSubscriptionDao, theChannelType, theSubscriptionInterceptor); super(theSubscriptionDao, theChannelType, theSubscriptionInterceptor);
@ -48,11 +49,12 @@ public abstract class BaseSubscriptionDeliverySubscriber extends BaseSubscriptio
return; return;
} }
CanonicalSubscription updatedSubscription = (CanonicalSubscription)getSubscriptionInterceptor().getIdToSubscription().get(msg.getSubscription().getIdElement(getContext()).getIdPart()); CanonicalSubscription updatedSubscription = (CanonicalSubscription) getSubscriptionInterceptor().getIdToSubscription().get(msg.getSubscription().getIdElement(getContext()).getIdPart());
if (updatedSubscription != null) { if (updatedSubscription != null) {
msg.setSubscription(updatedSubscription); msg.setSubscription(updatedSubscription);
} }
if (myReloadResourceBeforeDelivery) {
// Reload the payload just in case any interceptors modified // Reload the payload just in case any interceptors modified
// it before it was saved to the database. This is also // it before it was saved to the database. This is also
// useful for resources created in a transaction, since they // useful for resources created in a transaction, since they
@ -62,6 +64,7 @@ public abstract class BaseSubscriptionDeliverySubscriber extends BaseSubscriptio
IFhirResourceDao dao = getSubscriptionDao().getDao(type); IFhirResourceDao dao = getSubscriptionDao().getDao(type);
IBaseResource loadedPayload = dao.read(payloadId); IBaseResource loadedPayload = dao.read(payloadId);
msg.setPayload(getContext(), loadedPayload); msg.setPayload(getContext(), loadedPayload);
}
handleMessage(msg); handleMessage(msg);
} catch (Exception e) { } catch (Exception e) {
@ -72,4 +75,8 @@ public abstract class BaseSubscriptionDeliverySubscriber extends BaseSubscriptio
public abstract void handleMessage(ResourceDeliveryMessage theMessage) throws Exception; public abstract void handleMessage(ResourceDeliveryMessage theMessage) throws Exception;
public void setReloadResourceBeforeDelivery(boolean theReloadResourceBeforeDelivery) {
myReloadResourceBeforeDelivery = theReloadResourceBeforeDelivery;
}
} }