Ticket Hash: | aa230e52993ed716b51bc675b69fba1a0fed7afc | |||
Title: | Implements one-way callbacks from the server | |||
Status: | Fixed | Type: | Feature_Request | |
Severity: | Severe | Priority: | Immediate | |
Subsystem: | mORMot | Resolution: | Implemented | |
Last Modified: | 2015-05-06 17:20:59 | |||
Version Found In: | ||||
User Comments: | ||||
root added on 2014-06-27 08:14:07:
Aim is to implement notification events trigerred from the server side, very easily from Delphi code, even over HTTP (note that WCF does not allow this). It will be the ground of Event Collaboration or Event Sourcing stacks included within mORMot. See this blog article about the interface-based implementation proposal, and its innovative publish / subscribe pattern - may be included as http.sys API 2.0 websocket protocol ab added on 2014-12-31 10:32:32: We enhanced the priority of this feature request, since it is needed for several other feature requests, e.g. synch/replication [3453f314d9] or monitoring [17958b22c02]. ab added on 2015-01-29 12:28:33:
Status Update
WebSockets or long pooling are not an option in our current roadmap, since we would rather rely on a simple REST connection for the end-user applications, with an application service layer (as proposed by DDD principles). End-user application could simply pool its application service for any pending event. Mobile apps may benefit later on from Google/Apple push notification services. HTTP callback server or ZeroMQ may be used on a trusted intranet, for better performance. We are currently investigating about supporting ZeroMQ for easy implementation of the publish/subscribe pattern. See this good introduction to ZeroMQ for a high level presentation.
The ZeroMQ Request/Reply pattern may be used to implement a REST access to mORMot servers instead of HTTP, with the benefit of higher performance, and fair distribution among servers. ZeroMQ devices would add simple and efficient routing of services.
The ZeroMQ Publish/Subscribe pattern may be used to implement our one-way callbacks from the server, with appropriate filtering of the JSON content, on need. ab added on 2015-02-26 10:48:07: Implementation Proposal Proposal is to use interface parameters to interface-based service methods to send a callback to the server. When the client code supplies an instance of class (possibly self) for this parameter: type IMyCallback = interface(IInvokable) ['{5CD49AB1-D5A3-4059-B287-25E939DD2A0B}'] procedure EventCalledFromServer(const withAValue: integer); end; IMyService = interface(IInvokable) ['{FB31BF33-38C7-45AE-9511-6AC727ADC4F4}'] procedure MethodWithCallback(const anyParameter: variant; const TheCallBack: IMyCallback); end; In practice:
This pattern will also be the base of any kind of dual-connection process, e.g. regular publish/subscribe mechanism with a list of subscription on the server side, pointing to alive sicClientDriven client connections. ab added on 2015-02-26 11:01:35:
In addition, a callback passed as a type IMyService = ... type IMyCatalog = interface(IInvokable) ['{5696DC03-2AD6-419C-B894-B9EA1506DD9B}'] function RetrieveMyServiceInstance(const ShardingCriteria: TID; out Service: IMyCallback): boolean; end; As you can see, we specified an optional criteria, which may be used to spread the service implementation in several servers, in a way close to the MongoDB sharding concept. This would allow clean horizontal scaling of the whole SOA implementation. ab added on 2015-05-06 17:20:59: We have almost everything needed. CQRS can be easily implemented:
Event Source may be implemented easily with SOA interfaces, and their callbacks. See how callbacks can be defined, using WebSockets for communication and the corresponding samples. |