on 03-17-2008 9:56 PM
I checked this thread () and it indicates that there may be missing functionality to the MDM listener event model. However, the problems described in this thread are not the ones I encounter. Here is some sample code:
public class ListenerTest implements DataListener {
...
public static void main(String[] args) {
ListenerTest app = new ListenerTest();
try {
// get connection
ConnectionPool connections = null;
connections = ConnectionPoolFactory.getInstance(props.getServerName());
RepositoryIdentifier repId = new RepositoryIdentifier(props.getRepositoryName(),
props.getDbmsName(), DBMSType.ORACLE);
// get list of available regions for the repository
final GetRepositoryRegionListCommand regionListCommand =
new GetRepositoryRegionListCommand(connections);
regionListCommand.setRepositoryIdentifier(repId);
regionListCommand.execute();
final RegionProperties[] regions = regionListCommand.getRegions();
// set up event dispatcher
EventDispatcher ed = new EventDispatcher(props.getServerName());
ed.addListener(app);
ed.registerDataNotifications(props.getUserName(),
props.getPassword(), repId, regions[0]);
ed.registerRepositoryNotifications(props.getUserName(),
props.getPassword(), repId);
ed.registerGlobalNotifications();
while (true) {
Thread.yield();
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
System.out.println(ex);
}
}
} catch (ConnectionException e) {
e.printStackTrace();
} catch (CommandException e) {
e.printStackTrace();
}
}
// implement events
public void recordAdded(RecordEvent evt) {
System.out.println(evt.getServerName());
}
...
}
Whenever I generate a data event in the repository, I get this error message:
Mar 17, 2008 5:28:26 PM com.sap.mdm.internal.net.ConnectionImpl finalize
INFO: Disconnect was not called. Cleaning up connection in finalize.
I have tried to find code samples for the new API but only found the one linked to at the top of this posting. My questions are:
1. Why am I getting the finalize error whenever an event is generated?
2. Are there any working code samples for MDM listeners using the new Java API that I am unaware of?
I am able to use the MDM4J API to create listeners, but the event model is very limited compared to the new API.
Any help is greatly appreciated.
Richard,
Thank you for the information. I will take up the error that I am receiving in a separate post. (I tried to award points, but I don't know if they will be registered. The Forum doesn't appear to be working properly.)
Best Regards,
Doug
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Doug,
The only problem i see is how you're getting the instance of EventDispatcher.
You can't just create an instance, you have to go through the EventDispatcherManager.
//get an instance of EventDispatcherManager
EventDispatcherManager edm = EventDispatcherManager.getInstance();
//get an instance of EventDispatcher for your Master Data Server
EventDispatcher ed = edm.getEventDispatcher("server name");
//add the listener to the event dispatcher
ed.addListener(app);
//register the event dispatcher for notifications e.g. data, repository, etc...
ed.registerDataNotifications(props.getUserName(),
props.getPassword(), repId, regions[0]);
ed.registerRepositoryNotifications(props.getUserName(),
props.getPassword(), repId);
ed.registerGlobalNotifications();
Hope this helps,
Richard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll award points. Really, I will.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.