Difference between revisions of "IS-Notifier"

From Gcube Wiki
Jump to: navigation, search
(Design)
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
 +
== Role ==
 
The IS-Notifier is the gCube Service dedicated to manage subscriptions with respect to ''Topics'', i.e. organised items of interest for publishing/subscription . It acts as a subscriptions broker since allows its client to subscribe to a topic while freeing them from the need to know the location of the notifications producer (i.e. its EPR). It also supports subscriptions to Topics that are not yet exposed by their producers. In this case, the IS-Notifier maintains a subscription in a pending state until the notification producer registers the related Topic.  
 
The IS-Notifier is the gCube Service dedicated to manage subscriptions with respect to ''Topics'', i.e. organised items of interest for publishing/subscription . It acts as a subscriptions broker since allows its client to subscribe to a topic while freeing them from the need to know the location of the notifications producer (i.e. its EPR). It also supports subscriptions to Topics that are not yet exposed by their producers. In this case, the IS-Notifier maintains a subscription in a pending state until the notification producer registers the related Topic.  
  
It is important to notice that the design of such a service does not implement the classical brokered notification schema since the IS-Notifier subscribes the consumer directly to the notification producer. In this way, there is no single service that is in charge to receive notifications from producers and then dispatch them to the subscribed client(s). However, the IS-Notifier plays a mediator role because of the subscriptions brokerage. In fact, the IS-Notifier automatically manages the relocation of notification producers by forwarding the client subscription requests to the new instances of the producers. Moreover, the service supports the transparent subscription/re-subscription of the client to the new producer instances that comes up after the initial request of subscription.
+
It is important to notice that the design of such a service does not follow the classical brokered notification schema since the IS-Notifier subscribes a notification consumer directly to the notification producer. In this way, there is no single service (and a single point of failure) that is in charge to receive notifications from producers and then dispatch them to the subscribed client(s). As such, the IS-Notifier plays a mediator role because of the subscriptions brokerage.
 +
 
 +
As support for the dynamic (re)location of services in a gCube infrastructure, the IS-Notifier is capable to:
 +
* determine if a notification producer ohas been relocated on a different node and automatically/transparently reconnect the producer to all its registered consumers
 +
* determine if a notification consumers has been relocated on a different node and automatically/transparently re-subscribe it to the producer
 +
 
 +
This is possible because the IS-Notifier subscribes itself to the topics exposed by the [[IS-Registry#FactoryResource|Factory resource]] of the [[IS-Registry]] service.
 +
 
 +
== Design ==
 +
The IS-Notifier service adopts a singleton pattern. It implements a notification broker system on top of the [http://www.ibm.com/developerworks/library/specification/ws-notification/ WS-Notifications] standard implemented in GT4.     
 +
A library that simplifies interaction with this service is released with the gHN distribution (namely the [[IS-Notification|IS-Notification library]]).
 +
 
 +
== Operations ==
 +
The IS-Notifier follows the singleton pattern, it exposes one PortType ('''NotifierPortType''') offering the following operations:
 +
 
 +
* ''String registerTopic(RegisterTopicMessage message)'' allows client to register as producer of a topic, if the topic already exists his address is added as producer of the topic. 
 +
* ''UnregisterTopicResponse unregisterTopic(RegisterTopicMessage message)'' allows client to unregister a specific topic.
 +
* ''SubscribeToTopicResponse subscribeToTopic(SubscribeMessage message)'' allows client to register as consumer of a topic, f the topic already exists his address is added as consumer of the topic.
 +
* ''RemoveSubscriptionResponse removeSubscription (SubscribeMessage message)'' allows client to remove the subscription to a topic.
 +
* ''ListTopicsResponse listTopics (ListTopics topics)'' returns the list of all topic registered.
 +
* ''RemoveNotifierResponse removeNotifier(RemoveNotifier notifiers)'' removes a specific host from all the topic it was registered as producer
 +
* ''RemoveSubscriberResponse removeSubscriber(RemoveSubscriber subscribers)'' removes a specific host from all the topic it was registered as consumer
 +
* ''IsOngoingResponse isOngoing(IsOngoingRequest request)'' allows client to know which topic registration are still ongoing or finished.
 +
 
 +
== Sample Usage ==
 +
The IS-Notifier EPR in the current scope can be retrieved with the [[IS-Client|IS-Client library]]:
 +
<source lang="java">
 +
GCUBEScope scope = ...;
 +
ISClient client = GHNContext.getImplementation(ISClient.class);
 +
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
 +
query.addAtomicConditions(new AtomicCondition("/Profile/ServiceName","IS-Notifier"),new AtomicCondition("/Profile/ServiceClass","InformationSystem") );
 +
List<GCUBERunningInstance> ris= client.execute(query, scope);
 +
EndpointReferenceType notifierEPR =null;
 +
if (ris.size()>0)
 +
  notifierEPR = ris.get(0).getAccessPoint().getEndpoint("gcube/informationsystem/notifier/Notifier");
 +
else System.out.println("the Notifier Service has not been found");
 +
</source>
  
==== Resources and Properties ====
+
The following code explains how to register as consumer for a topic:
The service adopts the singleton pattern. The managed resource represents the operational status of the service by exposing a set of properties, e.g. number of topics currently published, the number of subscriptions managed, the number of pending subscriptions.
+
<source lang="java">
 +
GCUBEScope scope = ...;
  
==== Functions ====
+
//creating a NotificationConsumerManager
The main functions supported by the IS-Notifier are:
+
NotificationConsumerManager consumer = NotificationConsumerManager.getInstance();
 +
consumer.startListening(); //starting a listener that receives the notification
 +
EndpointReferenceType consumerEPR = consumer.createNotificationConsumer(this); //retrieving the consumer EPR
  
* '''registerTopic()''' – which takes as input parameter a message containing the EPR of the topics produced and the list of ''Topics'' consumers can subscribe and accordingly enriches the pool of managed ''Topics'';
+
SubscribeMessage mess = new SubscribeMessage();
* '''unregisterTopic()''' – which takes as input parameter a message containing the EPR of the topics producer and the list of ''Topics'' to be removed and accordingly revise the pool of managed ''Topics'';
+
mess.setEndpointReference(consumerEPR);
* '''subscribeToTopic()''' – which takes as input parameter a message containing the request for subscription (i.e. the EPR of the subscriber and the topic of interest) and subscribes the subscriber to the appropriate producer(s) according to the WS-BaseNotification specification .  
+
//in this case the registration is for all change made by the registry service to GCUBEGenericResource profiles
* '''listTopics()''' – which returns all the Topics managed by the IS-Notifier instance;
+
mess.setTopic("{http://gcube-system.org/namespaces/informationsystem/registry}GCUBEGenericResource");
* '''listTopicForNotifiers()''' – which takes as input parameter a message containing the EPR and returns ;
+
//a precondition is optionally selectable, in this case the server will notify only when a GCUBEGenericResource is deleted
* '''getSubscribersForTopic()''' – which takes as input parameter a message containing the target ''Topic'' and returns the list of current subscribers (actually their EPRs);
+
mess.setPrecondition("//operationType/[text()='destroy']");  
* '''removeSubscription()''' – which takes as input parameter a message containing the request for un-subscription (i.e. the EPR of the subscriber and the Topic to be unsubscribed) and manages the subscription removal;
+
  
 +
NotifierServiceAddressingLocator brokerLocator = new NotifierServiceAddressingLocator();
 +
NotifierPortType notifierPT = brokerLocator.getNotifierPortTypePort(notifierEPR);
 +
notifierPT= GCUBERemotePortTypeContext.getProxy(port, scope);
 +
brokerPT.subscribeToTopic(mess);
 +
</source>
  
 
[[Category:Information System]]
 
[[Category:Information System]]

Latest revision as of 16:29, 14 April 2011

Role

The IS-Notifier is the gCube Service dedicated to manage subscriptions with respect to Topics, i.e. organised items of interest for publishing/subscription . It acts as a subscriptions broker since allows its client to subscribe to a topic while freeing them from the need to know the location of the notifications producer (i.e. its EPR). It also supports subscriptions to Topics that are not yet exposed by their producers. In this case, the IS-Notifier maintains a subscription in a pending state until the notification producer registers the related Topic.

It is important to notice that the design of such a service does not follow the classical brokered notification schema since the IS-Notifier subscribes a notification consumer directly to the notification producer. In this way, there is no single service (and a single point of failure) that is in charge to receive notifications from producers and then dispatch them to the subscribed client(s). As such, the IS-Notifier plays a mediator role because of the subscriptions brokerage.

As support for the dynamic (re)location of services in a gCube infrastructure, the IS-Notifier is capable to:

  • determine if a notification producer ohas been relocated on a different node and automatically/transparently reconnect the producer to all its registered consumers
  • determine if a notification consumers has been relocated on a different node and automatically/transparently re-subscribe it to the producer

This is possible because the IS-Notifier subscribes itself to the topics exposed by the Factory resource of the IS-Registry service.

Design

The IS-Notifier service adopts a singleton pattern. It implements a notification broker system on top of the WS-Notifications standard implemented in GT4. A library that simplifies interaction with this service is released with the gHN distribution (namely the IS-Notification library).

Operations

The IS-Notifier follows the singleton pattern, it exposes one PortType (NotifierPortType) offering the following operations:

  • String registerTopic(RegisterTopicMessage message) allows client to register as producer of a topic, if the topic already exists his address is added as producer of the topic.
  • UnregisterTopicResponse unregisterTopic(RegisterTopicMessage message) allows client to unregister a specific topic.
  • SubscribeToTopicResponse subscribeToTopic(SubscribeMessage message) allows client to register as consumer of a topic, f the topic already exists his address is added as consumer of the topic.
  • RemoveSubscriptionResponse removeSubscription (SubscribeMessage message) allows client to remove the subscription to a topic.
  • ListTopicsResponse listTopics (ListTopics topics) returns the list of all topic registered.
  • RemoveNotifierResponse removeNotifier(RemoveNotifier notifiers) removes a specific host from all the topic it was registered as producer
  • RemoveSubscriberResponse removeSubscriber(RemoveSubscriber subscribers) removes a specific host from all the topic it was registered as consumer
  • IsOngoingResponse isOngoing(IsOngoingRequest request) allows client to know which topic registration are still ongoing or finished.

Sample Usage

The IS-Notifier EPR in the current scope can be retrieved with the IS-Client library:

GCUBEScope scope = ...;
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/ServiceName","IS-Notifier"),new AtomicCondition("/Profile/ServiceClass","InformationSystem") );
List<GCUBERunningInstance> ris= client.execute(query, scope);
EndpointReferenceType notifierEPR =null;
if (ris.size()>0)
   notifierEPR = ris.get(0).getAccessPoint().getEndpoint("gcube/informationsystem/notifier/Notifier");
else System.out.println("the Notifier Service has not been found");

The following code explains how to register as consumer for a topic:

GCUBEScope scope = ...;
 
//creating a NotificationConsumerManager
NotificationConsumerManager consumer = NotificationConsumerManager.getInstance();
consumer.startListening(); //starting a listener that receives the notification
EndpointReferenceType consumerEPR = consumer.createNotificationConsumer(this); //retrieving the consumer EPR
 
SubscribeMessage mess = new SubscribeMessage();
mess.setEndpointReference(consumerEPR);
//in this case the registration is for all change made by the registry service to GCUBEGenericResource profiles
mess.setTopic("{http://gcube-system.org/namespaces/informationsystem/registry}GCUBEGenericResource");
//a precondition is optionally selectable, in this case the server will notify only when a GCUBEGenericResource is deleted
mess.setPrecondition("//operationType/[text()='destroy']"); 
 
NotifierServiceAddressingLocator brokerLocator = new NotifierServiceAddressingLocator();
NotifierPortType notifierPT = brokerLocator.getNotifierPortTypePort(notifierEPR);
notifierPT= GCUBERemotePortTypeContext.getProxy(port, scope);
brokerPT.subscribeToTopic(mess);