Azure / Azure/azure-service-bus-java

receiveMessages method with maxWaitTime not working as expected

Open
#414 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
62
Forks
63
PR merge metrics
No merged PRs in 30d

Description

## Actual Behavior
1. I am working on azure service bus and using ServiceBusReceiverClient.receiveMessages(int maxMessages, Duration maxWaitTime) method to receive the message from the service bus, my use case is to receive batch of messages in specific amount of time. But this is not working as expected it is not waiting for duration maxWaitTime.
2. it start the processing of the message as soon as one message is received.

**below is code snippet :**

`ServiceBusReceiverClient receiver = new ServiceBusClientBuilder()
.connectionString(connectionString)
.receiver()
.maxAutoLockRenewDuration(Duration.ofMinutes(1))
.queueName("<>")
.buildClient();
while (true) {

Iterator iterator = receiver.receiveMessages(10, Duration.ofMinutes(2)).iterator();
while (iterator.hasNext()) {
ServiceBusReceivedMessage serviceBusReceivedMessage = (ServiceBusReceivedMessage) iterator.next();
System.out.println("received message is ->"+serviceBusReceivedMessage.getBody());

}

}`

## Expected Behavior
1. it should wait for maximum number of messages to receive before it times out.

## Versions
- OS platform and version: NA
- Maven package version or commit ID: 7.0.2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.