2017-03-21 7 views
0

郵便配達員からのRESTコールが期待した結果を返しても、RuleServiceClientを使用してJavaアプリケーションからコールすると、Drools Execution Serverからの成功は受信されましたが、KIE RuleServicesClientが空のレスポンスを返します

私の質問:私のJavaコードで何が間違っていますか?

下記をご覧ください。

私は、サンプルのルールを作成した(フィールドMessage.MyField == 1が、その後400にこのフィールドを設定している場合)、私は郵便配達員を使ってKIE実行サーバー上でそれを発射することができました:http://SERVER:8080/kie-server-webc/services/rest/server/containers/instances/kie-container

POSTリクエスト:

{ 
    "lookup": "defaultStatelessKieSession", 
    "commands": [{ 
     "insert": { 
      "object": { 
       "Message": { 
        "myField": 1 
       } 
      }, 
      "disconnected": false, 
      "out-identifier": "Message", 
      "return-object": true, 
      "entry-point": "DEFAULT" 
     } 
    }, { 
     "fire-all-rules": { 
      "max": -1, 
      "out-identifier": null 
     } 
    }] 
} 

レスポンスを("myField": 500を書き留めてください)

{ 
    "type": "SUCCESS", 
    "msg": "Container kie-container successfully called.", 
    "result": { 
    "execution-results": { 
     "results": [ 
     { 
      "key": "Message", 
      "value": { 
      "bnym.test1.Message": { 
       "myField": 500 
      } 
      } 
     } 
     ], 
     "facts": [ 
     { 
      "key": "Message", 
      "value": { 
      "org.drools.core.common.DefaultFactHandle": { 
       "external-form": "0:1:1208207159:1208207159:2:DEFAULT:NON_TRAIT:myProj.test1.Message" 
      } 
      } 
     } 
     ] 
    } 
    } 
} 

マイJavaクライアントコードborrowe dはチュートリアルからです:

です。 。 。

private static String URL = "http://SERVER:8080/kie-server-webc/services/rest/server";  
private static final String USER = "user"; 
private static final String PASSWORD = "pwd"; 

。 。 。

public void transform() throws Exception { 
    Message m = new Message(); 
    m.myField = 1; 

    KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(URL, USER, PASSWORD); 
    config.setMarshallingFormat(MarshallingFormat.JSON); 
    kieServicesClient = KieServicesFactory.newKieServicesClient(config); 

    RuleServicesClient rulesClient = kieServicesClient.getServicesClient(RuleServicesClient.class); 
    KieCommands commandsFactory = KieServices.Factory.get().getCommands(); 

    Command<?> insert = commandsFactory.newInsert(m); 
    Command<?> fireAllRules = commandsFactory.newFireAllRules(); 
    Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays.asList(insert, fireAllRules)); //0 
    ServiceResponse<String> executeResponse = rulesClient.executeCommands("kie-container", batchCommand); 

    if(executeResponse.getType() == ResponseType.SUCCESS) { 
     System.out.println("Commands executed with success! Response: "); 
     System.out.println(executeResponse.getResult()); 
    } 
} 

結果:

Commands executed with success! Response: 
{ 
    "results" : [ ], 
    "facts" : [ ] 
} 

私の質問:結果が空であるように、私のJavaコードで間違って何ですか?

は、私が送信された要求を確認し、それで正しいではありません見つけるためにあなたの他のものにそれを比較するために、クライアントのデバッグログをオンに勧めあなたに

答えて

0

ありがとうございます。あなたのアプリがDEBUGに、このロガーを設定し、使用して(または単にそれはあなたのためのより良いかどうDEBUGにすべてを設定)されているもののロギングシステムの場合

: org.kie.server.client.impl.AbstractKieServicesClientImpl

0

あなたの場合その後、あなたはコード例に従う、ステートレスセッションを作成する必要があり、ステートレス・セッションを使用して保存しておきたい:

public static StatelessKieSession getStatelessKieSession() { 
    KieServices ks = KieServices.Factory.get(); 
    KieContainer kContainer = ks.getKieClasspathContainer(); 
    StatelessKieSession kSession = kContainer.newStatelessKieSession("defaultStatelessKieSession"); 
    return kSession; 
} 

public void runRulesStateless(List<Object> objects) { 
    getStatelessKieSession().execute(objects); 
} 

public static void main(String[] args) { 
    runRulesStateless(Arrays.asList(new Object[] { new Message() })); 
} 

あなたはdifferenteステートレスセッションをしたい場合、あなたはkmodule.xml

に設定することができます
関連する問題