You can use wsadmin commands to control whether Dynamic Event Framework (DEF) events are
emitted synchronously or asynchronously.
About this task
By default, the Dynamic Event Framework is configured
to deliver a synchronous event flow. With synchronous event transmission,
an application waits for successful event delivery before it proceeds
with the rest of its transaction.
You can use commands to configure
events to be transmitted asynchronously. In an asynchronous flow,
an application places events on a queue and proceeds with processing.
Each
cell has a Dynamic Event Framework configuration. That configuration
is shared by the DEF component that runs in every Java virtual machine
in that cell. You can change the default synchronicity behavior for
the DEF configuration to run asynchronously for a specified event
point key. For more information about event point keys, see Event point key and filter.
This
procedure uses wsadmin scripting. For information about the wsadmin
commands that are used in these scripts, see Commands for the AdminConfig object using wsadmin
scripting.
Procedure
- Create a DefSynchronicityConfig object for the cell that emits events. This synchronicity configuration object controls whether emission for an event point key is
run synchronously or asynchronously.
- Connect to the wsadmin client by entering the following command:
wsadmin.bat -lang jython
wsadmin.sh -lang jython
- Locate the cell identifier.
cellid = AdminConfig.list('Cell')
- Create a DefSynchronicityConfig object.
sConfigId = AdminConfig.create('DefSynchronicityConfig', cellid, '[]')
- Create DefSynchronicityRule objects and filter options in the cell that emits events.
- Add DefSynchronicityRule objects. DefSynchronicityRule objects are container objects that provide a way to group sets of related
event point filters for easier management.
- Give the rule a name that identifies its use. In this case, the rule is named "asyncAll"
because the rule specifies that all events from all applications will run
asynchronously.
sRuleOptions = [['ruleId','asyncAll']]
- Create the rule.
sRule = AdminConfig.create('DefSynchronicityRule',sConfigId,sRuleOptions)
- Add event point filters. Repeat this step for each new filter that you want to add.
- Provide the attributes for an event point filter. For each of the seven attributes, provide a
specific value, or use an asterisk (*) to accept all values for that attribute. The values in the
following example mean that all events from all applications will run
asynchronously.
sFilterOptions = [['filterId','asyncAll-filter'],['appName','*'],['version','*'],['componentType','*'],['componentName','*'],['elementType','*'],['elementName','*'],['nature','*']]
- Create the event point filter.
sFilter = AdminConfig.create('DefFilter',sRule,sFilterOptions)
- Save the new DefSynchronicityConfig object.
AdminConfig.save()
- Reload the configured event listeners to pick up the changes that were made in the cell that
emits events.
- Get a list of DefManagement names.
dmList = AdminControl.queryNames('type=DefManagement,*').splitlines()
- Reload the configured event listeners for each item in DefManagementList. You can use a Jython
loop structure in a script or run the commands individually, as in the following example for a
three-cluster topology. Add more commands if there are more than three clusters.
AdminControl.invoke(dmList[0],'reloadConfiguredEventListeners')
AdminControl.invoke(dmList[1],'reloadConfiguredEventListeners')
AdminControl.invoke(dmList[2],'reloadConfiguredEventListeners')
In a single cluster environment, DefManagementList contains only one
item.
AdminControl.invoke(dmList[0],'reloadConfiguredEventListeners')
- Save the configuration settings.
AdminConfig.save()
Results
If any event point filter matches the event point key, the
event is emitted asynchronously. Then, the event is formatted and
placed on a JMS queue. The events are distributed according to the
rules in the DEF configuration. If no event point filter matches,
the event is distributed to all listeners in the current JVM on the
current thread.
Example
This example puts together the configuration script for the cell that emits events. The DEF event
listeners must be refreshed before this new configuration is applied.
cellid = AdminConfig.list('Cell')
sConfigId = AdminConfig.create('DefSynchronicityConfig', cellid, '[]')
sRuleOptions = [['ruleId','asyncAll']]
sRule = AdminConfig.create('DefSynchronicityRule',sConfigId,sRuleOptions)
sFilterOptions = [['filterId','asyncAll-filter'],['appName','*'],['version','*'],['componentType','*'],['componentName','*'],['elementType','*'],['elementName','*'],['nature','*']]
sFilter = AdminConfig.create('DefFilter',sRule,sFilterOptions)
AdminConfig.save()
dmList = AdminControl.queryNames('type=DefManagement,*').splitlines()
AdminControl.invoke(dmList[0],'reloadConfiguredEventListeners')
AdminControl.invoke(dmList[1],'reloadConfiguredEventListeners')
AdminControl.invoke(dmList[2],'reloadConfiguredEventListeners')
AdminConfig.save()
What to do next
If you find at some time that you must delete a DefSynchronicityConfig
object, use a script such as this one:
remId = AdminConfig.list('DefSynchronicityConfig')
rem = AdminConfig.remove(remId)
AdminConfig.save()