Source:
void transactionSendReceiveAndCommit(DispositionStatus dispositionStatus) { final MessagingEntityType entityType = MessagingEntityType.QUEUE; setSenderAndReceiver(entityType, TestUtils.USE_CASE_PEEK_TRANSACTION_SENDRECEIVE_AND_COMPLETE, isSessionEnabled); final String messageId1 = "transactionSendReceiveAndCommit"; final ServiceBusMessage message1 = getMessage(messageId1, isSessionEnabled); final String deadLetterReason = "test reason"; sendMessage(message1).block(TIMEOUT); AtomicReference<ServiceBusTransactionContext> transaction = new AtomicReference<>(); StepVerifier.create(receiver.createTransaction()) .assertNext(txn -> { transaction.set(txn); assertNotNull(transaction); }) .verifyComplete(); assertNotNull(transaction.get()); final ServiceBusReceivedMessageContext receivedContext = receiver.receive().next().block(TIMEOUT); assertNotNull(receivedContext); final ServiceBusReceivedMessage receivedMessage = receivedContext.getMessage(); assertNotNull(receivedMessage); final Mono<Void> operation; switch (dispositionStatus) { case COMPLETED: operation = receiver.complete(receivedMessage, transaction.get()); messagesPending.decrementAndGet(); break; case ABANDONED: operation = receiver.abandon(receivedMessage, null, transaction.get()); break; case SUSPENDED: DeadLetterOptions deadLetterOptions = new DeadLetterOptions().setDeadLetterReason(deadLetterReason); operation = receiver.deadLetter(receivedMessage, deadLetterOptions, transaction.get()); messagesPending.decrementAndGet(); break; case DEFERRED: operation = receiver.defer(receivedMessage, null, transaction.get()); break; default: throw logger.logExceptionAsError(new IllegalArgumentException( "Disposition status not recognized for this test case: " + dispositionStatus)); } StepVerifier.create(operation) .verifyComplete(); StepVerifier.create(receiver.commitTransaction(transaction.get())) .verifyComplete(); if (dispositionStatus == DispositionStatus.DEFERRED) { completeDeferredMessages(receiver, receivedMessage); } }

Target:
void transactionSendReceiveAndCommit(DispositionStatus dispositionStatus) { final MessagingEntityType entityType = MessagingEntityType.QUEUE; setSenderAndReceiver(entityType, TestUtils.USE_CASE_PEEK_TRANSACTION_SENDRECEIVE_AND_COMPLETE, isSessionEnabled); final String messageId1 = UUID.randomUUID().toString(); final ServiceBusMessage message1 = getMessage(messageId1, isSessionEnabled); final String deadLetterReason = "test reason"; sendMessage(message1).block(TIMEOUT); AtomicReference<ServiceBusTransactionContext> transaction = new AtomicReference<>(); StepVerifier.create(receiver.createTransaction()) .assertNext(txn -> { transaction.set(txn); assertNotNull(transaction); }) .verifyComplete(); assertNotNull(transaction.get()); final ServiceBusReceivedMessageContext receivedContext = receiver.receive().next().block(TIMEOUT); assertNotNull(receivedContext); final ServiceBusReceivedMessage receivedMessage = receivedContext.getMessage(); assertNotNull(receivedMessage); final Mono<Void> operation; switch (dispositionStatus) { case COMPLETED: operation = receiver.complete(receivedMessage, transaction.get()); messagesPending.decrementAndGet(); break; case ABANDONED: operation = receiver.abandon(receivedMessage, null, transaction.get()); break; case SUSPENDED: DeadLetterOptions deadLetterOptions = new DeadLetterOptions().setDeadLetterReason(deadLetterReason); operation = receiver.deadLetter(receivedMessage, deadLetterOptions, transaction.get()); messagesPending.decrementAndGet(); break; case DEFERRED: operation = receiver.defer(receivedMessage, null, transaction.get()); break; default: throw logger.logExceptionAsError(new IllegalArgumentException( "Disposition status not recognized for this test case: " + dispositionStatus)); } StepVerifier.create(operation) .verifyComplete(); StepVerifier.create(receiver.commitTransaction(transaction.get())) .verifyComplete(); if (dispositionStatus == DispositionStatus.DEFERRED) { messagesDeferredPending.add(receivedMessage.getSequenceNumber()); } }