0
votes

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 within 10 minutes, I see newly sent message is instantly ignored and dropped. Looking at this doc https://docs.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. So, I tried updating the MessageId to "PK_RK" + random GUID. I still see the same issue. What am I missing?

1

1 Answers

0
votes

The issue is not reproduced with the official service bus SDKs. The scenario is working as expected. If anyone is facing the issue please tag me in so I can look into the source code, configuration, and if there is any issue with the backend.

Similar post: https://github.com/MicrosoftDocs/azure-docs/issues/71585 https://docs.microsoft.com/en-us/answers/questions/301303/index.html