Skip to main content

How do I print out the contents of a structured event?

  • September 2, 2014
  • 0 replies
  • 0 views

Product: OpenFusion Notification Service

Version: 2.1 and above

 

Description:

How do I print out the contents of a structured event?

 

Solution:

There is no utility available to display the contents of a structured event. This can be achieved through coding by using the relevant extract method for the data stored in Any types and requires knowledge of the type information stored in each part of the structured event.

Below is an example of a String stored in the variable header of the event and a long stored in the remainder_of_body:

StructuredEvent event = new StructuredEvent ();

EventType type = new EventType ("Telecom", "Alarm");

FixedEventHeader fixed = new FixedEventHeader (type, "event");

Property variable[] = new Property[1];
variable[0] = new Property ();
variable[0].name = "probableCauseQualifier";
variable[0].value = orb.create_any ();
variable[0].value.insert_string ("ALARM");

org.omg.CORBA.Any data = orb.create_any ();
data.insert_long (counter);

event.header = new EventHeader (fixed, variable);
event.filterable_data = new Property[0];
event.remainder_of_body = data;

To print the values in the variable header and the remainder of body the following code can be used:

int data1;
data1 = event1.remainder_of_body.extract_long ();

String vhead1 = null;
vhead1 = event1.header.variable_header[0].value.extract_string ();

System.out.println (" event A: " vhead1 " number " data1 );


#KnowledgeDocs
#notificationservice
#OpenFusion