|
Summary: The NotifyDelegator is a convenient and efficient mechanism for registering notifications. These notifications are delivered as remote events for matching Entries.
Deprecated in GigaSpaces 6.0 OverviewThe NotifyDelegator is a convenient and efficient mechanism for registering notifications. These notifications are delivered as remote events for matching entries. A Notify registration triggers notification only when there is an exact match between a specified template and an entry arriving into the space. Thus, an entry can only match a single notify template. In situations where an entry must match different templates, multiple write/update operations are required, which impact on performance and scalability. Tokenized templates provide a simple and scalable mechanism that allows notifications of several different notify templates (each with a different token field value) to be triggered for a single space operation. This approach relies on fast indexes to effectively locate matching templates, without impacting on performance and scalability due to the fact that numerous notify templates have been registered. How it WorksA TokenQuery object is constructed with the user's entry and the chosen tokenized field. The TokenQuery object is used as the template object of the NotifyDelegator constructor.. Each token-template is automatically indexed by its token field value (It is not advisable, and in effect useless, to define it as an index field in the class). The token-template is then used to register notifications. MyEntry myEntry = new MyEntry(...); myEntry.tokenField = "token1"; TokenQuery tkTemplate = new TokenQuery( myEntry, "tokenField" ); NotifyDelegator nDelegator = new NotifyDelegator(space, tkTemplate,...); When a user Entry is written to the space, the tokenized field will be used for matching notify templates. The tokenized field is a string of tokens separated by a defined delimiter (a separator character). By default, this is a single space-character, but can be configured through the space configuration file, using the following parameter: <engine> <tokenized_fields_delimiter>;</tokenized_fields_delimiter> ... </engine> When performing space operations, each token (in the tokenized field of the written Entry) will trigger notifications for matching templates. Thus, a single operation can trigger different notify registrations. For example, consider a mailing list with different defined groups. You can send mail to all members in the group, or explicitly define sub-groups. A single write operation will trigger notifications for each of the different tokens (assuming a matching template was registered). MyEntry myEntry = new MyEntry(...); myEntry.tokenField = "token1;token2;token3"; spaceProxy.write(myEntry, null, lease);
In the following figure, a client has registered three notify templates, each with a different token field, with a corresponding listener. By setting the tokenized field, a space operation triggers each notify registration for a matching Entry and a valid token.
Limitations
ExampleThe example demonstrates a mailing list, as mentioned above. The mailing list has recipients joining for specific groups. Each registration is based on a TokenQuery constructed with a MailMessage Entry and recipients as the tokenized field. By having the groupName and recipients fields set, we can trigger notifications for messages both per group or for a list of recipients.
String listOfRecipients = recipient_name1 + DELIMITER + recipient_name2 + ... ; MailMessage msg = new MailMessage( from, subject, body ); msg.setGroup(groupName); msg.addRecipients(listOfRecipients); spaceProxy.write(msg, null, 30 * 1000); com.j_spaces.core.client.EntryArrivedRemoteEventThe RemoteEvent parameter passed to the notify callback method can be used to retrieve the entry that triggered the notify operation using the EntryArrivedRemoteEvent.getEntry() method. The EntryArrivedRemoteEvent is the object sent to the RemoteEventListener.notify method. This class includes the following methods:
com.j_spaces.core.client.NotifyModifiersThe NotifyModifiers class provides the notify types flag constants and helper methods that allow you to identify the event type revived at the notify listener class method. The Notify Types:
NotifyModifiers helper Methods:
|
(works on Firefox 2 and Internet Explorer 7)
