Unable to use camel-jetty endpoint to POST BatchExecitionCommand to Kie Execution Server

77 views
Skip to first unread message

chiippy chiippy

unread,
Aug 21, 2015, 10:37:31 AM8/21/15
to Drools Usage
Hi all

Recently, I am starting to look at Fuse Camel, Drools WB and Kie Execution Server Integration for a new project and I am having the following problem.

I am using Fuse 6.2, Drool 6.2.Final for WB and Kie Server.

This is what I have done:

1) create the Person Drink drool rule from the Fuse Example in Drools-WB and deployed in on the Kie Execution Server using my own Containers : myCheese.

2) in Fuse Camel, instead of calling the internal Kie-Camel Server,  I am using a bean in which setup the header for Comel-jetty to fire the rules :

 public void populateRestHeader(Exchange exchange) {

       // hard code the message for time being because   BatchExecutionHelperd doesn't work. please see below.  
    String myMessage = "<batch-execution lookup=\"ksession1\"> " 
+ "<insert out-identifier=\"person\" > <org.drools.camel.example.Person> <name>john</name> " 
+ "<age>51</age> </org.drools.camel.example.Person> </insert> " 
+ "<fire-all-rules/> </batch-execution>";

       // setup the login token
        exchange.getIn().setHeader("Authorization", basicToken);
       // POST so I can send XML.  GET works fine !
        exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
       // the content
        exchange.getIn().setHeader(Exchange.ACCEPT_CONTENT_TYPE, "application/xml");
        exchange.getIn().setBody(myMessage);


3) POST the commands to remote Kie-Server using jetty : "jetty:http://localhost:9080/kie-server-620/services/rest/server/containers/myCheese"

4) On the Kie-Server log, I am getting :

    15:19:33,140 WARN  [org.jboss.resteasy.core.ExceptionHandler] (default task-114) failed to execute: javax.ws.rs.NotSupportedException: Cannot consume content type
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:380) [resteasy-jaxrs-3.0.10.Final.jar:]
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114) [resteasy-jaxrs-3.0.10.Final.jar:]
   
     Either the "Content-Type" wasn't setup correctly or the body wasn't sent ? 

5) I tried to perform a GET using the same method and this works out nicely !

Received something ! <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response type="SUCCESS" msg="Info for container myCheese"><kie-container container-id="myCheese" status="STARTED"><release-id><artifact-id>mycheese</artifact-id><group-id>com.markit</group-id><version>1.0</version></release-id><resolved-release-id><artifact-id>mycheese</artifact-id><group-id>com.markit</group-id><version>1.0</version></resolved-release-id><scanner status="DISPOSED"/></kie-container></response>


6) Using SoapUI to execute the command without any problem. 
    <response type="SUCCESS" msg="Container myCheese successfully called.">
   <results><![CDATA[<execution-results>
  <result identifier="person">
    <org.drools.camel.example.Person>
      <name>john</name>
      <age>51</age>
      <canDrink>true</canDrink>
      <alive>false</alive>
      <sex></sex>
      <happy>false</happy>
    </org.drools.camel.example.Person>
  </result>
  <fact-handle identifier="person" external-form="0:1:866416565:866416565:1:DEFAULT:NON_TRAIT"/>
</execution-results>]]></results>
</response>

Questions :

a)  Any ideas why the error ?  Is it correct to set the Exchange.Body as the DATA for the POST ?
b) Instead of using Came-Jetty to POST the commands to Kie-Server, as Kie-Server declare it as REST, can I use CXFRS to do this ? Also, I believes Kie-Server also supports SOAP, but what is its WSDL ?   Another other alternatives ? 

c) For the BatchExecutionCommands, I was planning to use the following :

        BatchExecutionCommandImpl command = new BatchExecutionCommandImpl();
        final List<GenericCommand<?>> commands = command.getCommands();
        
        Person person = createTestPerson();

        commands.add(new InsertObjectCommand(person, "myPerson"));
        commands.add(new FireAllRulesCommand());
        command.setLookup("ksession1");

        String myXMLMessage = BatchExecutionHelper.newXStreamMarshaller().toXML(command);

     
    But  I am getting the Exception in the Fuse log as :

  • Caused by: java.lang.ClassNotFoundException: org.drools.core.runtime.help.impl.BatchExecutionHelperProviderImpl not found by org.kie.internalapi [281]
  •   at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)
  •   at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)
  •   at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)
  • at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_40]
  •   at java.lang.Class.forName0(Native Method)[:1.8.0_40]
    
  Seems like Kie-Internal Package couldn't access the Drools-Core  bundle ? 

Appreciates for any suggestions or help.

Many Thanks

Alex


Reply all
Reply to author
Forward
0 new messages