Before you can obtain an emitter, there must be at least one emitter
factory profile configured.
Before you begin
For each emitter factory profile, an emitter factory is automatically
created and is accessible using the JNDI name of the emitter factory profile.
Why and when to perform this task
To obtain an emitter, follow these steps:
Steps for this task
- Perform a JNDI lookup specifying the name of the emitter factory
you want to use for your emitter. This is the JNDI name specified
by an administrator when defining an emitter factory profile.
- Call the getEmitter() method of the emitter factory. The returned object is an emitter configured according to the
options defined in the emitter factory profile you specified. If the emitter
factory is unable to obtain an emitter, it throws an EmitterException exception.
Note: If
your event source is a J2EE client application running in a secure environment,
and the emitter profile you are using specifies asynchronous transmission
profiles, you must specify a JMS user name and password in order to get an
emitter. To do this, use the getEmitter(String, String) method, passing
the JMS user name and password you want to use. For more information, refer
to the Javadoc documentation for the com.ibm.events.emitter class.
Example
The following code fragment obtains an emitter configured with
the profile
Default:
import javax.naming.*
import com.ibm.events.emitter.*
Context context = new InitialContext();
EmitterFactory emitterFactory =
(EmitterFactory) context.lookup("com/ibm/events/configuration/emitter/Default");
Emitter emitter = emitterFactory.getEmitter();