Here is the scenario:
LCDS has been setup to connect to a MySQL database using FlashBuilder RDS and Fiber. Changes made within the Flex client application are correctly synchronized between all clients.
There is an existing system in place that makes direct inserts and updates to the same MySQL database. Those inserts and updates need to be propagated to all Flex client applications. Is it possible to have LCDS "watch" the database for inserts / updates and send those changes to all Flex clients?
Solved! Go to Solution.
Views
Replies
Total Likes
You should not call refreshFill() etc, rather you should call the relevant CRUD method for the object changed, please see the Javadoc I linked to. For example:
public void createItem(String destination, Object item)
You use this method to indicate to to the Data Management Service that a new item has been created.
So on calling this method and committing the transaction, LCDS will take care of pushing the new object to clients etc.
Views
Replies
Total Likes
On the server side, you can invoke the relevant APIs on DataServiceTransaction (http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Javadoc/flex/data/DataServiceTransaction.html) to notify LCDS of changes made to the database. These will then be pushed across to the relevant clients.
Views
Replies
Total Likes
There is no functionality built-in to LCDS to monitor changes to a database. However, if you can intercept requests to change the database, they can be propagated to all the clients through LCDS.
Views
Replies
Total Likes
Do you have any sample code that shows how to do this?
Simply calling dataServiceTransaction.refreshFill(...) doesn't seem to send any data to the client.
Since I am using Fiber, I ultimately need to be able to generically notify the client of updates to the database. Or at least trigger LCDS to check for updates against the database and send the appropriate updates to the client.
Here is the current code that doesn't seem to work:
public void triggerRefresh() {
DataDestination dt = DataDestination.getDataDestination("Test");
DataMessage fillMessage = InternalMessage.createMessage();
fillMessage.setOperation(DataMessage.UPDATE_OPERATION);
DataServiceTransaction tx = DataServiceTransaction.begin(false);
Map identity = new HashMap();
identity.put("id", 184); // ID of record that has changed in db.
ArrayList props = new ArrayList();
props.add("Item"); // Class name and table name of changed object.
PropertySpecifier ps = PropertySpecifier.getPropertySpecifier(dt, props, true);
Object retObj = dt.getItemFromAdapter(identity, ps);
fillMessage.setBody((Object)retObj);
Collection<Object> result = (Collection<Object>)dt.getAdapter().invoke(fillMessage);
System.out.println(result); // MOS added
tx.refreshFill("Test", null, null);
tx.commit();
}
Any suggestions?
Thanks,
Collin
Views
Replies
Total Likes
Wow, everyone says this is possible but no one seems to know how to get it to work...
Views
Replies
Total Likes
We have many customers doing this. You need to check your RDBMS vendor's documentation for invoking Java code from triggers, for example, if you want to go to that level.
Views
Replies
Total Likes
You should not call refreshFill() etc, rather you should call the relevant CRUD method for the object changed, please see the Javadoc I linked to. For example:
public void createItem(String destination, Object item)
You use this method to indicate to to the Data Management Service that a new item has been created.
So on calling this method and committing the transaction, LCDS will take care of pushing the new object to clients etc.
Views
Replies
Total Likes
Damon,
Thanks for your response. Our issue is not how to get the info that the DB table has been updated with a trigger. We can do that and then call whatever java code we need. The problem is figuring out the code to get LCDS to push an update for the objects that we know changed via the trigger to the connected clients.
The part of the equation that we can't find any example for is what curb47 was trying in his code above.
We know the DB has changed and can call a Java function, we don't know how to tell LCDS to refresh the in memory objects and put the changes to the clients.
I've been looking for an example of this for months. What am I missing?
Thanks,
R. Sparrow
Views
Replies
Total Likes
@R. Sparrow: See Ashish's response above. You need to tell LCDS via the DataServiceTransaction APIs about CRUD operations to data sets it is managing, and LCDS will take care of notifying all subscribed clients. So when a record is created, call createItem(). When a record is deleted, call deleteItem(), on update, call updateItem().
HTH
Damon
Damon and Ashish,
Thanks for the quick responses. Let me look into that and give it a try. We'll get back with you and let you know how it worked.
Thanks,
R. Sparrow
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies