1

我的问题是:有一段这样的代码(通过回调合约进行通信)

private void BroadcastMessage(DataEventArgs e)
{
    DataEventHandler temp = DataEvent;

    if (temp != null)
    {
        foreach (DataEventHandler handler in temp.GetInvocationList())
        {
            handler.BeginInvoke(this, e, EndAsync, null);
        }
    }
}

和一个回调合约

interface IDataCallback
{
    [OperationContract(IsOneWay = true)]
    void EntityUpdateReceived(Entity entity);

    [OperationContract(IsOneWay = true)]
    void EntitiesUpdateReceived(List<Entity> entities);

    [OperationContract(IsOneWay = true)]
    void EntityDeleteReceived(Entity entity);

    [OperationContract(IsOneWay = true)]
    void EntitiesDeleteReceived(List<Entity> entities);

    [OperationContract(IsOneWay = true)]
    void SendLogOffMessage(string message);

    [OperationContract(IsOneWay = true)]
    void Logoff();

    [OperationContract(IsOneWay = true)]
    void UpdatePlan(int userId);
}

我是否有保证消息将成功广播给所有客户端,即使有一些,比如说网络问题?我的意思是,服务是否会自动尝试一次又一次地传递消息,直到它成功,假设客户端一直处于连接状态,但在第一次传递过程中出现了一些问题。我问是因为我不知道是否必须编写额外的代码才能保证它(服务客户端确认消息等)我在 app.config 中启用了可靠会话,可靠会话是否解决了问题?

提前感谢您的回答

4

1 回答 1

3

It depends on the binding and configuration (for more details see here). And even then, the reliability is non-durable.

If you want something reliable and durable, you might want to look at transactional queues, for example via MSMQ (although numerous queue technologies are available). You might even want to post synchronously to the queue, since you expect it to be available.

于 2010-09-22T11:41:16.590 回答