public SubscriptionWorkerConfig withBatchSize(final int batchSize) { return new SubscriptionWorkerConfig( batchSize, this.initialRetryDelayMillis, this.maxRetryDelayMillis); }
public SubscriptionWorkerConfig withBatchSize(final int batchSize) { return new SubscriptionWorkerConfig( batchSize, this.initialRetryDelayMillis, this.maxRetryDelayMillis); }
public SubscriptionWorkerConfig withMaxRetryDelayMillis(final int millis) { return new SubscriptionWorkerConfig(this.batchSize, initialRetryDelayMillis, millis); } }
public SubscriptionWorkerConfig withMaxRetryDelayMillis(final int millis) { return new SubscriptionWorkerConfig(this.batchSize, initialRetryDelayMillis, millis); } }
public SubscriptionWorkerConfig withInitialRetryDelayMillis(final int millis) { return new SubscriptionWorkerConfig(this.batchSize, millis, this.maxRetryDelayMillis); }
public SubscriptionWorkerConfig withInitialRetryDelayMillis(final int millis) { return new SubscriptionWorkerConfig(this.batchSize, millis, this.maxRetryDelayMillis); }
/** * Creates a new subscription from a subscription handler, receiving all events from the event * streams that the subscription factory represents. Note that the subscription when returned is * not yet active and must be started by calling start() to receive events. * * @param handler The handler called to process batches of events. */ default EventSubscription fromSubscriptionHandler(final EventSubscriptionHandler<T> handler) { return fromSubscriptionHandler( handler, new SubscriptionWorkerConfig().withBatchSize(256)); }
/** * Creates a new subscription from a subscription handler, receiving all events from the event * streams that the subscription factory represents. Note that the subscription when returned is * not yet active and must be started by calling start() to receive events. * * @param handler The handler called to process batches of events. */ default EventSubscription fromSubscriptionHandler(final EventSubscriptionHandler<T> handler) { return fromSubscriptionHandler( handler, new SubscriptionWorkerConfig().withBatchSize(256)); }
/** * Creates a new subscription from a subscription handler, receiving all events from the event * streams that the subscription factory represents. Note that the subscription when returned is * not yet active and must be started by calling start() to receive events. * * @param handler The handler called to process batches of events. * @param batchSize The maximum number of items to process in each update. */ default EventSubscription fromSubscriptionHandler( EventSubscriptionHandler<T> handler, int batchSize) { return fromSubscriptionHandler( handler, new SubscriptionWorkerConfig().withBatchSize(batchSize)); }
/** * Creates a new subscription from a subscription handler, receiving all events from the event * streams that the subscription factory represents. Note that the subscription when returned is * not yet active and must be started by calling start() to receive events. * * @param handler The handler called to process batches of events. * @param batchSize The maximum number of items to process in each update. */ default EventSubscription fromSubscriptionHandler( EventSubscriptionHandler<T> handler, int batchSize) { return fromSubscriptionHandler( handler, new SubscriptionWorkerConfig().withBatchSize(batchSize)); }
@Test @Ignore // Manual only public void testRetriesOnHandlerErrorWithBackoff() { EventRepository<String> repository = mock(EventRepository.class); EventSubscriptionPositionSource positionSource = mock(EventSubscriptionPositionSource.class); when(repository.getPublisher(any())).then(position -> { WorkQueueProcessor<EventRecord<String>> processor = WorkQueueProcessor.create(); Flux<EventRecord<String>> eventSource = Flux .fromStream(IntStream.range(0, 1000000).mapToObj(this::wrapIntAsEvent)) .doOnNext(e -> { lastProducedValue = e.getEvent(); }); eventSource.subscribe(processor); return processor; }); when(positionSource.getSubscriptionPosition()).thenReturn(null); ErroringSubscriptionHandler<String> subscriptionHandler = new ErroringSubscriptionHandler<>(0); EventSubscriptionManager subscriptionManager = new EventSubscriptionManager<>( repository, positionSource, subscriptionHandler, new SubscriptionWorkerConfig().withBatchSize(64)); SubscriptionToken token = subscriptionManager.start(); sleep(100000); token.stop(); }
positionSource, subscriptionHandler, new SubscriptionWorkerConfig().withBatchSize(64));
positionSource, subscriptionHandler, new SubscriptionWorkerConfig().withBatchSize(64));
@Test @Ignore // Manual only public void testRetriesOnStreamError() { EventRepository<String> repository = mock(EventRepository.class); EventSubscriptionPositionSource positionSource = mock(EventSubscriptionPositionSource.class); when(repository.getPublisher(any())).then(position -> { WorkQueueProcessor<EventRecord<String>> processor = WorkQueueProcessor.create(); Flux<EventRecord<String>> eventSource = Flux .fromStream(IntStream.range(0, 1000000).mapToObj(this::wrapIntAsEvent)) .doOnNext(e -> { lastProducedValue = e.getEvent(); }); eventSource.subscribe(processor); return processor.take(100).thenMany(Flux.error(new RuntimeException("fail!"))); }); when(positionSource.getSubscriptionPosition()).thenReturn(null); SlowSubscriptionHandler<String> subscriptionHandler = new SlowSubscriptionHandler<>(); EventSubscriptionManager subscriptionManager = new EventSubscriptionManager<>( repository, positionSource, subscriptionHandler, new SubscriptionWorkerConfig().withBatchSize(64)); SubscriptionToken token = subscriptionManager.start(); sleep(100000); token.stop(); }