简体   繁体   English

在不同的Azure服务总线队列中使用相同的消息ID导致错误

[英]Using the same message id in different Azure service bus queues causing errors

I'm having an issue with my function below that adds a scheduled message to a Azure service bus queue. 我在下面的函数中遇到问题,它将计划的消息添加到Azure服务总线队列。 The creation method poops out when calling the method 调用方法时,创建方法会消失

var sendCodeSequence = await queueClient.ScheduleMessageAsync(message, 
                                                              new DateTimeOffset(endTime));

and no exception is thrown up the stack in my controller even though the message gets added to the queue! 即使消息被添加到队列中,我的控制器中的堆栈也不会抛出异常!

My question? 我的问题?

  1. if I'm using the same message id multiple times across different queues all on the same service bus will I run into problems creating and deleting them on each queue, even though they all have different sequence ids? 如果我在同一服务总线上的不同队列中多次使用相同的消息ID,我会遇到在每个队列上创建和删除它们的问题,即使它们都有不同的序列ID吗?

  2. I'm using a message id in the the brokered message contructor and message id property, is this ok or will this cause issues of adding more and deleting them off the queues? 我在代理消息构造函数和消息ID属性中使用了消息ID,这是正常的还是会导致添加更多并将其从队列中删除的问题?

ex. 恩。 I have 5 different queues on the same service bus namespace. 我在同一个服务总线命名空间上有5个不同的队列。 And might add 5 different messages, one to each queue, all with the same brokered message id. 并且可以添加5个不同的消息,每个队列一个,所有消息都具有相同的代理消息ID。 So, don't know if this will cause any issues? 那么,不知道这是否会引起任何问题?

Here is a method I'm using to add a scheduled message to a queue using my event id as the message id 这是我用于将使用我的事件ID作为消息ID将预定消息添加到队列的方法

public async Task <long> CreateHostPointCodeMessage(int eventId, YogaSpaceDuration duration, DateTime utcEventDateTime) {
  string serviceBusConnectionString = System.Configuration.ConfigurationManager.AppSettings["ServiceBusConnectionString"];
  string queueName = System.Configuration.ConfigurationManager.AppSettings["PreEventPointsCodeQueueName"];

  var queueClient = QueueClient.CreateFromConnectionString(serviceBusConnectionString, queueName);
  int length = Convert.ToInt16(EnumHelper.GetDisplayName(duration).Split(' ')[0]);
  var endTime = DateTime.SpecifyKind(utcEventDateTime.AddMinutes(length).AddMinutes(-5), DateTimeKind.Utc);

  BrokeredMessage message = new BrokeredMessage(eventId.ToString());
  message.MessageId = eventId.ToString();
  message.ScheduledEnqueueTimeUtc = endTime;

  var sendCodeSequence = await queueClient.ScheduleMessageAsync(message, new DateTimeOffset(endTime));
  await queueClient.CloseAsync();

  return sendCodeSequence;
}

FYI - I'm using 'Microsoft.ServiceBus.Messaging' to send messages to the queue, but according to this MS article I should be using 'Microsoft.Azure.ServiceBus' I don't know if this makes any difference? 仅供参考 - 我使用'Microsoft.ServiceBus.Messaging'将消息发送到队列,但根据这篇MS文章,我应该使用'Microsoft.Azure.ServiceBus'我不知道这是否有任何区别?

There is nothing wrong in sending messages with same id to different Queues under a Namespace. 将具有相同ID的消息发送到命名空间下的不同队列没有任何问题。

Even you can send any number of messages with same id to the same Queue, unless RequiresDuplicateDetection property of the queue is set to "True". 即使您可以将具有相同ID的任意数量的消息发送到同一个队列,除非队列的RequiresDuplicateDetection属性设置为“True”。

Only for the Queues with "RequiresDuplicateDetection" property enabled, the messages with duplicate Id will be lost. 仅对启用了“RequiresDuplicateDetection”属性的队列,具有重复Id的消息将丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 MassTransit 发布到 Azure 服务总线导致错误 - Publish to Azure Service Bus using MassTransit is causing errors Azure 服务总线使用 .net sdk 按 ID 删除队列消息 - Azure service bus delete queue message by id using the .net sdk 使用存储队列和服务总线时,Azure 死信队列和毒药队列有什么区别? - What is the difference between Azure Dead Letter Queues and Poison Queues when using Storage Queue and Service Bus? MassTransit在天蓝色服务总线上创建队列 - MassTransit creates queues on azure service bus Windows Azure服务总线队列 - MessageSender或QueueClient? - Windows Azure Service Bus Queues - MessageSender or QueueClient? 使用Azure Service Bus创建队列的MassTransit 3 - MassTransit 3 with Azure Service Bus creating queues 在Azure Service Bus上调用Abandon会在队列的后面而不是队列的前面重新排队该消息 - Calling Abandon on an Azure Service Bus re-queues the message at the back rather than the front of the queue 从 .net 5 中的 Azure 服务总线队列获取消息 ID - Get message id from Azure Service Bus Queue in .net 5 同一服务总线队列消息多次运行的Azure函数 - Azure function running multiple times for the same service bus queue message Azure服务总线消息删除 - Azure Service Bus message deleting
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM