Source:
<code>private synchronized void receiveMessages() { if (receiverSubscription.get() != null) { receiverSubscription.get().request(1); return; } ServiceBusReceiverAsyncClient receiverClient = asyncClient.get(); receiverClient.receiveMessages() .parallel(processorOptions.getMaxConcurrentCalls()) .runOn(Schedulers.boundedElastic()) .subscribe(new Subscriber<ServiceBusReceivedMessageContext>() { @Override public void onSubscribe(Subscription subscription) { receiverSubscription.set(subscription); receiverSubscription.get().request(1); } @Override public void onNext(ServiceBusReceivedMessageContext serviceBusReceivedMessageContext) { if (serviceBusReceivedMessageContext.hasError()) { handleError(serviceBusReceivedMessageContext.getThrowable()); } else { try { ServiceBusProcessorMessageContext serviceBusProcessorMessageContext = new ServiceBusProcessorMessageContext(receiverClient, serviceBusReceivedMessageContext); processMessage.accept(serviceBusProcessorMessageContext); <START> } catch (Exception exception) { <END> handleError(exception); } } if (isRunning.get()) { logger.verbose("Requesting 1 more message from upstream"); receiverSubscription.get().request(1); } } @Override public void onError(Throwable throwable) { logger.info("Error receiving messages.", throwable); handleError(throwable); if (isRunning.get()) { restartMessageReceiver(); } } @Override public void onComplete() { logger.info("Completed receiving messages."); if (isRunning.get()) { restartMessageReceiver(); } } }); }</code><technical_language>If user's processHandler throw error want abandon message , abandoning message</technical_language>

Target:
private synchronized void receiveMessages() { if (receiverSubscription.get() != null) { receiverSubscription.get().request(1); return; } ServiceBusReceiverAsyncClient receiverClient = asyncClient.get(); receiverClient.receiveMessages() .parallel(processorOptions.getMaxConcurrentCalls()) .runOn(Schedulers.boundedElastic()) .subscribe(new Subscriber<ServiceBusReceivedMessageContext>() { @Override public void onSubscribe(Subscription subscription) { receiverSubscription.set(subscription); receiverSubscription.get().request(1); } @Override public void onNext(ServiceBusReceivedMessageContext serviceBusReceivedMessageContext) { if (serviceBusReceivedMessageContext.hasError()) { handleError(serviceBusReceivedMessageContext.getThrowable()); } else { try { ServiceBusProcessorMessageContext serviceBusProcessorMessageContext = new ServiceBusProcessorMessageContext(receiverClient, serviceBusReceivedMessageContext); processMessage.accept(serviceBusProcessorMessageContext); } catch (Exception ex) { handleError(ex); logger.warning("Error when processing message. Abandoning message.", ex); abandonMessage(serviceBusReceivedMessageContext, receiverClient); } } if (isRunning.get()) { logger.verbose("Requesting 1 more message from upstream"); receiverSubscription.get().request(1); } } @Override public void onError(Throwable throwable) { logger.info("Error receiving messages.", throwable); handleError(throwable); if (isRunning.get()) { restartMessageReceiver(); } } @Override public void onComplete() { logger.info("Completed receiving messages."); if (isRunning.get()) { restartMessageReceiver(); } } }); }