开发者

Duplex or request-reply with Apache ActiveMQ WCF Binding configuration question

I am trying to use the Apache.NMS.WCF bindings for a WCF application and get the following error -

Contract requires TwoWay (either request-reply or duplex), but Binding 'NmsBinding' doesn't support it or isn't configured properly to support it.

My system.service model looks like this -

    <bindings>
        <nmsBinding>
            <binding 
                name="myNMSBinding" 
                destination="test.queue" 
                destinationType="TemporaryQueue"
                >
            </binding>
        </nmsBinding>
    </bindings>

    <extensions>
        <!--<bindingElementExtensions>
            <add name="nmsTransPort" 
                 type="Apache.NMS.WCF.NmsTransportElement, Apache.NMS.WCF, Version=1.1.0.1642, Culture=neutral, PublicKeyToken=82756feee3957618" />
        </bindingElementExtensions>-->
        <bindingExtensions>
            <add name="nmsBinding" 
                 type="Apache.NMS.WCF.NmsBindingCollection, Apache.NMS.WCF, Version=1.1.0.1642, Culture=neutral, PublicKeyToken=82756feee3957618" 

                 />
        </bindingExtensions>
    </extensions>

    <services>
        <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
            <!-- Service Endpoints -->
      开发者_如何学编程      <endpoint 
                address="tcp://localhost:61616" 
                binding="nmsBinding" 
                bindingConfiguration="myNMSBinding" 
                contract="WcfService1.IService1"
                />
        </service>
    </services>

Is there a way to configure the Apache NMS to be duplex or does it just not support it?


A message queue like ActiveMQ is by normally by design only a one-way thing - you can drop messages into it and that's about it.

The real solution if you do need responses back is to reverse the roles: the service you sent a message to on your main contract (one-way) will become the client that sends you back a response on a second queue, on which your app is listening in as the server.

See some MSDN docs and other resources on the topics:

  • MSDN: Queueing in WCF
  • MSDN: Two-way communication over MSMQ in WCF
  • MSDN Magazine: Build a queued WCF response service
  • CodeProject: WCF Queued Messaging
  • Mike Taulty: WCF, MSMQ and CompositeDuplex

The samples typically use MSMQ since that's natively supported by WCF, but the basic principles of breaking up your tasks into two separate one-way contracts and how to setup and use two separate request and response queues should apply to ActiveMQ just as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜