Apama Documentation : Developing Apama Applications : Developing Apama Applications in Event Modeler : Working with Blocks Created from Scenarios : Background for using scenario blocks
Background for using scenario blocks
To use scenario blocks in a main scenario, it is helpful to understand the implementation model. Consider a deck of cards with each card stacked on top of the other cards. Each card represents a sub-scenario, which is an instance of the source scenario.
When a sub-scenario generates an update event, that sub-scenario pops to the top of the stack of sub-scenarios, like you might move a card to the top of a deck. When a sub-scenario is at the top of the stack of sub-scenarios, you can access the values associated with that sub-scenario. Any time you can access the values associated with a sub-scenario, that sub-scenario is the context sub-scenario. For example, when a sub-scenario completes its processing, the scenario block sends an update event to its output feed. This update event makes the completed sub-scenario the context instance. Consequently, you can do something like this:
When instance status from MyScenarioBlock(output) = "ENDED"
Then  quantity = quantity + subquantity from MyScenarioBlock(output)
If quantity is a variable in the main scenario, this action increases the value of the quantity variable upon the completion of each sub-scenario. You do not need to first retrieve a sub-scenario to obtain the value of its subquantity variable.
As you can see, one way to operate on a particular sub-scenario is to wait for that sub-scenario to be the context sub-scenario. Another way to operate on a particular sub-scenario is to make that sub-scenario be the context sub-scenario. You do this by specifying the context ID of the sub-scenario you want to operate on and then calling the retrieve operation.
A main scenario can use two or more instances of the same scenario block. Each scenario block manages only the sub-scenarios it creates. However, you can change this according to the value you specify for the scenario block inheritExternalInstances parameter. See Inheriting sub-scenarios.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback