简体   繁体   English

使用FubuMVC.ServerSentEvents时发生一个事件

[英]One Event Behind when using FubuMVC.ServerSentEvents

We are currently working on implementing a notifications feature for our app we are developing for Windows Azure. 我们目前正在为我们为Windows Azure开发的应用程序实现通知功能。 We want to inform users when actions have taken place they are interested in (such as the importing and exporting of files and so on). 我们希望在用户感兴趣的操作发生时通知用户(例如文件的导入和导出等)。 This notification is specific to each logged in user. 该通知特定于每个登录用户。

We have been using ServerSentEvents and we have found that this list is one event behind. 我们一直在使用ServerSentEvents,我们发现此列表落后一个事件。 So we do not start seeing notifications until the second action has taken place and that notification is for the first action. 因此,只有在执行第二个操作并且该通知是针对第一个操作的之后,我们才开始看到通知。 In our dev environments this problem always happens, but in Azure it appears to work as expected (sometimes!!!) 在我们的开发环境中,总是会发生此问题,但是在Azure中,它似乎按预期工作(有时!!!)

We are using the default implementation of the Event Queue and Channel Initialiser. 我们正在使用事件队列和通道初始化程序的默认实现。 We publish via the EventPublisher.WriteTo method passing a topic and a serverevent. 我们通过EventPublisher.WriteTo方法进行发布,并传递一个主题和一个serverevent。

Here is our implementation of Topic: 这是我们对Topic的实现:

public class UserNotificationsTopic : Topic
    {
        [RouteInput]
        public Guid UserId { get; set; }

        public override bool Equals(object obj)
        {
            return Equals(obj as UserNotificationsTopic);
        }

        public bool Equals(UserNotificationsTopic other)
        {
            if (ReferenceEquals(null, other)) return false;

            return ReferenceEquals(this, other) ||
                UserId.Equals(other.UserId);
        }

        public override int GetHashCode()
        {
            return UserId.GetHashCode();
        }
    }

Implementation of our ServerEvent: 我们的ServerEvent的实现:

public class UserNotificationServerEvent : IServerEvent
    {
        public string Id { get; private set; }

        public string Event { get; private set; }

        public int? Retry { get; set; }

        public object Data { get; private set; }

        public UserNotificationServerEvent(string id, string @event, object data)
        {
            this.Id = id;
            this.Event = @event;
            this.Data = data;
        }
    }

Any help, suggestions would be appreciated! 任何帮助,建议将不胜感激!

Thanks 谢谢

Scott 史考特

I think I have found the solution (with a lot of assistance from my colleague). 我想我已经找到了解决方案(在我的同事的大力协助下)。

We reading about SignalR and found it has a similar problem in Azure (one event behind), the solution recommended was to add properties for urlCompression to the Web.config for the Azure Web Role. 我们阅读了有关SignalR的信息,发现它在Azure中存在类似的问题(发生了一个事件),建议的解决方案是将urlCompression的属性添加到Azure Web角色的Web.config中。

I added the settings which are the default for IIS7.5: 我添加了IIS7.5的默认设置:

<urlCompression doStaticCompression="true" doDynamicCompression="false"/>

And this appears to have solved the issue! 这样看来已经解决了问题! I am not sure why yet, so if anyone can help with that please feel free to add. 我还不确定为什么,所以如果有人可以提供帮助,请随时添加。

Anyway, I just thought I'd share the update. 无论如何,我只是想分享一下更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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