简体   繁体   中英

WCF Remote MSMQ - I can write to a remote queue, but cannot receive

jobsServer: Windows Server 2008 R2 .NET Version: 4.5

I'm using WCF to connect two servers - app and queue . I want app to be able to send/receive messages from queue . For some reason, app can send messages, but CANNOT receive them.

The netMsmq binding looks like:

<binding name="JobExecutionerBinding" receiveErrorHandling="Move">
  <security>
    <transport msmqAuthenticationMode="None" msmqProtectionLevel="None" />
  </security>
</binding>

And the service binding looks like:

Now, the client binding looks like:

<endpoint   address="net.msmq://queue/private/jobs" 
            binding="netMsmqBinding" 
            bindingConfiguration="JobExecutionerBinding" 
            contract="JobExecution.Common.IJobExecutionService" 
            name="SimpleEmailService" 
            kind="" 
            endpointConfiguration=""/>

I changed a few names for security's sake.

So, the WC client can send to the remote queue without a problem. It even properly queues the outgoing message and forwards it on later in the event that the remote queue server is down. But every time I start up the WCF service, I get this:

There was an error opening the queue. Ensure that MSMQ is installed and running, the queue exists and has proper authorization to be read from. The inner exception may contain additional information. ---> System.ServiceModel.MsmqException: An error occurred while opening the queue:The queue does not exist or you do not have sufficient permissions to perform the operation. (-1072824317, 0xc00e0003). The message cannot be sent or received from the queue. Ensure that MSMQ is installed and running. Also ensure that the queue is available to open with the required access mode and authorization. at System.ServiceModel.Channels.MsmqQueue.OpenQueue() at System.ServiceModel.Channels.MsmqQueue.GetHandle() at System.ServiceModel.Channels.MsmqQueue.SupportsAccessMode(String formatName, Int32 accessType, MsmqException& msmqException) --- End of inner exception stack trace --- at System.ServiceModel.Channels.MsmqVerifier.VerifyReceiver(MsmqReceiveParameters receiveParameters, Uri listenUri) at System.ServiceModel.Channels.MsmqTransportBindingElement.BuildChannelListener[TChannel](BindingContext context) at System.ServiceModel.Channels.Binding.BuildChannelListener[TChannel](Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters) at System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession) at System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result) at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.ServiceHostBase.InitializeRuntime() at

I've been all over StackOverflow and the internet for 8 hours. Here's what I've done:

  • Ensured that ANONYMOUS LOGIN, Everyone, Network, Network Service, and Local Service have full control
  • Stopped the remote MSMQ server and observed what the WCF service does, and I get a different error - so I'm sure that the WCF service when starting up is speaking to the MSMQ server
  • Disabled Windows Firewall on both boxes and opened all ports via EC2 security groups
  • Set AllowNonauthenticatedRpc and NewRemoteReadServerAllowNoneSecurityClient to 1 in the registry
  • Configured MS DTC on both servers (the queue is transactional, but I get the same error regardless as to whether the queue is transactional or not)
  • Confirmed that the WCF server starts up fine if I use the local queue, and receives without a problem

Help!!! I can't scale my app without a remote queueing solution.

It's not clear from your post which tier can not read and more importantly which queue .

However, reading remote queues transactionally is not supported:

Message Queuing supports sending transactional messages to remote queues, but does not support reading messages from a remote queue within a transaction . This means that reliable, exactly-once reception is not available from remote queues. See Reading Messages from Remote Queues

I suspect that somewhere your system is still performing transactional remote reads even though you mentioned you disabled it.

From a best practice point of view, even if you got it to work, your design will not scale which is a shame as it is something you mentioned you wanted.

Remote reading is a high-overhead and therefore inefficient process. Including remote read operations in an application limits scaling. 1

You should always remote write not remote read.

A better way is to insert a message broker or router service that acts as the central point for messaging. Your app and queue services (confusing names by the way) should merely read transactionally from their local queues .

ie

  • app should transactionally read it's local queue
  • app should transactionally send to the remote broker
  • broker transactionally reads local queue
  • broker transactionally sends to remote queue

Similarly if your queue tier wanted to reply the reverse process to the above would occur.

Later if you wish to improve performance you can introduce a Dynamic router which redirects a message to a different remote queue on another machine based on dynamic rulesets or environmental conditions such as stress levels.

Remote transactional reads are supported as of MSMQ 4.0 (Windows server 2008). If you are facing this issue, be sure to checkout https://msdn.microsoft.com/en-us/library/ms700128(v=vs.85).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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