如何在服务总线中实现并发性保证?

huangapple go评论84阅读模式
英文:

How to achieve guaranteed concurrency in service bus?

问题

我正在尝试在订阅服务总线的函数应用中实现一些确保的并发性。

为了实现这一目标,我已经在服务总线中实现了分区。

如果我的服务总线中的消息分发如下:

分区1	分区2	分区3
消息1	消息3	消息5
消息2	消息4	消息6

我期望我的函数应用调用顺序为:

消息1 --> 消息3 --> 消息5 --> 消息2 --> 消息4 --> 消息6

但实际情况并非如此。

我的 host.json 配置如下:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "maxConcurrentCalls": 1
    }
  },
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false,
        "excludedTypes": "Request"
      }
    }
  }
}

是否有任何方法可以实现这个目标?通过使用 sessionId 或事务吗?

英文:

I'm trying to achieve some guaranteed concurrency in function app which is subscribed to a service bus.

To achieve this, I've implemented partition in service bus.

If my message distribution in service bus is like this:

Partition1	Partition2	Partition3
message1	message3	mesaage5
message2	message4	message6

I expected my function app invocation serial to be :

message1 --> message3 -->message5 -->message2 -->message4-->message6

which is not happening.

My host.json configuration is

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "maxConcurrentCalls": 1
    }
  },
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false,
        "excludedTypes": "Request"
      }
    }
  }
}

Is there any way that I can achieve this? By using sessionId or transaction?

答案1

得分: 1

分区不是用于并发的。Azure Service Bus中的分区旨在确保在某些分区出现问题的情况下,不是所有消息都不可用,而是一些消息仍然可用。

您的配置中并发性设置为一。因此,您将从随机分区获取消息,逐个处理。如果您需要保证顺序,那将需要使用消息会话。事务处理适用于处理传入消息后生成的出站消息。

英文:

Partitioning is not intended for concurrency. Partitioning with Azure Service Bus is intended to ensure that in case some partitions are experiencing a problem, not all messages are not available but some.

Concurrency in your configuration is set to one. So you'll get messages from a random partition, processed one at a time. If you need a guaranteed order, that would be message sessions. Transactional processing is applicable for outgoing messages as a result of processing an incoming message.

huangapple
  • 本文由 发表于 2023年8月10日 12:44:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76872706.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定