Nonserializable

All fact objects that are inserted into a stateful session using the insert(Object) method are serialized to a file for persistence. Declared fact objects are converted into objects of an internal class (DeclaredFact) before serialization. Other Java classes need to implement the Java interface Externalizable or Serializable, otherwise the objects cannot be serialized and you will get errors in the log. To not serialize or, persist objects of a specific Java class, you can define the class name as metadata attribute for rules in this format:

@nonserializable(class name)
Note: The class name must include the package, for example, "com.lawson.mypackage.MyClass". If you omit the package from the class name, the package for the rule is used.

The metadata attribute name ("nonserializable") must be unique within a rule. If you need to specify more than one nonserializable Java class name for a rule, you can add a suffix to the attribute name. All metadata attributes with a name starting with "nonserializable" are considered to contain nonserializable class names.

@nonserializable1(class name)
@nonserializable2(class name)
@nonserializable3(class name)

Another option is to use one metadata attribute having several class names separated by the semicolon character (";") as metadata value.

@nonserializable(class name;class name;class name)

This metadata can only exist inside a rule. You can of course create a "dummy" rule that only contains nonserializable metadata attributes.

Example of some nonserializable rules:

rule "Nonserializable_Objects1"
    @nonserializable1(com.lawson.mypackage.MyClass1)
    @nonserializable2(com.lawson.mypackage.MyClass2)
    then
end
 
rule "Nonserializable_Objects2"
    @nonserializable(com.lawson.mypackage.MyClass3;MyClassInThisDRLFile)
    then
end
Note: Objects of classes that are instances of the class com.lawson.eventhub.analytics.drools.model.AbstractTime, that is, Time, Start, and Stop will not be persisted.