An Event function is a Project function invoked from the Sync LU Schema tab.
An Event function is a Project function invoked from the Events LU Schema property.
Notes:
To create an Event function, refer to the steps in How to Create Project Functions.
When creating an Event function, make sure that:
The EventDataContext data type exposes a set of methods which allow getting additional information about the change such as:
Using the above information the function can execute any required business logic, for example, to write the Instance ID and the exception into a log table or publish a message to Kafka.
To attach an Event function to the LU Schema, go to Project Tree > Implementation > Logical Units/Data Products > [LU Name] > Schema to display the LU Schema window.
In the Sync Schema Properties tab, click icon to add an existing Event function from the list.
Select an Event Type.
To remove an Event function, click icon next to the Event function definition in the Schema Properties.
Save the LU Schema.
Go to Project Tree > Logical Units > [LU Name] > Schema to display the LU Schema window.
To attach the Event function using the LU Schema Properties tab, click the three dots next to the Events option to open the Event Collection Editor.
Click Add and then click the area next to Name to display the list of Event functions. Select the function from the list and select the Event Type.
(Optional) To add more Event functions to the same LU, click Add again, select the additional functions and select an event type for each function.
Click OK to close the Editor and then Save the LU Schema.
Create a new function with Function Type = Event Function.
Write the business logic, for example populate the IID, LU name and a message into a specific log table defined in the Fabric Common DB. In addition, publish a message to Kafka using a Broadway flow. Note that you need to add the exception handling to the function.
try {
String IID = eventDataContext.getInstanceId();
String luTypeName = eventDataContext.getLuTypeName();
log.info("Event function - instance ID = "+ IID);
log.info("Event function - LU type = "+ luTypeName);
Db ci = db("fabric");
ci.beginTransaction();
ci.execute("insert into DATA_CHANGES values (?,?,?,?)", IID, luTypeName, "NA", "Post Sync Success");
ci.commit();
fabric().execute("broadway CRM.publishCustomer iid="+ IID);
} catch (Exception e) {
log.error("The function eventFuncSuccess failed: "+e.getMessage(),e);
}
Create a Broadway flow that publishes a message to Kafka.
Open the LU Schema's properties window and attach the Event function to the Events property.
An Event function is a Project function invoked from the Sync LU Schema tab.
An Event function is a Project function invoked from the Events LU Schema property.
Notes:
To create an Event function, refer to the steps in How to Create Project Functions.
When creating an Event function, make sure that:
The EventDataContext data type exposes a set of methods which allow getting additional information about the change such as:
Using the above information the function can execute any required business logic, for example, to write the Instance ID and the exception into a log table or publish a message to Kafka.
To attach an Event function to the LU Schema, go to Project Tree > Implementation > Logical Units/Data Products > [LU Name] > Schema to display the LU Schema window.
In the Sync Schema Properties tab, click icon to add an existing Event function from the list.
Select an Event Type.
To remove an Event function, click icon next to the Event function definition in the Schema Properties.
Save the LU Schema.
Go to Project Tree > Logical Units > [LU Name] > Schema to display the LU Schema window.
To attach the Event function using the LU Schema Properties tab, click the three dots next to the Events option to open the Event Collection Editor.
Click Add and then click the area next to Name to display the list of Event functions. Select the function from the list and select the Event Type.
(Optional) To add more Event functions to the same LU, click Add again, select the additional functions and select an event type for each function.
Click OK to close the Editor and then Save the LU Schema.
Create a new function with Function Type = Event Function.
Write the business logic, for example populate the IID, LU name and a message into a specific log table defined in the Fabric Common DB. In addition, publish a message to Kafka using a Broadway flow. Note that you need to add the exception handling to the function.
try {
String IID = eventDataContext.getInstanceId();
String luTypeName = eventDataContext.getLuTypeName();
log.info("Event function - instance ID = "+ IID);
log.info("Event function - LU type = "+ luTypeName);
Db ci = db("fabric");
ci.beginTransaction();
ci.execute("insert into DATA_CHANGES values (?,?,?,?)", IID, luTypeName, "NA", "Post Sync Success");
ci.commit();
fabric().execute("broadway CRM.publishCustomer iid="+ IID);
} catch (Exception e) {
log.error("The function eventFuncSuccess failed: "+e.getMessage(),e);
}
Create a Broadway flow that publishes a message to Kafka.
Open the LU Schema's properties window and attach the Event function to the Events property.