简体   繁体   English

带有Apache ActiveMQ WCF绑定的双工或请求-答复配置问题

[英]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 - 我正在尝试为WCF应用程序使用Apache.NMS.WCF绑定,并收到以下错误-

Contract requires TwoWay (either request-reply or duplex), but Binding 'NmsBinding' doesn't support it or isn't configured properly to support it. 合同要求使用TwoWay(请求-答复或双工),但是绑定“ NmsBinding”不支持它,或者没有正确配置为支持它。

My system.service model looks like this - 我的system.service模型看起来像这样-

    <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? 有没有一种方法可以将Apache NMS配置为双工还是不支持双工?

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. 像ActiveMQ这样的消息队列通常在设计上通常是单向的-您可以将消息放入其中,仅此而已。

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文档和其他资源:

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. 这些示例通常使用MSMQ,因为WCF本身就支持MSMQ,但是将任务分解为两个单独的单向合同的基本原理以及如何设置和使用两个单独的请求和响应队列的基本原理也应适用于ActiveMQ。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM