Kris,
As per the business requirement flow engine will do delegation and
all bussiness validation to be done on the DRL with our custom DSL (In
future).
We are able to execute flow based on the strategy approach as
standalone Java. But we are trying make this as web based spring
application it failed to load JNDI context in tomcat 6.x server.
We are following up the same approach mentioned in Drools flow User guide.
Do we need to do any customization for web? Also i would like to know is
there a way to use hibernate.properties based data persistence instead JNDI
/JTA approach. If so could please share the sample.
Thanks
Prem
On Fri, Oct 9, 2009 at 7:14 PM, Kris Verlaenen <
kris.verlaenen(a)cs.kuleuven.be> wrote:
The way you are inserting the process instance is probably fine,
I'm
just wondering why you need the process instance in your DRL. As there
might be alternatives where you don't need to use DRL constraint but
maybe code constraints or event nodes to reach the same behaviour.
Kris
Quoting PremKumar s <premkumar.sivanandan(a)gmail.com>:
> Kris,
>
> I am new to drools flow am not aware of other better ways to
> pass
> ProcessInstance to drools rule (DRL) When conditions. Based on few
> examples in the forum and sample testing code with out inserting
> processInstance to working memory rule constraints not able get to
> process
> instance in drools rule drl file.
>
> If would be great if could suggest better approach to pass the
> process
> instance to drools rule (DRL) conditions. I with try that out and
> update
> you.
>
> Thanks
> Prem
>
> On Fri, Oct 9, 2009 at 7:12 AM, Kris Verlaenen <
> kris.verlaenen(a)cs.kuleuven.be> wrote:
>
> > You can register a custom strategy like this:
> >
> > Environment env = KnowledgeBaseFactory.newEnvironment();
> > env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
> > env.set(EnvironmentName.TRANSACTION_MANAGER,
> > TransactionManagerServices.getTransactionManager());
> > ObjectMarshallingStrategy[] objectMarshalingStrategies = new
> > ObjectMarshallingStrategy[] {
> > new ProcessInstanceMarshallingStrategy(env)
> > };
> > env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
> > objectMarshalingStrategies);
> > StatefulKnowledgeSession ksession =
> > JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
> >
> > ... and then define the strategy as ...
> >
> > private static class ProcessInstanceMarshallingStrategy implements
> > ObjectMarshallingStrategy {
> > private Environment environment;
> > public ProcessInstanceMarshallingStrategy(Environment environment)
> {
> > this.environment = environment;
> > }
> > public boolean accept(Object o) {
> > return o instanceof ProcessInstance;
> > }
> > public Object read(ObjectInputStream ois) throws IOException,
> > ClassNotFoundException {
> > long id = ois.readLong();
> > return ((ProcessRuntime)
> > environment.get("ksession")).getProcessInstance(id);
> > }
> > public void write(ObjectOutputStream oos, Object o) throws
> IOException {
> > oos.writeLong(((ProcessInstance) o).getId());
> > }
> > }
> >
> > Note that this strategy only works for active process instances (so
> you
> > need to make sure they are removed from the working memory before
> ending
> > the process instance, for example by using an on-entry/exit action.
> I
> > think we will probably build in this strategy by default in the
> future.
> >
> > Could you clarify why you need the processInstance in the working
> > memory? As there might be an easier alternative?
> >
> > Kris
> >
> >
> > Quoting PremKumar s <premkumar.sivanandan(a)gmail.com>:
> >
> > > Thanks Kris for your input. It would be great if you could share
> us
> > > on
> > > sample code snippet how to acheive this
> ObjectMarshallingStrategy
> > > for
> > > ProcessInstances .
> > >
> > > Also confirm us by using this approach the process is avialable
> for
> > > drools
> > > rule constraints to take decisions.
> > >
> > > Thanks
> > > Prem
> > >
> > > On Thu, Oct 8, 2009 at 4:07 PM, Kris Verlaenen <
> > > kris.verlaenen(a)cs.kuleuven.be> wrote:
> > >
> > > > This is indeed a special case. Process instances are already
> > > stored as
> > > > part of the session runtime state, so no need to store them
> again
> > > as
> > > > part of the working memory. You need to register a custom
> > > > ObjectMarshallingStrategy for ProcessInstances in the working
> > > memory
> > > > that simply retrieves them from the session state.
> > > >
> > > > Kris
> > > >
> > > > Quoting PremKumar s <premkumar.sivanandan(a)gmail.com>:
> > > >
> > > > > Hi,
> > > > >
> > > > >
> > > > >
> > > > > I am evaluating the drools expert with drool flow
> using
> > > > > TimeManagement
> > > > > System. I am inserting the process instance into working
> memory
> > > of
> > > > > drools
> > > > > [session.insert(workflowProcessInstance)] So that the rules
> can
> > > use
> > > > > the
> > > > > process instance as part of Rule constraints to enable the
> rules
> > > to
> > > > > make
> > > > > more sophisticated decisions based on the state of the
> current
> > > > > process
> > > > > instance.
> > > > >
> > > > >
> > > > >
> > > > > Rule snippet
> > > > >
> > > > >
> > > > >
> > > > > rule "Submit Time" ruleflow-group "Submit
Time"
> > > > > dialect "java"
> > > > > when
> > > > >
> > > > > processInstance:WorkflowProcessInstance()
> > > > >
> > > > > tkRequest:TKRequest ()
> > > > > tkRequestDAO:TKRequestDAO()
> > > > > then
> > > > >
> > > > > // check the current processInstance
> state
> > > as
> > > > > Active
> > > > > then do that
> > > > >
> > > > > //Do custom operation, status change,
> > > > > persistence
> > > > > update
> > > > >
> > > > > end
> > > > >
> > > > >
> > > > >
> > > > > The approach is works fine with using
> > > > > KnowledgeBuilder.newStatefulKnowledgeSession() that is no
> > > > > persistence. But
> > > > > once i have enabled the Persistence using
> > > > > JPAKnowledgeService.newStatefulKnowledgeSession(know, null,
> > > > > getEnvironment()) it throws stack over flow error due the
> > > > > workflowProcessInstance is not serialized while trying to
> persist
> > > the
> > > > > newly
> > > > > added workflowProcessInstance to working memory.
> > > > >
> > > > >
> > > > >
> > > > > Once i have commented the
> > > > > session.insert(workflowProcessInstance)
> > > > > the stack overflow error is gone but none of my rules are
> not
> > > > > executed.
> > > > >
> > > > >
> > > > >
> > > > > Can some one provide guidance on how to pass this
> > > > > workflowProcessInstance to
> > > > > rule constriant with persistence JPAKnowledgeSession
> enabled.
> > > > >
> > > > >
> > > > >
> > > > > Thanks
> > > > >
> > > > > Prem
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm
> > > >
> > >
> >
> >
> >
> >
> > Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm
> >
>
Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm