Merge pull request #2771 from hapifhir/issue-2768-convert-mdm-submit-to-spring-batch
$mdm-submit operation was only submitting 100 resources ...
This commit is contained in:
commit
7aba83293a
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 2768
|
||||
title: "$mdm-submit operation was only submitting 100 resources and then stopping. It now correctly submits all
|
||||
requested resources."
|
|
@ -65,7 +65,9 @@ public class MdmSubmitSvcImpl implements IMdmSubmitSvc {
|
|||
@Autowired
|
||||
private IMdmSettings myMdmSettings;
|
||||
|
||||
private static final int BUFFER_SIZE = 100;
|
||||
public static final int DEFAULT_BUFFER_SIZE = 100;
|
||||
|
||||
private int myBufferSize = DEFAULT_BUFFER_SIZE;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
|
@ -88,7 +90,8 @@ public class MdmSubmitSvcImpl implements IMdmSubmitSvc {
|
|||
|
||||
validateSourceType(theSourceResourceType);
|
||||
SearchParameterMap spMap = myMdmSearchParamSvc.getSearchParameterMapFromCriteria(theSourceResourceType, theCriteria);
|
||||
spMap.setLoadSynchronousUpTo(BUFFER_SIZE);
|
||||
spMap.setLoadSynchronous(true);
|
||||
spMap.setCount(myBufferSize);
|
||||
ISearchBuilder searchBuilder = myMdmSearchParamSvc.generateSearchBuilderForType(theSourceResourceType);
|
||||
return submitAllMatchingResourcesToMdmChannel(spMap, searchBuilder);
|
||||
}
|
||||
|
@ -99,7 +102,7 @@ public class MdmSubmitSvcImpl implements IMdmSubmitSvc {
|
|||
try (IResultIterator query = theSearchBuilder.createQuery(theSpMap, searchRuntimeDetails, null, RequestPartitionId.defaultPartition())) {
|
||||
Collection<ResourcePersistentId> pidBatch;
|
||||
do {
|
||||
pidBatch = query.getNextResultBatch(BUFFER_SIZE);
|
||||
pidBatch = query.getNextResultBatch(myBufferSize);
|
||||
total += loadPidsAndSubmitToMdmChannel(theSearchBuilder, pidBatch);
|
||||
} while (query.hasNext());
|
||||
} catch (IOException theE) {
|
||||
|
@ -159,4 +162,9 @@ public class MdmSubmitSvcImpl implements IMdmSubmitSvc {
|
|||
throw new InvalidRequestException(ProviderConstants.OPERATION_MDM_SUBMIT + " does not support resource type: " + theResourceType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferSize(int myBufferSize) {
|
||||
this.myBufferSize = myBufferSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ class MdmBatchSvcImplIT extends BaseMdmR4Test {
|
|||
public void after() throws IOException {
|
||||
myInterceptorService.unregisterInterceptor(afterMdmLatch);
|
||||
afterMdmLatch.clear();
|
||||
myMdmSubmitSvc.setBufferSize(MdmSubmitSvcImpl.DEFAULT_BUFFER_SIZE);
|
||||
super.after();
|
||||
}
|
||||
|
||||
|
@ -69,6 +70,7 @@ class MdmBatchSvcImplIT extends BaseMdmR4Test {
|
|||
assertLinkCount(0);
|
||||
|
||||
//SUT
|
||||
myMdmSubmitSvc.setBufferSize(5);
|
||||
afterMdmLatch.runWithExpectedCount(10, () -> myMdmSubmitSvc.submitSourceResourceTypeToMdm("Patient", null));
|
||||
|
||||
assertLinkCount(10);
|
||||
|
|
|
@ -78,4 +78,12 @@ public interface IMdmSubmitSvc {
|
|||
* @param theMdmSettings Settings to set
|
||||
*/
|
||||
void setMdmSettings(IMdmSettings theMdmSettings);
|
||||
|
||||
/**
|
||||
* Buffer size for fetching results to add to MDM queue.
|
||||
*
|
||||
* @param theBufferSize
|
||||
*/
|
||||
public void setBufferSize(int theBufferSize);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue