cancel
Showing results for 
Search instead for 
Did you mean: 

Deploying a Listener

Former Member
0 Kudos

Hello MDM Gurus,

I've created an Updatelistener as a java-project. Now I want to deploy it to my WAS, but how can it be done? (Ofcourse deploying it with Developer Studio is working)

The solution I'm looking for is that I can start and stop in manually, but I don't know how I should deploy it then.

Can somebody help me with this?

With kind regards,

Gerwin

Accepted Solutions (1)

Accepted Solutions (1)

siar_sarferaz
Explorer
0 Kudos

Hello Jansen,

how does your updatelistener work?

I need to syndicate whenever new records are added or old records updated. Kindly advice.

Best regards,

Siar

Former Member
0 Kudos

Hi Siar,

Like I said, you need to create a java-project in Developer Studio, for instance MDMListener. Create a package and add a java file ("MDMListener.java") to the project. I'll give you the code to get started. Please remember that this example code gives you a combined add and update listener. I think it must be pretty clear how to separate them. Further, I know there is something like AddSyndicationIDs in the CatalogData class, but I'm not sure if you need that one.

Next, your file should look like this:

public class MDMListener implements RecordAddedListener,RecordUpdatedListener {

private CatalogData catalog;

public MDMListener(CatalogData catalog) {

this.catalog = catalog;

}

public void recordAdded(RecordAddedEvent arg0) {

//Here arg0 contains the tablname and the recordId

// Put your code here for what your listener must do

}

public void recordUpdated(RecordAddedEvent arg0) {

//Here arg0 contains the tablname and the recordId

// Put your code here for what your listener must do

}

public static void main(String[] args) {

CatalogData catalog = new CatalogData();

//ESTABLISH A CONNECTION TO A REPOSITORY

int loginReturnCode = catalog.Login(<HOST>, <PORT>, <USER>, <PASSWORDR>, catalog.GetCodeRegion());

if (loginReturnCode == RC.RC_OK) {

System.out.println("Connected to Repository");

MDMListener myListener = new MDMListener(catalog);

catalog.AddRecordAddedListener(myListener);

catalog.AddRecordUpdatedListener(myListener);

// This is an important piece, because here it checks for changes ever 500ms

while(true) {

Thread.yield();

try {

Thread.sleep(500);

} catch (InterruptedException e1) {

System.out.println(e1);

}

}

}

}

}

I hope this gets you on your way. Also, be aware that if you start a listener in Developer Studio, it will remain active as long as you don't stop it. So deploying or starting the same program again without stopping the previous instance will result in multiple listeners running and performing at the same time.

With kind regards,

Gerwin

Former Member
0 Kudos

Siar,

By the way, isn't there some setting to setup a syndication server that automatically syndicates changed records?

I'm not that familiar with it, maybe somebody else on the forum knows?

With kind regards,

Gerwin

Former Member
0 Kudos

In Syndicator->Map Properties

Check Suppress unchanged record to create outbound of only modified record.

Former Member
0 Kudos

Hi Reo,

I know about that setting, however, you still have to syndicate manually then. What I understand is that it will have to syndicate automatically.

With kind regards,

Gerwin

Former Member
0 Kudos

Hi !

To syndicate records automatically you have to use component called MDM Syndication Server. It is stand alone component based on syndication map's, and defined ports (file system directory). For syndication server you have to provide configuration settings (file) where you set how frequently it will check for data updates in MDM repository.

Best regards, marcin

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Gerwin,

to have control over yours MDM listners deployed on WAS you can create Web module project in NW Developer Studio. In this project create servlet and place your listner startup and removal code in init() and destroy() methods.

Remember to set "load on startup" parameter of your servlet to 1 (or other number - if you have more than one servlet that should be initialized on application startup).

With "load on startup" parameter - on application startup your servlet will be created, and then new instance of listner can be attached to proper MDM repository event.

You can control your listner status using Visual Administrator - with Start and Stop application functions.

Second possible solution is to expose listner start / stop functions with created webservice where listners are implemented as a session EJB.

Best Regards, marcin

Former Member
0 Kudos

Hi Gerwin,

If your OS is a windows, you can create a Windows service for Java Application using many free tools available.

If you are using a *nix based system, you can create a daemon to start or stop manually/automatically.

HTH

--

Venkat