Azure Service Bus主题超时异常 [英] Azure Service Bus Topic Timeout exception

查看:82
本文介绍了Azure Service Bus主题超时异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此博客文章上给出的代码为Azure Service Bus主题构建POC:

I am building a POC for Azure Service Bus Topics using the code given on this blog post: http://blogs.msdn.com/b/tomholl/archive/2011/10/09/using-service-bus-topics-and-subscriptions-with-wcf.aspx However, I am getting following error.

System.TimeoutException:请求已在00:00:00毫秒后超时.无法确定请求的成功完成.应该进行其他查询以确定该操作是否成功.

System.TimeoutException: The request has timed out after 00:00:00 milliseconds. The successful completion of the request cannot be determined. Additional queries should be made to determine whether or not the operation has succeeded.

我已经按照链接完成了所有操作.这是我的代码,我在此行上收到错误:((IChannel)clientChannerl).Open();

I have done everything as per the Link. Here is my Code, I receive error on this line: ((IChannel)clientChannerl).Open();

        var accountEventLog = new AccountEventLog()
        {
            AccountId = 123,
            EventType = "BE",
            Date = DateTime.Now
        };

        ChannelFactory<IAccountEventNotification> factory = null;
        try
        {
            factory = new ChannelFactory<IAccountEventNotification>("Subscribers");
            var clientChannerl = factory.CreateChannel();
            ((IChannel)clientChannerl).Open();

            using (new OperationContextScope((IContextChannel)clientChannerl))
            {
                var bmp = new BrokeredMessageProperty();
                bmp.Properties["AccountId"] = accountEventLog.AccountId;
                bmp.Properties["EventType"] = accountEventLog.EventType;
                bmp.Properties["Date"] = accountEventLog.Date;
                OperationContext.Current.OutgoingMessageProperties.Add(BrokeredMessageProperty.Name, bmp);

                clientChannerl.onEventOccurred(accountEventLog);
            }

            ((IChannel)clientChannerl).Close();
            factory.Close();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }

这是我的配置设置

    <behaviors>
      <endpointBehaviors>
        <behavior name="securityBehavior">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <sharedSecret issuerName="RootManageSharedAccessKey" issuerSecret="Shared Key Here" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
      </endpointBehaviors>
    </behaviors>      
    <bindings>
      <netMessagingBinding>
        <binding name="messagingBinding" sendTimeout="00:03:00" receiveTimeout="00:03:00"
                  openTimeout="00:03:00" closeTimeout="00:03:00" sessionIdleTimeout="00:01:00"
                  prefetchCount="-1">
          <transportSettings batchFlushInterval="00:00:01" />
        </binding>
      </netMessagingBinding>
    </bindings>
    <client>
      <endpoint name="Subscribers"
                address="sb://Namespace/topicname"
                binding="netMessagingBinding"
                bindingConfiguration="messagingBinding"
                contract="My Contract"
                behaviorConfiguration="securityBehavior" />
    </client>

我们将不胜感激任何帮助

Any help will be highly appreciated

推荐答案

我能够解决此问题.但是,我将描述我在整个练习中学到的东西.

I am able to resolve the issue. However, I am going to describe what I learned in this whole exercise.

  1. 行为中添加的令牌提供者用于通过ACS(活动目录服务)进行服务总线身份验证
  2. 默认情况下,使用Azure Portal创建的
  3. 命名空间不会创建ACS终结点/ACS身份验证.创建名称空间时,默认情况下仅创建SAS(共享访问签名).
  4. 要使用SAS令牌对您的wcf呼叫进行身份验证,请使用以下令牌提供程序:< sharedAccessSignature keyName ="RootManageSharedAccessKey" key ="密钥"/>
  5. 如果要使用ACS身份验证,请使用Azure Power Shell创建名称空间.以下是PS命令,用于创建启用了ACS身份验证的命名空间:

  1. The token provider added in the behavior is used for Service Bus Authentication with ACS (Active Directory Service)
  2. Namespaces created using Azure Portal don't create an ACS endpoint/ACS authentication by default. When you create a namespace it only creates SAS (Shared Access Signature) by default.
  3. To Authenticate your wcf call with SAS use this Token provider: <sharedAccessSignature keyName="RootManageSharedAccessKey" key="key" />
  4. In case you want to use ACS authentication then create namespace using Azure Power Shell. Following is the PS command to create Namespace with ACS Authentication enabled:

New-AzureSBNamespace名称空间"美国东部" -CreateACSNamespace $ true -NamespaceType消息

New-AzureSBNamespace "Namespace" "East US" -CreateACSNamespace $true -NamespaceType Messaging

因此,为了解决我的问题,我使用了上述的Point 3,它开始起作用.

So to resolve my issue I used the Point 3 described above and it started working.

这篇关于Azure Service Bus主题超时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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