Improve subscription procesing within a transaction
This commit is contained in:
parent
2edc9910e5
commit
7046d2fe94
|
@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.subscription;
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -108,19 +108,16 @@ public class SubscriptionCheckingSubscriber extends BaseSubscriptionSubscriber {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// should just be one resource as it was filtered by the id
|
ourLog.info("Found match: queueing rest-hook notification for resource: {}", id.toUnqualifiedVersionless().getValue());
|
||||||
for (IBaseResource nextBase : results.getResources(0, results.size())) {
|
|
||||||
ourLog.info("Found match: queueing rest-hook notification for resource: {}", nextBase.getIdElement());
|
|
||||||
|
|
||||||
ResourceDeliveryMessage deliveryMsg = new ResourceDeliveryMessage();
|
ResourceDeliveryMessage deliveryMsg = new ResourceDeliveryMessage();
|
||||||
deliveryMsg.setPayload(getContext(), nextBase);
|
deliveryMsg.setPayload(getContext(), msg.getNewPayload(getContext()));
|
||||||
deliveryMsg.setSubscription(nextSubscription);
|
deliveryMsg.setSubscription(nextSubscription);
|
||||||
deliveryMsg.setOperationType(msg.getOperationType());
|
deliveryMsg.setOperationType(msg.getOperationType());
|
||||||
deliveryMsg.setPayloadId(msg.getId(getContext()));
|
deliveryMsg.setPayloadId(msg.getId(getContext()));
|
||||||
|
|
||||||
ResourceDeliveryJsonMessage wrappedMsg = new ResourceDeliveryJsonMessage(deliveryMsg);
|
ResourceDeliveryJsonMessage wrappedMsg = new ResourceDeliveryJsonMessage(deliveryMsg);
|
||||||
getSubscriptionInterceptor().getDeliveryChannel().send(wrappedMsg);
|
getSubscriptionInterceptor().getDeliveryChannel().send(wrappedMsg);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,12 @@ public class StopWatch {
|
||||||
tgt.append(val);
|
tgt.append(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param theNumOperations Ok for this to be 0, it will be treated as 1
|
||||||
|
*/
|
||||||
public int getMillisPerOperation(int theNumOperations) {
|
public int getMillisPerOperation(int theNumOperations) {
|
||||||
return (int)(((double) getMillis()) / Math.max(1.0, theNumOperations));
|
int numOperations = Math.min(1, theNumOperations);
|
||||||
|
return (int)(((double) getMillis()) / Math.max(1.0, numOperations));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue