2

The WCF service while hosting with IIS is failing. The web.config for the service is

<system.serviceModel>
    <bindings>
        <netMsmqBinding>
            <binding name="msmqbindingnontransactionalnonsecure" exactlyOnce="False">
                <security mode="None" />
            </binding>
        </netMsmqBinding>
    </bindings>
    <services>
        <service name="MsmqService.MsmqService">
            <endpoint address="net.msmq://localhost/private/msmqpoc/MsmqService.svc"  binding="netMsmqBinding" bindingConfiguration="msmqbindingnontransactionalnonsecure" contract="MsmqWCFService.IMsmqContract" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="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="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

The service contract is

[ServiceContract]
public interface IMsmqContract
{
    [OperationContract(IsOneWay = true)]
    void SendMessage(string message);
}

While hosting service in IIS the following is the message that is displayed:

Server Error in '/msmqpoc' Application.
--------------------------------------------------------------------------------

Binding validation failed because the binding's ExactlyOnce property is set to true while the destination queue is non-transactional. The service host cannot be opened. Resolve this conflict by setting the ExactlyOnce property to false or creating a transactional queue for this binding. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Binding validation failed because the binding's ExactlyOnce property is set to true while the destination queue is non-transactional. The service host cannot be opened. Resolve this conflict by setting the ExactlyOnce property to false or creating a transactional queue for this binding.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.      
Stack Trace:
[InvalidOperationException: Binding validation failed because the binding's ExactlyOnce property is set to true while the destination queue is non-transactional. The service host cannot be opened. Resolve this conflict by setting the ExactlyOnce property to false or creating a transactional queue for this binding.]

The configuration is already is set to exactlyOnce=false, not sure why this error is coming, any help?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
user457485
  • 267
  • 3
  • 15

1 Answers1

2

I can only surmise your service is not picking up the correct config file. I would suggest double checking that. I cannot see any problem with the config file you have posted.

Slightly off topic, I would hazard that you should consider why you are using non-transactional queues. The only reason you would be using them would be if your overall architecture can tolerate message loss.

For example, in some low latency systems the messages are only valuable for at most seconds before they become invalid. So in this instance you would not need to use transactional queues.

If you cannot tolerate message loss you must use transactional queuing.

tom redfern
  • 30,562
  • 14
  • 91
  • 126
  • Thanks, that is exactly what was happening. The service was not picking up the named configuration, not sure why. I modified the configuration and removed the name of the binding after which the service started working as expected. – user457485 Mar 19 '12 at 11:20
  • hugh - Non-transactional queues are a legitimate option in exactly the same way as UDP. Trying to put forth a best practice fit for all scenarios here without knowing the OPs intention is not helpful. –  Apr 10 '14 at 07:04
  • @MickyDuncan thanks for the comment. Agree that non-transactional is a legitimate option, hence why I qualified my guess (that OP would be better off using transactional queuing) with an example of where it would not be needed. Of the benefits of queuing in general, it is the durability that people find most attractive. I would speculate that most people (when they start using queuing) have a built-in expectation of durability - I know I had. Without using DTC, MSMQ simply cannot provide durability. So, to the contrary I believe that pointing this out to the OP is helpful in this circumstance. – tom redfern Apr 10 '14 at 08:49
  • Agreed. The bit I like about MSMQ, or messaging for that matter, is the superior scalability it has over RPC alternatives. The "free set of steak-knives" one might say. ;) –  Apr 10 '14 at 09:25