简体   繁体   English

使用node.js的通知服务器的协议比较

[英]protocol comparison for notification server with node.js

I'd like to implement push notification server using node.js. 我想使用node.js实现推送通知服务器。 The basic scenario is: 基本方案是:

  1. Some applications sends notification messages to the server. 某些应用程序将通知消息发送到服务器。
  2. Notification server receives the request and forwards the message to uesr's mail or IM client based on user's preference. 通知服务器接收请求,然后根据用户的偏好将消息转发到uesr的邮件或IM客户端。

In step 1, which protocol (eg REST, socket, HTTP/XML and so on.) would you recommend from the performance perspective? 从性能的角度来看,在步骤1中,您会推荐哪种协议(例如REST,套接字,HTTP / XML等)?

Also in step 2, I have a plan to use node-xmpp module for IM client but for mail, which way is the best to implement? 同样在第2步中,我计划将IM-Client而不是邮件使用node-xmpp模块,哪种方法最好实现? For example, 例如,

  1. Just use SMTP. 只需使用SMTP。 (But I think this might occur performance degradation because SMTP is an expensive communication and performance depends on SMTP server capacity. (但是我认为这可能会导致性能下降,因为SMTP是一种昂贵的通信,而性能取决于SMTP服务器的容量。
  2. use queue mechanism, in order to avoid drawbacks from the above. 使用队列机制,以避免上述缺点。 node.js app simply puts the message into the queue, and smtp server pulls the message. node.js应用程序只是将消息放入队列,而smtp服务器则将消息提取。
  3. other solutions... 其他解决方案...

Thanks in advance. 提前致谢。

With regards to what to use as a protocol, i would go for a REST interface, whereby the application posting sends a POST request to a resource associated with the USER. 关于用作协议的内容,我将使用REST接口,由此应用程序发布会将POST请求发送到与USER相关联的资源。 something along the lines of "http://example.com/rest/v1/{userID}/notifications 类似“ http://example.com/rest/v1/{userID}/notifications”的内容

I personally would use json as the data/content of the rest request and have node.js write this information to a message queue. 我个人将使用json作为其余请求的数据/内容,并让node.js将此信息写入消息队列。 (as a json string). (作为json字符串)。

You can than have xmpp readers for each user, as well as an SMTP handler reading from this queue as fast as the SMTP server allows it to go. 然后,您可以为每个用户使用xmpp阅读器,以及一个SMTP处理程序,该SMTP处理程序从此队列中读取的速度可以达到SMTP服务器允许的速度。

However, this full post is what i would do in your situation, rather than a factual response on what is best. 但是,这篇完整的帖子是我在您遇到的情况下会做的,而不是对最佳做法的事实回应。 I know JMS fairly well and i've been working a lot with rest interfaces lately, therefore this is the way i would do it. 我非常了解JMS,并且最近我一直在使用rest接口,因此这就是我要做的方式。

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

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