Expand my Community achievements bar.

Big bug in DataServiceTransaction.CreateItem

Avatar

Former Community Member

createItem  arent pushing anything to the clients in manualsync.


DataServiceTransaction dst = DataServiceTransaction.begin(false);
    String ps[] = {"test_room"};
    dst.setProducerSubtopics("inventory", ps);

...

Product p = new Product(0,"name_"+d.toString(),"description_str","image_path","category_name",99.9, 100);
service.create(p);

...

dst.createItem( "inventory", p);

dst.commit();

what's wrong?

but   dst.addItemToFill("inventory", fill, -1, p);  works well.

8 Replies

Avatar

Employee

Hi,

How are you declaring the Data Service on the client side? Do you have the consumer subscriptions on the DataService set to "test_room" in order to get the updates? Refer to the LCDS 3.1 documentation here for details for how to do it.

Rohit

Avatar

Former Community Member

I am sure the consumer on client was set correct.

Because removeItemFromFill and deleteItem all worked!

Avatar

Employee

Hi,

From the manual sync document

"Note: When you manually route messages, you cannot use the autoRefresh fill capability. Instead, if you want to update fills you must put in calls to manually manage fill membership."

addItemToFill and removeItemFromFill are methods to manage fill membership, but createItem runs refreshFill to evaluate the new item

createItem API doc

     * You use this method to indicate to to the Data Management Service that a new item

     * has been created. The Data Management Service goes through all sequences currently

     * being managed by clients and determine whether this item belongs in

     * each sequence.  Usually it re-evaluates each fill method to make this

     * determination (though you can control how this is done for each fill

     * method).  When it finds a sequence that contains this item, it

     * then sends a create message for this item to each client subscribed

     * for that sequence.

createItem requires auto-sync and refreshFill.  It doesn't like the addItemToFill or removeItemToFill.  It is the reason why you cannot find fillParameters in the createItem signature.

William

Avatar

Former Community Member

In fact, in manualsync only the subtopics set by setProducerSubtopics

control messages routing,

"fill" parameter is useless at all.

Avatar

Employee

Do you mean that dst.addItemToFill(destination, ["abc"], 0, item) makes the item go into both collections where there are 2 fills on client? 

ds.fill(collection1, "abc");

ds.fill(collection2, "123");

William

Avatar

Employee

Thanks for bringing this up. I just tested addItemToSync using different sets of fillParameters.

I had fill(collection1, "abc") and fill(collection, "123"); 

I called with "abc", I got a message event and the "abc" filled collection updated(not the "123 filled collection").   It was correct. 

I called with "123", nothing happened on "abc" filled collection. It was correct.

I call dst.addItemToFill(destination, ["ijk"], 0, item);   I thought I was not going to get any message event, but I did.

I am going to discuss with the Dev.  I think this should not happen.

William

Avatar

Employee

You are right, the setProducerSubtopics control the messages routing no matter that the client has collection which matches the addItemToFill's fillparameters. I thought it was too many messages send to client if the client didn't have the relevant fill.  However, it is how it works.  It is same as the createItem. If you had a message event handler, you could handle the message by the dst.createItem.  For createItem message,  the client's dataservice didn't handle this message since there was no indication how this item related to any of its fills.

William