Enrichment sample details
After you run the sample, you can study the source files to learn how the sample works.
Running the sample
- In the Java perspective, right-click the test client EnrichmentClient and select .
- Expand JUnit and select Enrichment Test.
- Click Run. The Console view opens and displays several messages. The
messages indicate that the test driver is connected and that the AccountInitialization event is
emitted and processed. An event was sent by the client application. The solution processed the event, a rule agent was triggered, and the following message was printed to the <InstallDir>/runtime/wlp/usr/servers/cisDev/logs/trace.log file:
a new account has been created for the customer Lee Stan, email: lstan@example.com, phone number: 9256757680
- Review the events in Insight Inspector,
which is a web application that you can use to review and troubleshoot
solutions:
- Switch to the Samples Console perspective.
- In the Sample Server view, click Insight Inspector opens in a web browser. Accept any security exception that is displayed. .
- In Insight Inspector,
click EnrichmentSolution. The solution timeline shows that the EnrichmentRuleAgent
processed an AccountInitialization event and emitted a SendMessageNewAccount
event.
The following image shows that the Account entity is created by the AccountInitialization event. This event sets the values of the accountId and the balance of the account. The emitted event, SendMessageNewAccount, is selected by default in the solution timeline. The attributes of this event are displayed in the Data tab. The values of the firstName, lastName, email, and phoneNumber in the event are retrieved from the database by using the accountId (accountId1). The event is emitted by the Initialization rule of the EnrichmentRuleAgent.
Source files
- EnrichmentSolution, the solution project
- EnrichmentRuleAgent, the rule agent that is used by the solution
- EnrichmentSolution - Java Model, which contains the Java™ interfaces of the solution
- EnrichmentSolutionBOM, the BOM of the solution
- EnrichmentExtension, which contains the integration of data from a database
- EnrichmentClient, which contains the JUnit test that submits the event and tests the enriched attributes
How this sample works
In this simplified solution, the rule agent processes the event by using a rule that prints a message after the account is created. The message contains the entity attributes that are enriched from the local Derby database, which has the name ENRICHMENT.
a customer provider is a data provider ,
accepts an email (text), returns a first name (text), a last name (text), a phone number (text).
The data provider extension class is fully defined in the extension project EnrichmentExtension. To see how the attributes are enriched, open the class EnrichmentExtension/src/customerEnrichment/Customer.java and review the processRequest method.
The solution is exported to a solution archive, which is deployed to the cisDev server by the solutionManager command. The database is created locally and populated. The Ant tasks that are used to deploy the sample and to create the database are defined in build.xml.
The EnrichmentClient project has a data folder that contains the script that creates and populates the database. In src/test, the project also contains the Java source code that is used to send the event.
Rebuilding the sample
After you use or modify the sample, you can rebuild it to its original state.
- In the Samples Commands view, open .
- Double-click redeploy to undeploy and redeploy the solution.