Avoid deserialization issues in subscription delivery (#1856)
* Avoid deserialization issues in subscription delivery * Add changelog
This commit is contained in:
parent
5b2181a563
commit
e07e071130
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 1856
|
||||||
|
title: The subscription delivery queue in the JPA server was erroniously keeping both a copy of the serialized and the
|
||||||
|
deserialized payload in memory for each entry in the queue, doubling the memory requirements. This also caused failures
|
||||||
|
when delivering XML payloads in some configurations. This has been corrected.
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 1856
|
||||||
|
title: "The subscription delivery queue in the JPA server was erroniously keeping both a copy of the serialized and the
|
||||||
|
deserialized payload in memory for each entry in the queue, doubling the memory requirements. This also caused failures
|
||||||
|
when delivering XML payloads in some configurations. This has been corrected."
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.subscription.model;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.parser.IParser;
|
||||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
@ -62,7 +63,8 @@ public class ResourceDeliveryMessage extends BaseResourceMessage implements IRes
|
||||||
public IBaseResource getPayload(FhirContext theCtx) {
|
public IBaseResource getPayload(FhirContext theCtx) {
|
||||||
IBaseResource retVal = myPayload;
|
IBaseResource retVal = myPayload;
|
||||||
if (retVal == null && isNotBlank(myPayloadString)) {
|
if (retVal == null && isNotBlank(myPayloadString)) {
|
||||||
retVal = theCtx.newJsonParser().parseResource(myPayloadString);
|
IParser parser = EncodingEnum.detectEncoding(myPayloadString).newParser(theCtx);
|
||||||
|
retVal = parser.parseResource(myPayloadString);
|
||||||
myPayload = retVal;
|
myPayload = retVal;
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -93,7 +95,13 @@ public class ResourceDeliveryMessage extends BaseResourceMessage implements IRes
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPayload(FhirContext theCtx, IBaseResource thePayload, EncodingEnum theEncoding) {
|
public void setPayload(FhirContext theCtx, IBaseResource thePayload, EncodingEnum theEncoding) {
|
||||||
myPayload = thePayload;
|
/*
|
||||||
|
* Note that we populate the raw string but don't keep the parsed resource around when we set this. This
|
||||||
|
* has two reasons:
|
||||||
|
* - If we build up a big queue of these on an in-memory queue, we aren't taking up double the memory
|
||||||
|
* - If use a serializing queue, we aren't behaving differently (and therefore possibly missing things
|
||||||
|
* in tests)
|
||||||
|
*/
|
||||||
myPayloadString = theEncoding.newParser(theCtx).encodeResourceToString(thePayload);
|
myPayloadString = theEncoding.newParser(theCtx).encodeResourceToString(thePayload);
|
||||||
myPayloadId = thePayload.getIdElement().toUnqualified().getValue();
|
myPayloadId = thePayload.getIdElement().toUnqualified().getValue();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue