wcf netmsmq 事务服务

发布于 2024-11-28 08:55:01 字数 1231 浏览 0 评论 0原文

嘿,全部。

我有一个有趣的案例。我尝试基于 Windows 服务应用程序上托管的 netmsmq 绑定创建 wcf 服务客户端通信。 所以我发现我的主机服务出现问题 - 它无法从队列接收任何消息。 MSDTC 显示事务回滚。经过一些尝试后,消息将进入重试子队列。 ServiceHost 变为失败状态,并且在我再次启动后一次又一次失败。 因此,在主机应用程序中,除了主机故障状态之外,我没有任何异常。 我有两份合同的服务(如果很重要的话)。

[ServiceContract]
public interface IService
{
    [OperationContract(IsOneWay = true)]
    void Send1(MyDataContract data);

    [OperationContract(IsOneWay = true)]
    void Send2(MyDataContract data);
}
[DataContract]
public class MyDataContract
{
    [DataMember]
    public string From { get; set; }
    [DataMember]
    public string Host { get; set; }
    [DataMember]
    public string To { get; set; }
    [DataMember]
    public DateTime SendTime { get; set; }
}

一些服务实现

[OperationBehavior(TransactionScopeRequired = true, 
                 TransactionAutoComplete = true)]
public void Send1(MyDataContract dc)
{......}

服务配置:

消息在队列中 - 客户端服务工作正常。 因此,在运行时,服务主机的 Send1 方法永远不会执行。但我在将消息从重试子队列移动到传入队列后关闭了 HostFaulted 事件。我只能说这么多。

有什么帮助吗?

Hy, all.

I have an interesting case. I have tried to create a wcf service-client communication based on netmsmq binding hosted on windows service app.
So I catch a problem with my host service - it can not receive any message from queue. MSDTC shows transaction rollback. And after some tries messages are moving into retry subqueue. ServiceHost become failed state and after i start in again in fails again and again.
So in host application i have no exception and nothing except host fault state.
I have service with two contracts (if it is important).

[ServiceContract]
public interface IService
{
    [OperationContract(IsOneWay = true)]
    void Send1(MyDataContract data);

    [OperationContract(IsOneWay = true)]
    void Send2(MyDataContract data);
}
[DataContract]
public class MyDataContract
{
    [DataMember]
    public string From { get; set; }
    [DataMember]
    public string Host { get; set; }
    [DataMember]
    public string To { get; set; }
    [DataMember]
    public DateTime SendTime { get; set; }
}

some service implementation

[OperationBehavior(TransactionScopeRequired = true, 
                 TransactionAutoComplete = true)]
public void Send1(MyDataContract dc)
{......}

service config:

<endpoint address="net.msmq://localhost/private/myservice" binding="netMsmqBinding" contract="IService" bindingConfiguration="NetMsmqBinding_IService" />

Messages are in queue - client service works fine.
So at runtime method Send1 of service host never executes. But i handle HostFaulted events close after moving message from retry subqueue to incoming queue. That's all i can say.

any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔女人霸气范 2024-12-05 08:55:01

因此,我花了大约一天的时间来发现问题。所以一步一步来:
1.我在msmq wcf上有微软示例
2.我发现没有什么区别
3.我明白,我有大消息(大于1Mb),所以默认情况下WCF可以不反序列化这么大的消息。有必要设置 ma​​xBufferPoolSizema​​xReceivedMessageSize

但这就是问题 - 为什么 wcf 客户端在没有任何扩展配置的情况下成功发送如此大的消息:)

我的建议:在 WCF 中设置包大小和池为您可能最大(如果只有您使用该服务)。

So, i spend around one day to detect the problem. So step by step:
1. I've got microsoft sample on msmq wcf
2. I found no difference
3. I understood, that i have big messages (larger 1Mb), so by default WCF can, not deserialize such big messages. It was neccessary to set maxBufferPoolSize and maxReceivedMessageSize

But that's the question - why wcf client successfuly send such big messages without any extended configurations :)

My advise: in WCF set package size and pools to max possible for you (if only you uses that service).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文