通过订阅在本地测试Azure Service Bus队列 [英] Test Azure Service Bus Queues Locally with a subscription

查看:107
本文介绍了通过订阅在本地测试Azure Service Bus队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在本地测试Azure Service Bus队列?

How does one test Azure Service Bus Queues Locally?

1.我必须将Queue重命名为其他名称,因为其他一些开发人员或已经运行的功能可能会使用它

1.I have to rename our Queue to something else, as some other developers or already running function may consume it

Example: 

a) Original Queue: Product

b) Test Queue: Test

2.我们还具有Azure功能来拾取队列,因此也要重命名服务总线触发器.

2.We also have Azure functions picking up queues, so also rename the Service Bus Trigger.

但是,它仍然无法正常工作吗?

However, its still not working?

是否需要更改其他内容?

Does Anything else need to be changed?

我看到队列消息是通过Service Bus Explorer发送的,但是它们不是事件句柄,也不是我们的流程动作所响应.

I see Queue messages being sent with Service Bus Explorer, but they are not being event handle or responded with our process action.

[FunctionName(nameof(TestAsync))]
public async Task TestRollAsync(
[ServiceBusTrigger("test", Connection = "ServiceBusConnection", IsSessionsEnabled = false)] Message sbMessage)
{
    var cmessage = Encoding.UTF8.GetString(sbMessage.Body);
    Test msg = null;

    try
    {
        msg = JsonConvert.DeserializeObject<Test>(cmessage);
    }

推荐答案

重命名队列不是最方便的方法,因为在提交代码时将需要撤消更改,这很容易出错.更好的选择是使用特定于开发人员的Azure服务总线名称空间,该名称空间可以使用MSDN/公司帐户在标准层上进行配置.您可以根据需要在标准层上具有多个名称空间.在配置和不使用其他名称空间时,除了每月10美元的服务费(或您的货币的等值金额)外,该服务不涉及其他任何费用.

Renaming the queue is not the most convenient way as it will require to undo the changes when you commit the code and that's error-prone. A better option would be to use a developer-specific Azure Service Bus namespace that can be provisioned on a standard tier, using MSDN/company account. You can have as many namespaces on the standard tier as needed. There's no cost involved for the service other than $10 a month for the service (or the equivalent for your currency) when additional namespaces are provisioned and not used.

每个开发人员都有一个命名空间,您的代码保持不变,并且可以在本地的settings.json文件中更改连接字符串(值),并且不应将其提交到存储库.这样,队列名称和连接字符串名称将保持不变,您可以在本地进行开发/调试

With a namespace per developer, your code stays as-is, and the connection string (the value) can be changed in the settings.json file that is local and should not be committed to the repository. That way the queue name and connection string name remain untouched and you can develop/debug locally

这篇关于通过订阅在本地测试Azure Service Bus队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆