MSMQ,消息放在队列中,在前看不见,但永远不会被服务合约回升 [英] MSMQ, Message is put on queue and disapears but is never picked up by service contract
问题描述
我有一个本地专用队列。我也有一个MVC的应用程序,监听使用msmqIntegrationBinding队列内的WCF服务。的问题是,当排队的消息,但是该消息后在前看不见的瞬间服务合同从不调用。该消息是不是在毒害队列中。下面是配置部分,其中我宣布绑定到队列:
I have a local private queue. I also have a WCF-service inside an MVC-application that listens to the queue using msmqIntegrationBinding. The problem is that the service contract is never invoked when a message is queued but the message disapears the moment after. The message is not in the poison queue. Here is the config-part where i declare the binding to the queue:
<services>
<service name="SkruvInfo.Web.Service.QueueMessageReceiver">
<endpoint address="msmq.formatname:DIRECT=OS:LEIA\private$\screwinfo_autotests_messagequeue"
binding="msmqIntegrationBinding"
bindingConfiguration="MsmqBinding"
contract="SkruvInfo.Web.Service.IQueueMessageReceiver" />
</service>
</services>
和这里的合同:
[ServiceContract(Namespace = "http://localhost/SkruvWeb/Service")]
public interface IQueueMessageReceiver
{
[OperationContract(IsOneWay = true, Action = "*")]
void PutScrewInfoMessage(MsmqMessage<string> msg);
}
这是在服务方式:
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void PutScrewInfoMessage(System.ServiceModel.MsmqIntegration.MsmqMessage<string> msg)
{
log4net.Config.XmlConfigurator.Configure();
var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
try
{
log.Debug("Message from queue: " + msg.Body.ToString(CultureInfo.InvariantCulture));
var xDoc = new XmlDocument();
xDoc.LoadXml(msg.Body);
CacheScrewInfoModelFromScrewInfoXmlDoc(xDoc);
}
catch (Exception e)
{
log.Error("Error parsing message from queue",e);
EventLog.WriteEntry("Application","Message error for screws");
}
}
为什么消息在前看不见任何建议,但不会调用?服务
Any suggestions to why the message disapears but does not invoke the service?
推荐答案
尝试修改与ServiceKnownType属性的服务合同:
Try to modify your service contract with ServiceKnownType attribute:
[ServiceContract(Namespace = "http://localhost/SkruvWeb/Service")]
[ServiceKnownType(typeof(String))]
public interface IQueueMessageReceiver
{
[OperationContract(IsOneWay = true, Action = "*")]
void PutScrewInfoMessage(MsmqMessage<string> msg);
}
更新
如果您使用的是MsmqIntegrationBinding我假设您的队列客户端就像一个VB6客户端遗留应用程序?如果是这样你需要在你的服务绑定配置指定序列化格式。例如:
If you are using MsmqIntegrationBinding I am assuming your queue client is a legacy application like a VB6 client? If so you will need to specify the serialization format in your service binding configuration. For example:
<msmqIntegrationBinding>
<binding name="MsmqBinding" serializationFormat="ActiveX">
<security mode="None" />
</binding>
</msmqIntegrationBinding>
Permissable值记录的这里。
这篇关于MSMQ,消息放在队列中,在前看不见,但永远不会被服务合约回升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!