IS-Notification

From Gcube Wiki
Revision as of 14:26, 23 November 2010 by Lucio.lelii (Talk | contribs) (How to produce notification for custom topics)

Jump to: navigation, search

Design

The IS-Notification is a library that provides a subscription/notification mechanism based on Remote Events. This library helps the clients to interact with the Notifier Service and allows:

  • for a Client or a Service (Subscriber) to subscribe for a Topic and receiving notifications
  • for a Service (producer) to register its own topic and sending notification.

Interface

  • public <T extends BaseNotificationConsumer> void registerToISNotification(T consumer,List<GCUBENotificationTopic> notifications, GCUBESecurityManager manager, GCUBEScope ... scope) throws ISNotifierException – this method registers a entity of type T (consumer) for a list of GCUBENotificationTopic in selected Scopes (scope) with a GCUBESecurityManager (manager) in the IS-Notifier;
  • public void unregisterFromISNotification( GCUBESecurityManager manager, List<GCUBENotificationTopic> notifications, GCUBEScope ... scope) throws ISNotifierException – this method unregisters the consumer for a list of GCUBENotificationTopic from the IS-Notifier in the selected scopes (scope) with a GCUBESecurityManager (manager);
  • public void registerISNotification (EndpointReferenceType producerEPR, List<? extends Topic> notifications, GCUBESecurityManager manager, GCUBEScope ... scope) throws ISNotifierException – this method registers the reference to a resource (producerEPR) that produces a list of topics (notifications) in the IS-Notifier in the selected scopes (scope) with a GCUBESecurityManager (manager);
  • public void unregisterISNotification (EndpointReferenceType producerEPR, List<? extends Topic> notifications, GCUBESecurityManager manager, GCUBEScope ... scope) throws ISNotifierException – this method unregister the reference to a resource (producerEPR) for a list of topics (notifications) in the IS-Notifier in the selected scopes (scope) with a GCUBESecurityManager (manager);
  • public boolean[] isTopicRegistered(GCUBESecurityManager securityManager, GCUBEScope scope, List<TopicData> topics) throws ISNotifierException - this methods checks if a topic (topic) registration is completed or not for a producer (producerEpr) in the IS-Notifier in the selected scopes (scope) with a GCUBESecurityManager (manager);

New Features

From version 1.4 this library contains new features:

  • the possibility to register for a client running outside a gcore container;
  • the possibility to register to a Topic specifying a 'precodition'. The 'precodition' is represented by an XPath specified at Topic creation time an evaluated producer-side. This feature reduces the number of messages exchanged between producer and consumer.

How to configure clients running outside the gCore container

To register a Topic outside a gCore cotnainer this library requires 2 steps of configuration:

  • modify the file $GLOBUS_LOCATION/etc/globus_wsrf_core/client-server-config.wsdd adding in the globalConfiguration session the parameter logicalHost
     ...
<globalConfiguration>
        <parameter name="containerThreads" value="1"/>
        <parameter name="containerThreadsMax" value="3"/>
 
         <!-- add the following line --> 
        <parameter name="logicalHost" value="yourhost"/> 
 
        <parameter name="sendXsiTypes" value="true"/>
        <parameter name="authenticationService"
                value="gsi/AuthenticationService"/>
     ...
  • start the client setting the GLOBUS_LOCATION system property
       java -DGLOBUS_LOCATION=$GLOBUS_LOCATION RegistrationTest

How to register a producer for a topic

To make a GCUBEService capable to produce notifcation for a topic we have, first of all, configure it.

In the deploy-server.wsdd for each port-type that represent a resource that will produce a notification add at the providers SubscribeProvider and GetCurrentMessageProvider:

<parameter name="providers" value="GCUBEProvider SubscribeProvider GetCurrentMessageProvider"/>

In the wsdl of such port-type add in the portType tag wsntw:NotificationProducer:

<portType name="ReadManagerPortType" wsdlpp:extends="wsntw:NotificationProducer provider:GCUBEProvider">

and import in the same file the namespace xmlns:wsntw="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl"

<wsdl:import namespace="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl" 
		location="../wsrf/notification/WS-BaseN.wsdl"/>

Now the service is ready to produce both properties topics and custom topic.

How to produce notification for custom topics

In your GCUBEWSResource declare the topic

... 
Resource extends GCUBEWSResource {
...
   private SimpleTopic updateTopic= new SimpleTopic(new QName(NS, "UpdateTopic");

add it to the list of topics of the GCUBEWSResource (it can be done on the overriding the initialiContainer() method)

..	
  @Override protected void initialiseContainers() throws Exception {
	super.initialiseContainers();
	...
	getTopicList().addTopic(updateTopic);
 
  }
...

In this way the topic is automatically registered by gcore at container start-up. After this we need to notify the event: