reactor.core.publisher.TopicProcessor Java Examples

The following examples show how to use reactor.core.publisher.TopicProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactorProxies.java    From RHub with Apache License 2.0 4 votes vote down vote up
public static ReactorProcProxy topicProcessorProxy() {
    return new ReactorProcProxy(TopicProcessor.create(), PASS);
}
 
Example #2
Source File: ReactorProxies.java    From RHub with Apache License 2.0 4 votes vote down vote up
public static ReactorProcProxy serializedTopicProcessorProxy() {
    return new ReactorProcProxy(TopicProcessor.create().serialize(), PASS);
}
 
Example #3
Source File: ReactorProxies.java    From RHub with Apache License 2.0 4 votes vote down vote up
public static ReactorProcProxy safeTopicProcessorProxy() {
    return new ReactorProcProxy(TopicProcessor.create(), WRAP);
}
 
Example #4
Source File: ReactorProxies.java    From RHub with Apache License 2.0 4 votes vote down vote up
public static ReactorProcProxy safeSerializedTopicProcessorProxy() {
    return new ReactorProcProxy(TopicProcessor.create().serialize(), WRAP);
}
 
Example #5
Source File: ReactiveStepMetadataRepository.java    From data-prep with Apache License 2.0 4 votes vote down vote up
public ReactiveStepMetadataRepository(StepMetadataRepository delegate, SecurityProxy proxy) {
    this.delegate = delegate;

    final TopicProcessor<InvalidateMessage> invalidateFlux = TopicProcessor.create();
    final TopicProcessor<UpdateMessage> updateFlux = TopicProcessor.create();
    invalidateFlux.subscribe(invalidateMessage -> {
        LOGGER.debug("Delayed invalidate of step #{}.", invalidateMessage.stepId);
        try {
            TenancyContextHolder.setContext(invalidateMessage.context);
            proxy.asTechnicalUser();
            delegate.invalidate(invalidateMessage.stepId);
        } finally {
            proxy.releaseIdentity();
            TenancyContextHolder.clearContext();
        }
        LOGGER.debug("Delayed invalidate of step #{} done.", invalidateMessage.stepId);
    });
    updateFlux.subscribe(updateMessage -> {
        LOGGER.debug("Delayed update of step #{}.", updateMessage.stepId);
        try {
            TenancyContextHolder.setContext(updateMessage.context);
            proxy.asTechnicalUser();
            delegate.update(updateMessage.stepId, updateMessage.rowMetadata);
        } catch (Exception e) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Unable to update step metadata for step #{}.", updateMessage.stepId, e);
            } else {
                LOGGER.error("Unable to update step metadata for step #{}.", updateMessage.stepId);
            }
        } finally {
            proxy.releaseIdentity();
            TenancyContextHolder.clearContext();
        }
        LOGGER.debug("Delayed update of step #{} done.", updateMessage.stepId);
    });

    invalidates = invalidateFlux.connectSink();
    updates = updateFlux.connectSink();

    LOGGER.info("Using asynchronous step row metadata update.");
}