Creating a New BrokerEvent
Before your BrokerClusterPublisher application can publish or deliver an event it must create the event and set the event's fields. The following example contains an excerpt from a sample application that shows the creation of a new event. The constructor takes the following parameters:
A
BrokerClusterPublisher reference
The name of the event type. In the following example, the event scope is
Sample and the event type name is
SimpleEvent.
class ClusterPublish1
{
static String broker_host = "localhost";
static String broker_name = null;
static String client_group = "default";
. . .
public static void main(String args[])
{
BrokerClusterPublisher bcp;
BrokerEvent e;
. . .
/* Create a BrokerClusterPublisher */
. . .
/* Create a BrokerEvent */
try {
e = new BrokerEvent( bcp, "Sample::SimpleEvent");
} catch (BrokerException ex) {
System.out.println("Error on creating new BrokerEvent \n"+ex);
return;
}
. . .