I have a C# code to send a message to the service bus topic as follows:
public class ServiceBusTopicsRepository : IServiceBusTopicsRepository
{
private TopicClient _topicClient;
public ServiceBusTopicsRepository(string connectionString, string entityPath)
{
_topicClient = new TopicClient(connectionString, entityPath);
}
public async Task AddMessageAsync(SyncJob job)
{
await _topicClient.SendAsync(CreateMessage(job));
}
private Message CreateMessage(SyncJob job)
{
var body = JsonSerializer.Serialize(job);
var message = new Message
{
Body = Encoding.UTF8.GetBytes(body)
};
message.MessageId = "PK_RK";
return message;
}
}
On running the code, when it hits the breakpoint after line:
await _topicClient.SendAsync(CreateMessage(job));
I see message is not being added to the topic all the time when I execute the code.
DuplicateDetectionHistoryTimeWindow is 10 min
When I try to send message after 12 minutes, I see newly sent message is instantly ignored and dropped. Looking at this doc https://learn.microsoft.com/en-us/azure/service-bus-messaging/duplicate-detection, I see that if any new message is sent with MessageId that was logged during the time window (10 min), the message is reported as accepted (the send operation succeeds), but the newly sent message is instantly ignored and dropped. However, it looks like it ignoring the message even after 10 min.
I tried updating the MessageId to "PK_RK" + random GUID. I still see the same issue.