Azure Service Bus – 自动删除空闲用例

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

Azure Service Bus - Auto-delete on idle use cases

问题

根据 Microsoft Docs:

"Auto-delete on idle" 允许您指定在队列或主题订阅空闲一段时间后自动删除它们。当实体上有流量时,间隔会被重置。最短持续时间为5分钟。

我也理解,这与消息生存时间(Message Time to Live)不同,因为它删除的是整个队列或主题订阅,而不是单个消息。

问题: 有哪些实际应用场景和用例中 "Auto-delete on idle" 会很有用?

英文:

According to Microsoft Docs:

>Auto-delete on idle enables you to specify an idle interval after which a queue or topic subscription is automatically deleted. The interval is reset when there is traffic on the entity. The minimum duration is 5 minutes.

I also understand, that this is not the same as Message Time to Live, because the whole queue or topic subscription is deleted, not a single message.

Question: What are some real life examples and use cases where Auto-delete on idle is useful?

答案1

得分: 1

你可以通过SDK创建队列或主题。

当您想处理一批项目时,您可以为此批次编程创建一个队列。这样做的好处是,例如,所有dlq项目将与其他批次分开。
批处理完成后,Auto-Delete将清理队列。

英文:

You can create queue's or topics through the SDK.

When you want to process a batch of items, you could create a queue programmatically for this batch. This has the advantage that for example all dlq items will remain separated from other batches.
After a the batch has been processed, the Auto-Delete will clean up the queue.

答案2

得分: 0

在临时消息传递(通常情况下)

当您需要设置临时队列或主题以满足短期通信场景,例如请求-响应模式或临时消息传递需求时,您可以使用自动删除空闲以在资源不再使用时自动清理资源。这有助于避免积累未使用的消息实体,减少管理开销,以及有助于成本管理。

在自动化测试中

如果您的项目使用定期执行的自动化测试,例如每周或每个发布周期,您可以以编程方式创建一个用于测试的队列。在这种情况下,您可以启用空闲时自动删除功能,以便测试队列将在所有测试结束后被删除,并且所有测试数据将被清除。

在定时任务中

Azure Function App计时器触发器允许您按计划运行特定的函数。例如,您有一个Function App,在每个月底从数据库中读取分析数据。然后,它将所有记录发送到Service Bus主题,从那里数据被许多外部服务接收。由于Function App只需要每月运行一次,因此不必一直保留主题和订阅 - 您可以启用空闲时自动删除功能,以保持Service Bus资源的清洁。

在动态扩展中

在根据工作负载动态扩展应用程序或服务的情况下,自动删除空闲可以很有用。当额外的应用程序或服务实例被启动以处理增加的负载时,它们可以创建用于处理消息的临时队列/主题。如果这些实例不再需要并处于空闲状态,自动删除空闲可以确保相关的消息实体被自动删除,以防止不必要的资源消耗。

英文:

In Temporary Messaging (in general)

When you need to set up temporary queues or topics for short-lived communication scenarios, such as request-response patterns or ephemeral messaging needs, you can use auto delete on idle to automatically clean up the resources when they are no longer in use. This helps to avoid accumulating unused messaging entities and reduces management overhead, as well as it helps with cost management.

In Automated Testing

If your project is using Automated Tests, which are scheduled every week or every release, you can create a queue programmatically which will be used for tests. In such case, you can enable Auto-delete on idle feature, so the testing queue will be deleted after all tests will end and all test data will be erased.

In Scheduled Tasks

Azure Function App timer trigger allows you to run specific function on schedule. For example, you have Function App which reads analytic data from database at the end of every month. Then, it sends all records to Service Bus topic, from where data is picked up by many external services. Since Function App needs to be run only once a month, keeping topics and subscriptions for it all the time is not necessary - you can enable Auto-delete on idle feature, to keep your Service Bus resources clean.

In Dynamic Scaling

In scenarios where you dynamically scale your application or services based on workload, auto-delete on idle can be useful. When additional instances of your application or service are spun up to handle increased load, they can create temporary queues/topics for processing messages. If those instances are no longer needed and become idle, auto-delete on idle can ensure that the associated messaging entities are automatically removed, preventing unnecessary resource consumption.

huangapple
  • 本文由 发表于 2023年5月21日 21:46:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76300209.html
匿名

发表评论

匿名网友

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

确定