This guide provides several equivalent examples with a couple of History Eventing producers, both adding an event value as a history entry. In this way it is shown how using the FIM History Eventing producer simplifies the user input and prevents it from too complex filter definitions.
The FIM History Eventing Producer is interested only in configurations, which group is exactly the one defined in com.prosyst.mbs.services.history.producer.ItemEventingConfigurationConstants.GROUP, i.e "mbs/history/eventing/fim" from the examples below, unlike the group of the General History Eventing Producer – "mbs/history/eventing".
1. Property-changed events
{
"group": "mbs/history/eventing",
"tokenPatterns": {
"uid": "${uid}",
"property.name": "${property.name}"
},
"namespacePattern": "test",
"id": "1",
"properties": {
"topic": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"filter": "(&(name=mySwitch)(property.name=state)(tags=tag1)(tags=tag2))",
"value": "property.value.new"
}
}
{
"group": "mbs/history/eventing/fim",
"tokenPatterns": null,
"namespacePattern": "test",
"id": "2",
"properties": {
"name": "mySwitch",
"property.name": "state",
"tags": "[\"tag1\",\"tag2\"]"
}
}
You can also add the same FIM History configurations programmatically using java code:
private void addFIMEventingDemoConfiguration(HistoryConfigurationAdmin configAdmin) {
// use ItemEventingConfigurationConstants to set the configuration properties
Map<String, String> fimEventingProducerProps = new HashMap<String, String>(3, 1.0f);
fimEventingProducerProps.put(ItemEventingConfigurationConstants.NAME, "mySwitch");
fimEventingProducerProps.put(ItemEventingConfigurationConstants.PROPERTY_NAME, "state");
fimEventingProducerProps.put(ItemEventingConfigurationConstants.TAGS, "[\"tag1\",\"tag2\"]");
configAdmin.addConfiguration(ItemEventingConfigurationConstants.GROUP, "test", null, firmEventingProducerProps);
}
2. Operation-executed events
{
"group": "mbs/history/eventing",
"tokenPatterns": {
"uid": "${uid}",
"operation.name": "${operation.name}"
},
"namespacePattern": "test",
"id": "3",
"properties": {
"topic": "com/prosyst/mbs/services/fim/FunctionalItemEvent/OPERATION_EXECUTED",
"filter": "(&(name=mySwitch)(operation.name=toggle)(tags=tag1)(tags=tag2))",
"value": "val"
}
}
{
"group": "mbs/history/eventing/fim",
"tokenPatterns": null,
"namespacePattern": "test",
"id": "4",
"properties": {
"name": "mySwitch",
"operation.name": "toggle",
"tags": "[\"tag1\",\"tag2\"]",
"value": "val"
}
}
You can also add the same FIM History configurations programmatically using java code:
private void addFIMEventingDemoConfiguration(HistoryConfigurationAdmin configAdmin) {
// use ItemEventingConfigurationConstants to set the configuration properties
Map<String, String> fimEventingProducerProps = new HashMap<String, String>(4, 1.0f);
fimEventingProducerProps.put(ItemEventingConfigurationConstants.NAME, "mySwitch");
fimEventingProducerProps.put(ItemEventingConfigurationConstants.OPERATION_NAME, "toggle");
fimEventingProducerProps.put(ItemEventingConfigurationConstants.TAGS, "[\"tag1\",\"tag2\"]");
fimEventingProducerProps.put(EventingConfigurationConstants.PROPERTY_VALUE, "val");
configAdmin.addConfiguration(ItemEventingConfigurationConstants.GROUP, "test", null, firmEventingProducerProps);
}