|
|
|
|
@ -38,6 +38,7 @@ import org.springframework.core.KotlinDetector;
@@ -38,6 +38,7 @@ import org.springframework.core.KotlinDetector;
|
|
|
|
|
import org.springframework.core.ReactiveAdapter; |
|
|
|
|
import org.springframework.core.ReactiveAdapterRegistry; |
|
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
|
import org.springframework.scheduling.SchedulingAwareRunnable; |
|
|
|
|
import org.springframework.scheduling.support.DefaultScheduledTaskObservationConvention; |
|
|
|
|
import org.springframework.scheduling.support.ScheduledTaskObservationContext; |
|
|
|
|
import org.springframework.scheduling.support.ScheduledTaskObservationConvention; |
|
|
|
|
@ -120,8 +121,10 @@ abstract class ScheduledAnnotationReactiveSupport {
@@ -120,8 +121,10 @@ abstract class ScheduledAnnotationReactiveSupport {
|
|
|
|
|
|
|
|
|
|
boolean shouldBlock = (scheduled.fixedDelay() > 0 || StringUtils.hasText(scheduled.fixedDelayString())); |
|
|
|
|
Publisher<?> publisher = getPublisherFor(method, targetBean); |
|
|
|
|
Supplier<ScheduledTaskObservationContext> contextSupplier = () -> new ScheduledTaskObservationContext(targetBean, method); |
|
|
|
|
return new SubscribingRunnable(publisher, shouldBlock, subscriptionTrackerRegistry, observationRegistrySupplier, contextSupplier); |
|
|
|
|
Supplier<ScheduledTaskObservationContext> contextSupplier = |
|
|
|
|
() -> new ScheduledTaskObservationContext(targetBean, method); |
|
|
|
|
return new SubscribingRunnable(publisher, shouldBlock, scheduled.scheduler(), |
|
|
|
|
subscriptionTrackerRegistry, observationRegistrySupplier, contextSupplier); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -180,30 +183,43 @@ abstract class ScheduledAnnotationReactiveSupport {
@@ -180,30 +183,43 @@ abstract class ScheduledAnnotationReactiveSupport {
|
|
|
|
|
* Utility implementation of {@code Runnable} that subscribes to a {@code Publisher} |
|
|
|
|
* or subscribes-then-blocks if {@code shouldBlock} is set to {@code true}. |
|
|
|
|
*/ |
|
|
|
|
static final class SubscribingRunnable implements Runnable { |
|
|
|
|
static final class SubscribingRunnable implements SchedulingAwareRunnable { |
|
|
|
|
|
|
|
|
|
private final Publisher<?> publisher; |
|
|
|
|
private static final ScheduledTaskObservationConvention DEFAULT_CONVENTION = |
|
|
|
|
new DefaultScheduledTaskObservationConvention(); |
|
|
|
|
|
|
|
|
|
private static final ScheduledTaskObservationConvention DEFAULT_CONVENTION = new DefaultScheduledTaskObservationConvention(); |
|
|
|
|
private final Publisher<?> publisher; |
|
|
|
|
|
|
|
|
|
final boolean shouldBlock; |
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
private final String qualifier; |
|
|
|
|
|
|
|
|
|
private final List<Runnable> subscriptionTrackerRegistry; |
|
|
|
|
|
|
|
|
|
final Supplier<ObservationRegistry> observationRegistrySupplier; |
|
|
|
|
|
|
|
|
|
final Supplier<ScheduledTaskObservationContext> contextSupplier; |
|
|
|
|
|
|
|
|
|
SubscribingRunnable(Publisher<?> publisher, boolean shouldBlock, List<Runnable> subscriptionTrackerRegistry, |
|
|
|
|
Supplier<ObservationRegistry> observationRegistrySupplier, Supplier<ScheduledTaskObservationContext> contextSupplier) { |
|
|
|
|
SubscribingRunnable(Publisher<?> publisher, boolean shouldBlock, |
|
|
|
|
@Nullable String qualifier, List<Runnable> subscriptionTrackerRegistry, |
|
|
|
|
Supplier<ObservationRegistry> observationRegistrySupplier, |
|
|
|
|
Supplier<ScheduledTaskObservationContext> contextSupplier) { |
|
|
|
|
|
|
|
|
|
this.publisher = publisher; |
|
|
|
|
this.shouldBlock = shouldBlock; |
|
|
|
|
this.qualifier = qualifier; |
|
|
|
|
this.subscriptionTrackerRegistry = subscriptionTrackerRegistry; |
|
|
|
|
this.observationRegistrySupplier = observationRegistrySupplier; |
|
|
|
|
this.contextSupplier = contextSupplier; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Nullable |
|
|
|
|
public String getQualifier() { |
|
|
|
|
return this.qualifier; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
Observation observation = TASKS_SCHEDULED_EXECUTION.observation(null, DEFAULT_CONVENTION, |
|
|
|
|
|