简体   繁体   中英

Drools Spark Streaming integration for stateful kiesession

I am working with drools and spark streaming. I want to maintain the KieSession throughout the job in the spark streaming context. Each session for each worker node in spark. I understand that kiesession is where the facts are inserted and queried upon. According to my understanding session is the one which actually builds the rete network and inserts the facts in to alpha and beta memories. So my idea is to create a each kiesession for each working name throughout the job so that states are maintained in the kiesession. But i am not able to broadcast the kiesession because it is not serialized. Is there any other method to achieve only a single stateful session(KieSession) for each worker node in spark streaming context.

You can marshall / unmarshal KieSession using org.kie.api.marshalling.Marshaller , here is javadoc for org.kie.internal.marshalling.MarshallerFactory

The MarshallerFactory is used to marshal and unmarshal StatefulKnowledgeSessions. At the simplest it can be used as follows:

 // ksession is the StatefulKnowledgeSession // kbase is the KnowledgeBase ByteArrayOutputStream baos = new ByteArrayOutputStream(); Marshaller marshaller = MarshallerFactory.newMarshaller( kbase ); marshaller.marshall( baos, ksession ); baos.close();

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