简体   繁体   中英

Why dynamic (real time) update doesn’t work? Why changes can be seen only after application restarts?

For example:

When attribute value in domain is changed (value of string or boolean gets changed from 'true' to 'false'). Everything happens in one session, and we're waiting for another rebounds to 'rest', which should be getting data but it seems not to be updating.

This is often caused by incorrect domain usage in hyperon runtime.

Compare these 2 usages (incorrect and correct):

1) Incorrect - domain element is reused (it should not be)

// incorrect:

HyperonDomainObject lob = engine.getDomain("GROUP", "LOB[GROUP]");
HyperonDomainObject trm = lob.getChild("PRODUCT", "PRD3");
HyperonDomainObject adb = trm.getChild("RIDER", "ADB");

// adb is domain element snapshot

while (true) {

    log.info("code = {}", adb.getAttrString("CODE", ctx));

    // sleep 3 sec
    ...
}


// == console ==   (in meantime user changes attribute CODE from "A" to "BBB")
// but adb is frozen - it is snapshot

code = A
code = A
code = A
code = A
...

2) Correct usage - always get fresh domain objects:

while (true) {

    HyperonDomainObject lob = engine.getDomain("GROUP", "LOB[GROUP]");
    HyperonDomainObject trm = lob.getChild("PRODUCT", "PRD3");
    HyperonDomainObject adb = trm.getChild("RIDER", "ADB");

    log.info("code = {}", adb.getAttrString("CODE", ctx));

    // sleep 3 sec
    ...
}


// == console ==   (in meantime user changes attribute CODE from "A" to "BBB")
// adb is always fresh

code = A
code = A
code = BBB
code = BBB
...

Remember, engine.getDomain() returns domain object snopshot and this object is frozen.

Treat engine.getDomain() as cache as it finds objects in memory structure. This structure is refreshed if user modify domain in Hyperon Studio.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM