How to skip the exception and drop off bad input data on BRMS / BPM Suite execution server side ?

Solution Unverified - Updated -

Issue

Our application sends aggregated data(XML format) to execution server and fire the rules every 5 seconds. Sometimes the xml contains invalid data entries, execution server will throw exceptions and we will lose all the data (even the good ones aggregated in 5 seconds) in the above situation. Could you explain how to skip the invalid data entries in the xml input ?

Our rules look like:

package org.kie.example.project1;

declare TestVO
    @role(event)
    cnt : int
    name : String
end

rule "test"
when
    TestVO( name == "test", cnt > 0 )
then
    System.out.println("test");
end

We invoke execution server with REST requests containing following data:

<batch-execution lookup="infoSession">
  <insert>
    <org.kie.example.project1.TestVO>
      <name>test</name>
      <cnt>1</cnt>
    </org.kie.example.project1.TestVO>
  </insert>

  <insert>
    <org.kie.example.project1.TestVO>
      <name>test</name>
      <cnt>aaa</cnt>
    </org.kie.example.project1.TestVO>
  </insert>
  <fire-all-rules />
</batch-execution>

And converting the cnt variable which has the value aaa will lead to ConversionException:

<?xml version="1.0" encoding="UTF-8"?>

<response type="FAILURE" msg="Error calling container window: com.thoughtworks.xstream.converters.ConversionException: For input string: &quot;aaa&quot; : For input string: &quot;aaa&quot;
---- Debugging information ----
message             : For input string: &quot;aaa&quot;
cause-exception     : java.lang.NumberFormatException
cause-message       : For input string: &quot;aaa&quot;
class               : java.lang.Integer
required-type       : java.lang.Integer
converter-type      : com.thoughtworks.xstream.converters.SingleValueConverterWrapper
wrapped-converter   : com.thoughtworks.xstream.converters.basic.IntConverter
path                : /batch-execution/insert[2]/org.kie.example.project1.TestVO/cnt
line number         : 1
class[1]            : org.kie.example.project1.TestVO
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : org.drools.core.command.runtime.rule.InsertObjectCommand
converter-type[2]   : org.drools.core.runtime.help.impl.XStreamXML$InsertConverter
class[3]            : org.drools.core.command.runtime.BatchExecutionCommandImpl
version             : 1.4.7

Environment

  • Red Hat JBoss BRMS
    • 6.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content