All event consumers have to make calls to the XEMS event consumer setup routines before receiving XEMS events. These routines perform required setup, and are XEMS implementation dependent. The setup routines are designed to work with the register routines to save the state of a consumer environment so that the consumer can be restarted with a call to the
The event consumer interface allows event consumers to register and unregister with XEMS. Once registered, consumers can add and delete event filters define what events they are interested in. When XEMS receives events from event suppliers, the event will be filtered using the event filter, and only the matching events will be forwarded on to the interested consumers.
ems_consumer_start - Consumer Start
#include <xems.h>
void ems_consumer_start(
ems_string_t consumer,
ems_ulong_int flags,
ems_handler_t hfunc[],
ems_uuid_t ** uuid,
ems_handle_t * handle[],
ems_error_t * status);
This routine should be called at the beginning of each event consumer before making any register calls. It will create a ems_uuid_t to uniquely identify this event consumer and perform any local consumer initialization required. The routine can be called the first time a consumer starts, or when a consumer is restarting and wishes to reestablish the environment already established. If a new environment is being established, then the uuid parameter should contain NULL. When reestablishing an environment, then the uuid from the initial call should be passed in.
- Input
- consumer
specifies the consumer name. This parameter can be null if the uuid is specified.
- flags
reserved for future use.
- hfunc
null terminated array of event handler routines. All event handler routines that will be used in anems_consumer_register() call must be in this array.
- uuid
the unique consumer id returned from a previous call toems_consumer_start() .
- Output
- uuid
the unique consumer id for this consumer environment.
- handle
returns an XEMS handle which can be used on subsequent calls to XEMS routines. This handle also represents a consumer filter_group/event handler association.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible ems status codes are:
ems_s_status_ok
ems_s_no_memory
ems_s_consumer_already_started
ems_consumer_stop - Consumer Stop
#include <xems.h>
void ems_consumer_stop(
ems_error_t * status);
This routine should be called at the end of each event consumer. It will perform any consumer cleanup required.
- Output
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible XEMS status codes are:
ems_s_status_ok
ems_s_consumer_not_started
ems_push_consumer_register - Push Consumer Register
#include <xems.h>
void ems_push_consumer_register(
ems_netname_t * hostname,
ems_filtername_list_t * filter_group,
int hfunc_index,
ems_handle_t * handle,
void * arg,
ems_error_t * status);
This routine is used by XEMS event consumers to register as a push consumer with XEMS. This routine contacts an event service, and registers this filter group/handler association with that event service. This routine may be called multiple times per consumer with different hostnames, filter_groups, and handler functions. The handler function specified is started up the in the consumer process.ems_consumer_start() has to have been called before this routine (to establish the consumer name and uuid).
- Input
- hostname
is the name of the host machine where the Event Service is running. If the hostname is NULL, then the local host is assumed.
- filter_group
is a list of event filter names which will define this consumers initial event filter group. If filter_group is empty, no filter group is specified, and XEMS will not forward any events to this consumers until the consumer makes a call toems_add_event_to_group() .
- hfunc_index
the index into the event handler array of the event handler function to call if an event passes the filter group and is sent to the consumer. The event handler array is the hfunc[] parameter to theems_consumer_start() routine.
- Output
- handle
returns an XEMS handle which can be used on subsequent calls to XEMS routines. This handle also represents a consumer filter_group/event handler association.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_s_no_memory
ems_s_already_registered
ems_pull_consumer_register - Pull Consumer Register
#include <xems.h>
void ems_pull_consumer_register(
ems_netname_t * hostname,
ems_filtername_list_t * filter_group,
ems_handle_t * handle,
ems_error_t * status);
This routine is used by XEMS event consumers to register as a pull consumer with XEMS. This routine should be called once for each host that this consumer wants to receive events from.
- Input
- hostname
is the name of the host machine where the Event Service is running. If the hostname is NULL, then the local host is assumed.
- filter_group
is a list of event filter names which will define this consumers initial event filter group. If filter_group is empty, no filter group is specified, and XEMS will not forward any events to this consumers until the consumer makes a call toems_add_event_to_group() .
- Output
- handle
returns an XEMS handle which can be used on subsequent calls to XEMS routines.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_s_no_memory
ems_s_already_registered
ems_consumer_unregister - Consumer Unregister
#include <xems.h>
void ems_consumer_unregister(
ems_handle_t * handle,
ems_error_t * status);
This routine is used by XEMS event consumers to unregister with XEMS. This routine should be called once for each call toems_push_consumer_register() orems_pull_consumer_register() . The event consumer should call this routine before calling theems_consumer_stop() routine.
- Input
- handle
a handle returned from a call to one of the consumer register routines.
- Output
- handle
this routine will free up memory used by handle, and set handle to NULL.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_s_unknown_consumer
ems_add_filter_to_group - Add Event Filter to Group
#include <xems.h>
void ems_add_filter_to_group(
ems_handle_t handle,
ems_filtername_list_t * event_filters,
ems_error_t * status);
This routine is used by XEMS event consumers to add event filter names to a consumers event filter group. This routine can be called multiple times for each consumer.
- Input
- handle
must contain a valid consumer handle obtained fromems_push_consumer_register() orems_pull_consumer_register() .
- event_filters
contains a list of one or more event filter names to add to this consumers event filter group. consumers can use the names of new event filters after building them with theems_filter_add() routine, or existing filters which can be obtained by using theems_filter_get_namelist() routine.
- Output
- status
Returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_delete_filter_from_group - Delete Event Filter From Group
#include <xems.h>
void ems_delete_filter_from_group(
ems_handle_t handle,
ems_filtername_list_t * filter_name,
ems_error_t * status);
This routine is used by XEMS event consumers to delete event filter names from consumer event filter groups.
- Input
- handle
must contain a valid consumer handle obtained fromems_push_consumer_register() orems_pull_consumer_register() .
- filter_name
specifies the event filter name(s) to delete from the consumers event filter group.
- Output
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_get_filter_group - Get Filter Group
#include <xems.h>
void ems_get_filter_group(
ems_handle_t handle,
ems_filtername_list_t ** filter_group,
ems_error_t * status);
This routine returns a list of event filter names that comprise the consumers event filter group.
- Input
- handle
must contain a valid consumer handle obtained fromems_push_consumer_register() orems_pull_consumer_register() .
- Output
- filter_group
will contain the list of event filter names which are in the consumers event filter group. It is up to the requesting consumer to free the storage allocated for filter_group.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_consumer_get_registration - Get Consumer Registration
#include <xems.h>
void ems_consumer_get_registration(
ems_handle_t handle,
ems_netname_t ** hostname,
ems_filtername_list_t ** filter_group,
int* hfunc_index,
ems_error_t * status);
This routine returns the consumer registration information associated with a consumer handle.
- Input
- handle
must contain a valid consumer handle obtained fromems_push_consumer_register() orems_pull_consumer_register() .
- Output
- filter_group
will contain the list of event filter names which are in the event filter group which is associated with this consumer registration handle. It is up to the caller to free the storage allocated for filter_group.
- hostname
will contain the hostname of the event service associated with this consumer registration handle. It is up to the caller to free the storage allocated for hostname.
- hfunc_index
will contain the handler function index associated with this consumer registration handle. If the consumer is a pull consumer, then this value will be -1.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_consumer_pull - Consumer Pull
#include <xems.h>
void ems_consumer_pull(
ems_handle_t handle,
ems_event_t * event,
ems_error_t * status);
This routine is called by pull consumers to get an event from the event service. The event has to pass through the filter group set up by the pull consumer in order to receive the event. This routine does not return until an event is available.
- Input
- handle
must contain a valid consumer handle obtained fromems_pull_consumer_register() .
- Output
- event
will contain the event received from the pull operation from the event service.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_consumer_try_pull - Consumer Try Pull
#include <xems.h>
void ems_consumer_try_pull(
ems_handle_t handle,
ems_event_t * event,
ems_error_t * status);
This routine is called by pull consumers to get an event from the event service. The event has to pass through the filter group set up by the pull consumer in order to receive the event. This routine returns with a status ofems_s_no_event() when no event is available.
- Input
- handle
must contain a valid consumer handle obtained fromems_pull_consumer_register() .
- Output
- event
will contain the event received from the pull operation from the event service.
- status
returns the status code from this routine which indicates whether the routine completed successfully or, if not, why not.
The possible status codes are:
ems_s_status_ok
ems_s_no_event
Contents | Next section | Index |