use of com.evolveum.midpoint.provisioning.impl.shadows.ShadowedAsyncChange in project midpoint by Evolveum.
the class AsyncUpdater method processAsynchronousUpdates.
public void processAsynchronousUpdates(ResourceShadowCoordinates shadowCoordinates, AsyncUpdateEventHandler handler, Task callerTask, OperationResult callerResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, ExpressionEvaluationException {
InternalMonitor.recordCount(InternalCounters.PROVISIONING_ALL_EXT_OPERATION_COUNT);
ProvisioningContext globalContext = ctxFactory.createForCoordinates(shadowCoordinates, callerTask, callerResult);
// This is a bit of hack to propagate information about async update channel to upper layers
// e.g. to implement MID-5853. TODO fix this hack
globalContext.setChannelOverride(SchemaConstants.CHANNEL_ASYNC_UPDATE_URI);
IndividualEventsAcknowledgeGate<AsyncUpdateEvent> acknowledgeGate = new IndividualEventsAcknowledgeGate<>();
ResourceObjectAsyncChangeListener listener = (resourceObjectChange, lTask, lResult) -> {
ShadowedAsyncChange change = new ShadowedAsyncChange(resourceObjectChange, changeProcessingBeans);
change.initialize(lTask, lResult);
AsyncUpdateEvent event = new AsyncUpdateEventImpl(change) {
@Override
public void acknowledge(boolean release, OperationResult result) {
LOGGER.trace("Acknowledgement (release={}) sent for {}", release, this);
change.acknowledge(release, result);
acknowledgeGate.acknowledgeIssuedEvent(this);
}
};
acknowledgeGate.registerIssuedEvent(event);
try {
handler.handle(event, lResult);
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Got unexpected exception while handling an async update event", t);
acknowledgeGate.acknowledgeIssuedEvent(event);
}
};
resourceObjectConverter.listenForAsynchronousUpdates(globalContext, listener, callerResult);
// There may be some events in processing - for example, if the async update task is suspended while
// receiving a lot of events.
acknowledgeGate.waitForIssuedEventsAcknowledge(callerResult);
}
Aggregations