public final class SampleEventConsumer extends Object
SampleEventListener
).
In the first sample below the consumer uses the EventingFactory
to
create an EventingService
object. The consumer then creates an
EventSubscriptionAttributes
object and specifies only the event
family of the events for which it wants to be notified of events. Specifying
only the family indicates interest in all event types within the family. The
subscribe method is then called to create the subscription.
package com.mycompany; import com.avaya.collaboration.eventing.EventSubscriptionAttributes; import com.avaya.collaboration.eventing.EventingFactory; import com.avaya.collaboration.eventing.EventingService; import com.avaya.collaboration.eventing.families.EventFamilyCall; final EventingService eventingService = EventingFactory.createEventingService(); final EventSubscriptionAttributes attr = EventingFactory.createEventSubscriptionAttributes(EventFamilyCall.FAMILY_NAME); final String subscriptionId = eventingService.subscribe(attr);The second sample starts out similar to the first one, except that specific event types within the family are specified in the subscription attributes. Additionally, the consumer adds "consumer private data" to the subscription attributes. Consumer private data is an arbitrary object that contains data associated with the subscription that the consumer would like to have returned as part of an event delivery. Then, filtering criteria is specified to further restrict which events the consumer wishes to receive. The filtering data specified here is applied against the metadata that a producer specifies. Finally, the subscribe method is called to create the subscription. Please note that providing filtering criteria in a subscription will only give desired results, if the producer of an event populates corresponding data elements in its metadata. Filtering on data elements for which no metadata is populated by any producer will mean that events will never be delivered for the subscription.
package com.mycompany; import com.avaya.collaboration.eventing.EventFilter; import com.avaya.collaboration.eventing.EventSubscriptionAttributes; import com.avaya.collaboration.eventing.EventingFactory; import com.avaya.collaboration.eventing.EventingService; import com.avaya.collaboration.eventing.families.EventFamilyCall; import com.avaya.collaboration.eventing.families.EventFamilySystem; // // Specify some events during construction of the attributes object. // final List<String> eventTypes = Arrays.asList(EventFamilyCall.EVENT_CALL_OFFERED_FROM_CALLING_PARTY, EventFamilyCall.EVENT_CALL_ANSWERED); final EventSubscriptionAttributes attr = EventingFactory.createEventSubscriptionAttributes(EventFamilyCall.FAMILY_NAME, eventTypes); // // Add some events - method 1 // attr.addEventType(EventFamilyCall.EVENT_CALL_OFFERED_FROM_CALLING_PARTY).addEventType( EventFamilyCall.EVENT_CALL_ANSWERED); // // Add some events - method 2 // attr.getEventTypeList().add(EventFamilyCall.EVENT_CALL_OFFERED_FROM_CALLING_PARTY); attr.getEventTypeList().add(EventFamilyCall.EVENT_CALL_ANSWERED); // // Add some events - method 3 // final List<String> eventsToAdd = Arrays.asList(EventFamilyCall.EVENT_CALL_OFFERED_FROM_CALLING_PARTY, EventFamilyCall.EVENT_CALL_ANSWERED); attr.getEventTypeList().addAll(eventsToAdd); // // Set opaque data I want returned to me // final Serializable myPrivateData = "my data"; attr.setConsumerPrivateData(myPrivateData); // // Do some additional filtering // final EventFilter ef = EventingFactory.createEventFilter(); ef.setCorrelationId("some correlation ID"); ef.addCriterion(EventFamilyCall.FILTER_UCID, "some call ID"); attr.setFilter(ef); final String subscriptionId = EventingFactory.createEventingService().subscribe(attr);
Copyright © 2014 Avaya. All Rights Reserved.