Hi,

I've been using the following code for creating an executor service that 
discards the oldest invocations when the queue is full.

ThreadPoolBuilder poolBuilder = new ThreadPoolBuilder(getContext());
singleSplitExecutorService = 
poolBuilder.poolSize(1).maxPoolSize(1).maxQueueSize(200)
        .rejectedPolicy(ThreadPoolRejectedPolicy.DiscardOldest)
        .build("singleSplitExecutorService");

Then I'm using that executor service in a wiretap:


.wireTap(split(getMessageSplitRouteId())).executorService(singleSplitExecutorService)

During migrating to Camel 4 I noticed, that Discard and DiscardOldest has been 
removed and only Abort and CallerRuns are available now. However with 
CallerRuns the ordering of invocations wouldn't be correct anymore in case the 
queue is full and with Abort I'd have unwanted exceptions causing our routes to 
stop processing data.

Is there a suggested alternative way to achieve the same functionality?
Why has it been removed from camel in the first place? Java 17 still comes with 
a default implementation of the RejectedExecutionHandler for discarding, so I 
don't see a reason for that.

I know that I can create the executor service myself with plain Java, but I 
still wanted to ask if I'm missing something in Camel APIs.

Jannik

Reply via email to