Azure / Azure/azure-service-bus-java
Error: 2 messages in DeadLetter if one message isn't completed / closed by IMessageReceiver...
- Dominant language
- Java
- Stars
- 62
- Forks
- 63
- PR merge metrics
- No merged PRs in 30d
Description
## Actual Behavior
1. Two messages are going in DeadLetter instead of one message if not closed IMessageReceiver
Please find the below code.
Say I have 5 messages (A,B,C,D,E) in my subscriber available for consumption;
I start consuming message A and neither I call `complete` on the message nor `close` the receiver.
I should expect message A to appear in the DeadLetter after the given operation time out, however, I am seeing 2 messages, A and B both, in the DeadLetter on my Service Bus.
Is this a bug or I am missing something obvious here?
## Code:
```
import java.time.Duration;
import com.microsoft.azure.servicebus.ClientFactory;
import com.microsoft.azure.servicebus.IMessage;
import com.microsoft.azure.servicebus.IMessageReceiver;
import com.microsoft.azure.servicebus.ReceiveMode;
import com.microsoft.azure.servicebus.primitives.ConnectionStringBuilder;
import com.microsoft.azure.servicebus.primitives.ServiceBusException;
public class TopicReceiveExample {
private static final String connectionString = "Endpoint=######";
private static final String subscriptionName = "####-topic/subscriptions/####-sub";
private static ConnectionStringBuilder connectionStringBuilder;
IMessageReceiver receiver;
public static void main(String[] args) throws InterruptedException, ServiceBusException {
connectionStringBuilder = new ConnectionStringBuilder(connectionString, subscriptionName);
IMessageReceiver receiver = ClientFactory.createMessageReceiverFromConnectionStringBuilder(connectionStringBuilder, ReceiveMode.PEEKLOCK);
IMessage message = receiver.receive(Duration.ofSeconds(10));
System.out.println("Message Content :: "+ new String(message.getBody()));
//
//receiver.complete(message.getLockToken());
//receiver.close();
}
}
```
## Expected Behavior
1. Only message A should go in DeadLetter
## Actual Behavior
1. message A and B both are pushed to the DeadLetter
## Environment
Windows 8
- Maven package : com.microsoft.azure :: azure-servicebus :: 1.1.1
## Any more information needed here???
This behavior is making me bonkers already and need assistance;
Contributor guide
Assessment
This issue has not been assessed yet.