Source:
private ServiceBusAsyncConsumer getOrCreateConsumer() { final ServiceBusAsyncConsumer existing = consumer.get(); if (existing != null) { return existing; } final String linkName = StringUtil.getRandomString(entityPath); logger.info("{}: Creating consumer for link '{}'", entityPath, linkName); final Flux<ServiceBusReceiveLink> receiveLink = connectionProcessor.flatMap(connection -> { if (receiverOptions.isSessionReceiver()) { return connection.createReceiveLink(linkName, entityPath, receiverOptions.getReceiveMode(), null, entityType, receiverOptions.getSessionId()); } else { return connection.createReceiveLink(linkName, entityPath, receiverOptions.getReceiveMode(), null, entityType); } }) .doOnNext(next -> { final String format = "Created consumer for Service Bus resource: mode: [{}]" + " sessionEnabled? transferEntityPath: [{}], entityType: [{}]"; logger.verbose(format, next.getEntityPath(), receiverOptions.getReceiveMode(), CoreUtils.isNullOrEmpty(receiverOptions.getSessionId()), "N/A", entityType); }) .repeat(); final AmqpRetryPolicy retryPolicy = RetryUtil.getRetryPolicy(connectionProcessor.getRetryOptions()); final ServiceBusReceiveLinkProcessor linkMessageProcessor = receiveLink.subscribeWith( new ServiceBusReceiveLinkProcessor(receiverOptions.getPrefetchCount(), retryPolicy, receiverOptions.getReceiveMode())); ServiceBusAsyncConsumer newConsumer = new ServiceBusAsyncConsumer(linkName, linkMessageProcessor, messageSerializer, receiverOptions, renewalContainer, this::renewMessageLock); if (consumer.compareAndSet(null, newConsumer)) { return newConsumer; } else { newConsumer.close(); return consumer.get(); } }

Target:
private ServiceBusAsyncConsumer getOrCreateConsumer() { final ServiceBusAsyncConsumer existing = consumer.get(); if (existing != null) { return existing; } final String linkName = StringUtil.getRandomString(entityPath); logger.info("{}: Creating consumer for link '{}'", entityPath, linkName); final Flux<ServiceBusReceiveLink> receiveLink = connectionProcessor.flatMap(connection -> { if (receiverOptions.isSessionReceiver()) { return connection.createReceiveLink(linkName, entityPath, receiverOptions.getReceiveMode(), null, entityType, receiverOptions.getSessionId()); } else { return connection.createReceiveLink(linkName, entityPath, receiverOptions.getReceiveMode(), null, entityType); } }) .doOnNext(next -> { final String format = "Created consumer for Service Bus resource: mode: [{}]" + " sessionEnabled? transferEntityPath: [{}], entityType: [{}]"; logger.verbose(format, next.getEntityPath(), receiverOptions.getReceiveMode(), CoreUtils.isNullOrEmpty(receiverOptions.getSessionId()), "N/A", entityType); }) .repeat(); final AmqpRetryPolicy retryPolicy = RetryUtil.getRetryPolicy(connectionProcessor.getRetryOptions()); final ServiceBusReceiveLinkProcessor linkMessageProcessor = receiveLink.subscribeWith( new ServiceBusReceiveLinkProcessor(receiverOptions.getPrefetchCount(), retryPolicy, receiverOptions.getReceiveMode())); final ServiceBusAsyncConsumer newConsumer = new ServiceBusAsyncConsumer(linkName, linkMessageProcessor, messageSerializer, receiverOptions); if (consumer.compareAndSet(null, newConsumer)) { return newConsumer; } else { newConsumer.close(); return consumer.get(); } }