如何使用RESTful Web服务创建异步通知系统? [英] How would I create an asynchronous notification system using RESTful web services?

查看:214
本文介绍了如何使用RESTful Web服务创建异步通知系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过RESTful Web服务提供的Java应用程序。我想创建一个机制,以便客户可以注册事件的通知。呃是不能保证客户端程序是Java程序,因此我将无法使用JMS(即如果每个客户端都是一个Java应用程序,那么我们可以允许客户端订阅一个JMS主题并且在那里收听通知消息)。



用例大致如下:


  1. 客户端通过RESTful Web服务调用自动注册我的服务器应用程序,表示有兴趣在特定对象更新时获取通知消息。

  2. 当对象感兴趣的是更新,然后我的服务器应用程序需要通知所有有兴趣被通知此事件的客户。

如上所述,我知道如果所有客户端都是Java应用程序,我将如何做到这一点 - 设置客户端可以听的主题用于通知消息。然而,我不能使用这种方法,因为许多客户端可能无法收听通知消息的JMS主题。



任何人都可以启发我这个问题通常如何解决?我可以使用RESTful API提供什么机制?

解决方案

我可以想到四种方法:


  1. Twitter方法:您注册客户端,然后使用GET定期回拨以检索任何通知。


  2. 客户端描述在进行注册请求时,如何收到通知。这样,您可以允许JMS为那些可以处理它的人,并回到电子邮件或类似的那些不能。


  3. 在注册期间拿一个URL当您有通知时,单独请求并发回每个客户端。很难发布/ Sub,但效果会相似。当然,您会假设客户端正在收听这些通知,并根据您的规格实施了客户端。


  4. 购买IBM WebSphere MQ(MQSeries) 。最好的IBM产品。不是REST,但它非常适合这样的多平台集成。



I have a Java application which I make available via RESTful web services. I want to create a mechanism so clients can register for notifications of events. The rub is that there is no guarantee that the client programs will be Java programs and hence I won't be able to use JMS for this (i.e. if every client was a Java app then we could allow the clients to subscribe to a JMS topic and listen there for notification messages).

The use case is roughly as follows:

  1. A client registers itself with my server application, via a RESTful web service call, indicating that it is interested in getting a notification message anytime a specific object is updated.
  2. When the object of interest is updated then my server application needs to put out a notification to all clients who are interested in being notified of this event.

As I mentioned above I know how I would do this if all clients were Java apps -- set up a topic that clients can listen to for notification messages. However I can't use that approach since it's likely that many clients will not be able to listen to a JMS topic for notification messages.

Can anyone here enlighten me as to how this problem is typically solved? What mechanism can I provide using a RESTful API?

解决方案

I can think of four approaches:

  1. A Twitter approach: You register the Client and then it calls back periodically with a GET to retrieve any notifications.

  2. The Client describes how it wants to receive the notification when it makes the registration request. That way you could allow JMS for those that can handle it and fall back to email or similar for those that can't.

  3. Take a URL during the registration request and POST back to each Client individually when you have a notification. Hardly Pub/Sub but the effect would be similar. Of course you'd be assuming that the Client was listening for these notifications and had implemented their Client according to your specs.

  4. Buy IBM WebSphere MQ (MQSeries). Best IBM product ever. Not REST but it's great at multi-platform integration like this.

这篇关于如何使用RESTful Web服务创建异步通知系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆