SAS Event Stream Processing is a powerful solution to analyze streaming data and take appropriate action instantly. When designing your ESP model, you might face some challenges regarding the test, simulation, performance analysis and workload management of your streaming application. That’s where the Event Generator comes in. An Event Generator is an ESP object that generates event streams and publishes them into an event stream processing model. The Event Generator, which is new in SAS ESP 4.1/4.2, is very useful:
Let's go into more details.
Design an Event Generator
An Event Generator is an XML string that cannot be designed in ESP Studio. Event Generators can be created, destroyed, started, and stopped through the SAS Event Stream Processing HTTP interface (REST admin API). Let’s have a look at an Event Generator complete example:
The "publish-target" tag identifies the ESP source window that we want to publish events to.
The "resources" tag defines the resources from which you can read maps, lists, and sets to be accessed from your event generation functions.
Resources can also point to external files.
The "init" section is aimed to initialize a set of values upon the start of the event generation. The resources (properties) defined above are referenced here using # symbols (e.g. #brokers, #venues).
And the "fields"tag defines the event values to be generated using a set of functions. They are based on the functions defined in Functional Window and Notification Window Support Functions in SAS Event Stream Processing: Programming Reference.
For example, the "listItem(#symbols,random(0,$numSymbols))" will return a random item from the defined list of symbols, the random function returning a number between 0 and $numSymbols.
Run an Event Generator
Once you have designed a valid Event Generator, next steps are to create it by pushing the XML into an ESP XML server and start it. Here is the command to create it. The URL means that you want to create an Event Generator called myFirstEG in the according ESP server.
Note: this example assumes you have an ESP XML Factory Server running with an admin port of 5556.
You should see the following:
If you look to the linux terminal where you started the ESP XML Factory Server (assuming you started it with the -loglevel "event.generator=trace"), you should see how the Event Generator is initialized:
Then, you are ready to start your Event Generator with the following command:
This command tells the Event Generator to load 3000 events, at a rate of 50 events per second with a blocksize of 5 events.
You should see the following:
If you look to the linux terminal where you started the ESP XML Factory Server (assuming you started it with the -loglevel "event.generator=trace"), you should see how the Event Generator publishes events:
Now it is running, you should see some events coming in your ESP model, so that you can check the consistency of your model and your rules.
You have additional REST API methods:
Finally, the real rate (number of events published per second) is defined by the maximum value of either blocksize or rate. Here are several examples to illustrate this:
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.