@Override public void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions, ExecutorService executorService) throws InterruptedException, ServiceBusException { assertNonNulls(handler, handlerOptions, executorService); TRACE_LOGGER.info("Registering message handler on entity '{}' with '{}'", this.entityPath, handlerOptions); this.setHandlerRegistered(); this.messageHandler = handler; this.messageHandlerOptions = handlerOptions; this.customCodeExecutor = executorService; this.innerReceiver = ClientFactory.createMessageReceiverFromEntityPath(this.factory, this.entityPath, this.entityType, this.receiveMode); TRACE_LOGGER.info("Created MessageReceiver to entity '{}'", this.entityPath); if(this.prefetchCount != UNSET_PREFETCH_COUNT) { this.innerReceiver.setPrefetchCount(this.prefetchCount); } for (int i = 0; i < handlerOptions.getMaxConcurrentCalls(); i++) { this.receiveAndPumpMessage(); } }