Discussion:
[jboss-user] [jBPM] - Custom JuelScriptEngine
Marcos Sousa
2013-07-07 06:41:33 UTC
Permalink
Marcos Sousa [https://community.jboss.org/people/marcos.sousa] created the discussion

"Custom JuelScriptEngine"

To view the discussion, visit: https://community.jboss.org/message/826736#826736

--------------------------------------------------------------
This is a prodution problem.

We copy paste the orginal JuelScriptEngine from jBPM, so we can create new functions.

We are getting issues in productions using decisions.

To reproduce the issue we create 2 threads  invoking startProcessInstante (after task we put decision) then we see what was happen in the code, surprised we found:
1. jBPM creates for those 2 threads our JuelExtendedScriptEngine
2. The ELContext creates 1 new JuelExtendedScriptEngine and use this for those 2 threads - Why? How can I put ELContext to reuse the JuelExtendedScriptEngine created by jBPM?

I see that inside the JuelExtendedScriptEngine every value fits ok. But the evaluation of our new function instead of use the JuelExtendedScriptEngine previous created by jBPM it uses that one created by ELContext.

Remember that the code is the same as the original jBPM 4.3 JuelScriptEngine.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/826736#826736]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Marcos Sousa
2013-07-07 15:33:54 UTC
Permalink
Marcos Sousa [https://community.jboss.org/people/marcos.sousa] created the discussion

"Re: Custom JuelScriptEngine"

To view the discussion, visit: https://community.jboss.org/message/826756#826756

--------------------------------------------------------------
Looks like theres is an bug somewhere or in jBPM or in JUEL!
07-Jul-2013 17:22:57:656 [pool-1-thread-1] factory: ***@1c4120e
07-Jul-2013 17:22:57:656 [pool-1-thread-1] Juel4AppnameScriptEngine: ***@17d5b2a
07-Jul-2013 17:22:57:671 [pool-1-thread-1] Juel4AppnameScriptEngineFactory getScriptEngine ***@17d5b2a
07-Jul-2013 17:22:57:671 [pool-1-thread-1] INI eval ScriptContext ***@e47e99
07-Jul-2013 17:22:57:687 [pool-1-thread-2] factory: ***@1c4120e
07-Jul-2013 17:22:57:687 [pool-1-thread-2] Juel4AppnameScriptEngine: ***@cc5c6c
07-Jul-2013 17:22:57:687 [pool-1-thread-2] Juel4AppnameScriptEngineFactory getScriptEngine ***@cc5c6c
07-Jul-2013 17:22:57:687 [pool-1-thread-2] INI eval ScriptContext ***@15ab821
07-Jul-2013 17:22:57:734 [pool-1-thread-1] toELContext ERRADO   elContext com.xpt.appname.bpm.script.Juel4AppnameScriptEngine$***@1868b72
07-Jul-2013 17:22:57:734 [pool-1-thread-1] toELContext CORRECTO elContext ***@17d5b2a
07-Jul-2013 17:22:57:750 [pool-1-thread-2] toELContext ERRADO   elContext com.xpt.appname.bpm.script.Juel4AppnameScriptEngine$***@12bc418
07-Jul-2013 17:22:57:750 [pool-1-thread-2] toELContext CORRECTO elContext ***@cc5c6c
07-Jul-2013 17:22:57:765 [pool-1-thread-1] getEqual ScriptContext: ***@15ab821
07-Jul-2013 17:22:57:843 [pool-1-thread-1] END eval ScriptContext ***@e47e99
07-Jul-2013 17:22:57:843 [pool-1-thread-2] getEqual ScriptContext: ***@15ab821
07-Jul-2013 17:22:57:859 [pool-1-thread-2] END eval ScriptContext ***@15ab821
07-Jul-2013 17:22:57:921 [pool-1-thread-1] [k = 0] [VALIDO] Instância [process-decision.95980007] [Definir Titulares] [Definir Cliente - CORRECTO] ***@1a95cf6
07-Jul-2013 17:22:57:921 [pool-1-thread-2] [k = 1] [INVALIDO] Instância [process-decision.95980008] [Definir Titulares] [Definir Titulares - CORRECTO] ***@1a95cf6
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/826756#826756]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Marcos Sousa
2013-07-07 21:04:33 UTC
Permalink
Marcos Sousa [https://community.jboss.org/people/marcos.sousa] created the discussion

"Re: Custom JuelScriptEngine"

To view the discussion, visit: https://community.jboss.org/message/826763#826763

--------------------------------------------------------------
An way that looked to fit to me is:
public ScriptEngine getScriptEngine() {
        if (queue.isEmpty()) {
            ScriptEngine scriptEngine = new Juel4AppnameScriptEngine(this);

            try {
                queue.put(scriptEngine);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            return scriptEngine;
        } else {
            while (!queue.isEmpty()) {
                try {
                    Thread.sleep(1 * 100L);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            ScriptEngine scriptEngine = new Juel4AppnameScriptEngine(this);

            try {
                queue.put(scriptEngine);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            return scriptEngine;
        }
    }

Then in Juel4AppnameScriptEngine I use "Juel4ImpressionScriptEngineFactory.queue.poll();" before return eval method.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/826763#826763]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...