Locate event brokers.

# EventBrokerDiscovery Service

Overview

Usage

## Overview

The EventBrokerDiscovery Service provides the ability to locate one or more EventBroker services that can process a particular event. The EventBrokerDiscovery Service has the ability to locate brokers that have been deployed within the Discovery Service framework via Foundation Service deployment utilities. Likewise, the EventBrokerDiscovery Service can locate brokers that have been instantiated as standalone applications. Once an EventBrokerDiscovery service has been obtained, it can be used to send synchronous or asynchronous event requests for processing.

## Usage

To use the EventBrokerDiscovery Service it must be configured and deployed as a foundation service. Configuring foundation services is accomplished with the Foundation Services Manager Plug-in within the SAS Management Console application. Configuration information that is specific to an EventBrokerDiscovery service is contained within its initialization data. This information specifies details about how to locate brokers that have been deployed as standalone applications and have registered themselves with a remote object registry. The structure of this initialization data contains entries for each broker that has been registered to an RMI registry and thus is able to be looked up. Each entry is represented in URL format as follows:

    <EventBrokers>
       <Location url="//host:port/name"/>
       <Location url="//host:port/name"/>
                          ...
    </EventBrokers>

### Using the EventBrokerDiscovery Service

The following code segment shows how to obtain an EventBrokerDiscovery service after it has been deployed.

    final Class[] desiredServiceCapabilities = new Class[] {
        com.sas.services.events.discovery.EventBrokerDiscoveryServiceInterface.class};

    _eventBrokerDiscoveryService = (EventBrokerDiscoveryServiceInterface)
        DiscoveryService.defaultInstance().findService(new ServiceTemplate(desiredServiceCapabilities,
                                                                           null));//no additional filter criteria

Once an instance of an EventBrokerDiscovery service has been obtained it can then be used to locate desired EventBroker services. The following code segment locates all event brokers that can process a broadcast type of event that is named myEvent.

    Set brokerRefs = null;
    brokerRefs = _eventBrokerDiscoveryService.locateBrokers("myEvent",
                                                            EventBrokerDiscoveryServiceInterface.EVENT_TYPE_BROADCAST,
                                                            EventBrokerDiscoveryServiceInterface.LOCATE_ALL);

    // iterate over brokers
    Iterator iterator = brokerRefs.iterator();
    while( iterator.hasNext() )
    {
       EventBrokerServiceInterface _eventBrokerService = (EventBrokerServiceInterface) iterator.next();

       // send an event to be processed synchronously
       _eventBrokerService.sendSyncEvent(event);
    }