简体   繁体   English

如何从Azure服务总线队列到多个主题协调事件?

[英]how to Orchestrate an event from azure service bus queue to multiple topics?

in my application I have a scenario where there are events are continuously generated, each event is associated with a type. 在我的应用程序中,我有一个场景,其中连续生成事件,每个事件都与一种类型相关联。

For every event multiple sub actions depending on the type need to be performed which are totally independent. 对于每个事件,根据类型需要执行多个完全独立的子动作。

So for this scenario solution which I thought of is to use Queue along with topics as below 因此,对于此场景解决方案,我想到的是将Queue与以下主题一起使用

Event generator ---> Queue -----> Orchestrator --------> topics <----- Listeners 事件生成器--->队列-----> 协调器 -------->主题<-----侦听器

to implement the above there is a need to have an orchestrator which gets the events from the queue and apply some logic and insert into topics . 为了实现上述目的,需要一个协调器,该协调器从队列中获取事件,并应用一些逻辑并插入主题。

Can any one suggest any good component for the orchestrator on azure ? 有人能为协调器提出任何好的建议吗?

Orchestrator should be able to handle load(Spikes are expected) - As we are using queues processing an event need not be a realtime it can be a delayed based on the load. Orchestrator应该能够处理负载(预计会有峰值) -由于我们正在使用队列处理事件,因此事件不必是实时的,它可以根据负载而延迟。

I have two options for you. 我有两个选择给你。

I. Service Bus forwarding 一,业务总线转发

If the rules of forwarding are straightforward (eg based on a property value), you can setup this with Service Bus filterer subscriptions and forwarding. 如果转发规则很简单(例如,基于属性值),则可以使用Service Bus过滤器订阅和转发进行设置。

You create an ingress topic which will get all the messages. 您创建一个将获取所有消息的入口主题。 Then you create a subscription for this topic per each type of message, and you apply a filter for that subscription to filter out all the other types. 然后,您为每种消息类型为此主题创建一个订阅,然后对该订阅应用一个过滤器以过滤掉所有其他类型。 You then setup the forward rule to send the messages to the appropriate outgoing topic: 然后,您设置转发规则,以将消息发送到适当的传出主题:

var description = new SubscriptionDescription("IngressTopic", "Type1");
description.ForwardTo = "SinkType1Topic";
SqlFilter filter = new SqlFilter("Type = 1");
namespaceManager.CreateSubscription(description, filter);

where Type is the property in your message. 其中Type是消息中的属性。 You repeat this for each type. 对每种类型重复此操作。

II. 二。 Azure Function Azure功能

If you need to run your custom code to determine which outgoing topic the message belongs to, you can run this custom code as Azure Function. 如果需要运行自定义代码来确定邮件属于哪个传出主题,则可以将此自定义代码作为Azure Function运行。 Just make an ingress queue, and create a Function which will listen to this queue, receive the message and forward it to the appropriate outgoing topic: 只需创建一个入口队列,然后创建一个函数即可侦听此队列,接收消息并将其转发到适当的传出主题:

public static void Run(MyMessage message, IBinder binder)
{
    string outgoingTopic = message.CalculateOutgoingTopic();
    var attribute = new ServiceBusAttribute(outgoingTopic);
    var collector = binder.Bind<ICollector<MyMessage>>(attribute);
    collector.Add(message);
}

Azure Functions are good for handling spiky load. Azure函数非常适合处理尖峰负载。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM