Configuring event emitters for asynchronous event delivery

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

  1. 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.
    1. Connect to the wsadmin client by entering the following command:
      For Windows operating system
      wsadmin.bat -lang jython
      For Linux operating systemFor UNIX operating system
      wsadmin.sh -lang jython
    2. Locate the cell identifier.
      cellid = AdminConfig.list('Cell')
    3. Create a DefSynchronicityConfig object.
      sConfigId = AdminConfig.create('DefSynchronicityConfig', cellid, '[]')
  2. Create DefSynchronicityRule objects and filter options in the cell that emits events.
    1. Add DefSynchronicityRule objects. DefSynchronicityRule objects are container objects that provide a way to group sets of related event point filters for easier management.
      1. 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']]
      2. Create the rule.
        sRule = AdminConfig.create('DefSynchronicityRule',sConfigId,sRuleOptions)
    2. Add event point filters. Repeat this step for each new filter that you want to add.
      1. 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','*']]
      2. Create the event point filter.
        sFilter = AdminConfig.create('DefFilter',sRule,sFilterOptions)
    3. Save the new DefSynchronicityConfig object.
      AdminConfig.save()
  3. Reload the configured event listeners to pick up the changes that were made in the cell that emits events.
    1. Get a list of DefManagement names.
      dmList = AdminControl.queryNames('type=DefManagement,*').splitlines()
    2. 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')
    3. 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()