cancel
Showing results for 
Search instead for 
Did you mean: 

Events and Notification

Former Member
0 Kudos

Hi,

Can we capture record level events (i.e Record added or modified), when it is created in Data Manager using java api's SP05?

Thanks,

Priya.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello, Priya!

Yes, we can

Look at package

com.sap.mdm.notification

and

com.sap.mdm.notification.event

Take especial view on

AbstractDataListener

and

RecordEvent

http://help.sap.com/javadocs/MDM/SP06P2/index.html

Former Member
0 Kudos

Hi,

Thanks for the reply.

RecordEvent is not present in SP05, we have only DataEvent.

but, under data lister we have 3 methods

void recordAdded(DataEvent event)

A record was created event.

void recordModified(DataEvent event)

A record was modified event.

void recordRemoved(DataEvent event)

A record was deleted event.

But using this I am not able to capture the Record Event.

http://help.sap.com/javadocs/MDM/SP05/

Thanks,

Priya.

Former Member
0 Kudos

Wow! Really, right u r!! i'm sorry, i've already on SP06...

so... API for listening of SP05 is really poor....

hm... may be u forget to use method

EventDispatcher.registerDataNotifications()

??

look there is my simple example which is work fine on my MDM SP06 may be it helps u

        try {
            EventDispatcher ed = new EventDispatcher(gate.getServer());
            ed.addListener(new AbstractDataListener() {

                @Override
                public void recordAdded(RecordEvent re) {
                    RecordId r = re.getRecordId();
                    TableId t = re.getTableId();
                    System.out.println("Hura!!!");
                }
            });
            ed.registerDataNotifications("Admin", "", gate.getRepository(), gate.getRegion());
            Thread.sleep(60000);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

try to replace RecordEvent with DataEvent and i think that example should work on SP05.

Former Member
0 Kudos

Hi,

Thanks for the sample Code.

Even I have a similar type of Code :

public class DataChangeEvent implements Runnable

{

//Server Name

private String serverName = "";

//Repository Name

private String repositoryName = "";

// DB-Server Name

private String dbmsName = "";

// User name

private String userName = "";

// Password

private String userPassword = "";

public void run()

{

RepositoryIdentifier repId = new RepositoryIdentifier(repositoryName,dbmsName,DBMSType.ORACLE);

int eventType = DataEvent.Type.RECORD_MODIFIED;

System.out.println("eventType : "+eventType);

try {

EventDispatcher evtDisp = new EventDispatcher(serverName);

evtDisp.addListener(new AbstractDataListener()

{

@Override

public void recordModified(DataEvent arg0)

{

System.out.println("Record: updated!!!");

}

});

evtDisp.registerDataNotifications(userName, userPassword, repId);

Thread.sleep(1000);

}

catch (InterruptedException ex)

{

ex.printStackTrace();

}

catch (Exception ex)

{

ex.printStackTrace();

}

System.out.println("Message");

}

}

When i run this thread and make modifications to records through Data manager, those events are not capatured in my listener.

I have a question --- Will Java API's listen to events that are generated through data manager.

Thanks,

Priya.

Former Member
0 Kudos

your thread sleep on one second, r u sure that it's enough time to modify record?

put your thread in 60seconds sleep as in my example, and run yuor thread, and when thread registered event listener and go in to sleep, try to modify records in the DataManager.

and put more debug information about when your thread start, register listener, exit...

U must understand that before your thread register listener - u could not get DataEvent, and after your thread finished u also can get DataEvent.

as for your question i think the answer is yes.

Former Member
0 Kudos

yes... I understand that... after the listener is registered only, an Exception can be thrown.

Running a Thread program for a long time... i.e around 60 seconds... will hang my system, so i generally run it with 20 sec or 25 secs.... and try to modify a data in data manager. The code i shared with you was sample one.. that is not the exact values that I uses while I am doing the testing.

Still the problem is not solved... I made many pointers, when then it is not listening to the events.

Am I doing anything wrong.

Thanks,

Priya.

Former Member
0 Kudos

Hi,

Has anybody tried this option, of creating events and listening to it using SP05?

Do we need to use the MDM4j jar files present in SP05 ? for listening to events or is there any other way possible in the new API's.

Thanks,

Priya.

Former Member
0 Kudos

In SP06 it's work fine and improve - u can get RecordId of records

Former Member
0 Kudos

Hi,

Thanks for the reply.

I think in SP05, we need to use the classes present in MDM4J.jar to listen to events.

Thanks,

Priya.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Priya,

Could you please throw some light on events and notifications with SP05 API. You mentioned MDM4j.jar which I have it, and give some pointers about the info on how to implement a basic listener.

Thanks

-Sai

Former Member
0 Kudos

Hi,

I have not tried the events and notification in MDM4j.jar.

I would propose, to move on to SP06 for working on events, because using MDM4j and new java api's in the same program is little confusing.

Thanks,

Priya.