insertStage.setReceiver( resultHandlerStage );
JAXBContext jaxbCtx = KnowledgeBuilderHelper.newJAXBContext( classNames,
kbase );
Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
Transformer transformer = PipelineFactory.newJaxbFromXmlTransformer( unmarshaller );
transformer.setReceiver( insertStage );
Action unwrapObjectStage = PipelineFactory.newJmsUnwrapMessageObject();
unwrapObjectStage.setReceiver( transformer );
Pipeline pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );
pipeline.setReceiver( unwrapObjectStage );
ResultHandleFactoryImpl factory = new ResultHandleFactoryImpl();
Service feeder = PipelineFactory.newJmsMessenger( pipeline,
props,
this.destinationName,
factory );
feeder.start();
String xml = StringUtils.readFileAsString( new InputStreamReader( getClass().getResourceAsStream( "order.xml" ) ) );
this.simpleProducer.sendObject( xml );
for ( int i = 0; i < 5; i++ ) {
// iterate and sleep 5 times, to give these messages time to complete.
if ( factory.list.size() == 1 ) {
break;
}
Thread.sleep( 5000 );
}
FactHandle factHandle = (FactHandle) ((Map) ((ResultHandlerImpl) factory.list.get( 0 )).getObject()).keySet().iterator().next();
assertNotNull( factHandle );
assertEquals( 1,
factory.list.size() );
Action executeResult = PipelineFactory.newExecuteResultHandler();
Action assignAsResult = PipelineFactory.newAssignObjectAsResult();
assignAsResult.setReceiver( executeResult );
//transformer = PipelineFactory.newXStreamToXmlTransformer( xstream );
Marshaller marshaller = jaxbCtx.createMarshaller();
transformer = PipelineFactory.newJaxbToXmlTransformer( marshaller );
transformer.setReceiver( assignAsResult );
KnowledgeRuntimeCommand getObject = PipelineFactory.newStatefulKnowledgeSessionGetObject();
getObject.setReceiver( transformer );
pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline( ksession );