【问题标题】:Windows Service Bus 1.0, Appfabric, Netmessagingbinding failuringWindows 服务总线 1.0、Appfabric、Netmessaging 绑定失败
【发布时间】:2012-12-09 15:34:53
【问题描述】:

当我尝试在 Windows Server AppFabric 中托管 WCF 服务时,我似乎一遍又一遍地遇到同样的问题,该服务使用 netmessagingbinding 从 Windows Service Bus 1.0 队列接收消息。 AppFabric 中止服务,所以如果我在 service?wsdl 上按 F5,那么有时我会失败,有时我会生成一个不错的 WSDL。我的错误在哪里?很难找到使用 AppFabric、netmessagingbinding 和 Windows 服务总线(不是 Azure)的示例,所以我一直无法找到我的错误......

[ServiceContract]
public interface ISBMessageService
{
    [OperationContract(IsOneWay = true, Action = "DoSomething")]
    [ReceiveContextEnabled(ManualControl = true)]
    void DoSomething(string something);
}

[ServiceBehavior]
public class SBMessageService : ISBMessageService
{
    [OperationBehavior]
    public void DoSomething(string something)
    {
        Trace.WriteLine(String.Format("You sent {0}", something));

        // Get the BrokeredMessageProperty from the current OperationContext
        var incomingProperties = OperationContext.Current.IncomingMessageProperties;
        var property = incomingProperties[BrokeredMessageProperty.Name] as BrokeredMessageProperty;

        ReceiveContext receiveContext;

        if (ReceiveContext.TryGet(incomingProperties, out receiveContext))
        {
            receiveContext.Complete(TimeSpan.FromSeconds(10.0d));
        }
        else
        {
            throw new InvalidOperationException("...");
        }             
    }
}

<?xml version="1.0"?>
<configuration>
  <appSettings>
  <!-- Service Bus specific app setings for messaging connections -->
  <add key="Microsoft.ServiceBus.ConnectionString"       
      value="Endpoint=sb://LRNcomp/LRNnamespace"/>
  </appSettings>
 <system.web>
     <compilation debug="true" targetFramework="4.0"/>
     <httpRuntime/>
 </system.web>
 <system.serviceModel>
  <!-- These <extensions> will not be needed once our sdk is installed-->
    <extensions>
      <bindingElementExtensions>
        <add name="netMessagingTransport"      type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingTransportExtensionElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </bindingElementExtensions>
  <bindingExtensions>
    <add name="netMessagingBinding" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </bindingExtensions>
  <behaviorExtensions>
    <add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </behaviorExtensions>
</extensions>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="securityBehavior">
      <transportClientEndpointBehavior>
        <tokenProvider>
          <sharedSecret issuerName="owner" issuerSecret="somthing"/>
        </tokenProvider>
      </transportClientEndpointBehavior>
    </behavior>
  </endpointBehaviors>
</behaviors>
<bindings>
  <netMessagingBinding>
    <binding name="messagingBinding" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:03:00" sendTimeout="00:03:00" sessionIdleTimeout="00:01:00" prefetchCount="-1">
      <transportSettings batchFlushInterval="00:00:01"/>
    </binding>
  </netMessagingBinding>
</bindings>
<services>
  <service name="SBExamples.SBMessageService">
    <endpoint name="Service1" address="sb://LRNcomp:9354/LRNnamespace/test/myqueue2" binding="netMessagingBinding" bindingConfiguration="messagingBinding" contract="SBExamples.ISBMessageService" behaviorConfiguration="securityBehavior"/>
  </service>
</services>
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
  <!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
  <directoryBrowse enabled="true"/>
</system.webServer>
</configuration>

【问题讨论】:

  • 托管在哪里(self,IIS)? Azure 门户有一个使用 SB 的简单 application example,但我猜这并不是你想要的。
  • WCF 服务托管在我的本地 AppFabric 实例(Windows 7 机器)中。服务总线也是本地的,但当然这两个实例都要移动到其他机器上。
  • 您能否附上您的错误信息。
  • 我发现我的 WCF 合同中有一个错误,更新它就很神奇。

标签: wcf appfabric servicebus


【解决方案1】:

WCF 合同中的错误产生了许多奇怪的异常,例如我的传输通道被中止。在发送方和接收方之间正确共享合同起到了作用。

【讨论】:

  • 我也有同样的问题。您能否更具体地说明您是如何解决该问题的?另外,在您的 sb:// 端点中,路径中的“测试”到底是什么?
猜你喜欢
  • 2011-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多