Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Event Manager Programmer's Guide: HP-UX 11i v3 Edition 1 > Chapter 4 Sample EVM Programming Operations

Dealing with Missed Events

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

If you are developing an application that subscribes for a set of events that can be posted in high volume over a short period, your program may occasionally be notified by the EVM daemon that it has missed one or more events. This occurs if the program has a significant amount of processing to do and is unable to handle when a new event arrives immediately, causing unhandled events to fill the connection buffers. It watches for notification of missed events by including the EvmREASON_EVENTS_MISSED reason in its callback function and displays a message that includes the number of events missed. For more information about missed events, see “Missed Events”.

Example 4-10 shows how to subscribe for all events and displays each event on stdout as it arrives.

Example 4-10 Dealing with Missed Events

#include <stdio.h>
#include <evm/evm.h>
#include<unistd.h>
void EventCB(EvmConnection_t conn, EvmCallbackArg_t cbarg,	EvmCallbackData_t *cbdata);
/*===============================================* Function: main()*===============================================*/
int main()
{ 	EvmConnection_t conn;	EvmStatus_t status;	int conn_fd;	
status = EvmConnCreate(EvmCONNECTION_LISTEN,	EvmRESPONSE_CALLBACK,NULL,EventCB,NULL,&conn);	
if (status != EvmERROR_NONE) 
{	fprintf(stderr,"Failed to create EVM listening connection\n");		
exit(1);	}	
status = EvmConnSubscribe(conn,NULL,"[name *]");		
/* This code segment subscribes for notification of all events.	*/	
if (status != EvmERROR_NONE) 
{	fprintf(stderr,"Failed to subscribe for event notification\n");	
exit(1);	}		
for (;;) 
{	status = EvmConnWait(conn,NULL);		
if (status != EvmERROR_NONE) 
{	fprintf(stderr,"Connection error\n");			
exit(1);		}		
if (EvmConnDispatch(conn) != EvmERROR_NONE) 
{	fprintf(stderr,"Connection dispatch error\n");			
exit(1);		}	}}
/*===============================================* Function: EventCB()*===============================================*/
void EventCB(EvmConnection_t conn, EvmCallbackArg_t cbarg,	EvmCallbackData_t *cbdata)
{ 	char buff[256];	switch (cbdata->reason) 
{	case EvmREASON_EVENT_DELIVERED:			
EvmEventFormat(buff, sizeof(buff), cbdata->event);			
fprintf(stdout,"Event: %s\n",buff);			
EvmEventDestroy(cbdata->event);			
/* To demonstrate missing events, sleep for one second after each event is received. 
This simulates a heavy processing load and ensures that the input connection buffer will be filled if the 
event load is heavy.*/			
sleep(1);			
break;	
/* The callback function is invoked with reason code EvmREASON_EVENTS_MISSED if the daemon is unable to 
send one or more missed events. The callback data member extension.eventMissedData.missedCount contains 
a count of the number of missed events.*/		
case EvmREASON_EVENTS_MISSED:
fprintf(stdout,"*** Missed %d incoming events\n",cbdata->extension.eventMissedData.missedCount);			
break;		
default:	break;	}}
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2007 Hewlett-Packard Development Company, L.P.