Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6713223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:21:14+00:00 2026-05-26T08:21:14+00:00

I was using a proprietary rule engine, and I am now trying to use

  • 0

I was using a proprietary rule engine, and I am now trying to use Drools, i’m pretty new to Drools.

With the previous rule engine, the rule were fired for all instances of existing object even if they were attribute of an other object.

I have a set of rules that are applied to a given type of object O. I add to my session and object O’ having O as attribute. But as the rules are not applied to O’ they won’t be applied to the attribute O of O’.

I will illustrate this with an HEllo word example :

I added to the basic drool Example the following class :

 public static class Email {

        private Message message ;


        public void setMessage(Message message) {
            this.message = message;
        }

        public Message getMessage() {
            return message;
        }
}

Email is O’ and Message is O.

My session “works” as follow :

            ...
            Message message = new Message();
            message.setMessage("Hello World");
            message.setStatus(Message.HELLO);
            Email email = new Email();
            email.setMessage(message);
            ksession.insert(email);
            ksession.fireAllRules();
            logger.close();
            ...

and I have a Sample drool file :

rule "Hello World"
    when
        m : Message( status == Message.HELLO, myMessage : message )
    then
        System.out.println( myMessage );
        m.setMessage( "Goodbye cruel world" );
        m.setStatus( Message.GOODBYE );
        update( m );
end

The rule is only applied on Message .

If I launch my session the way it is, no rule will be fired .
To have rules fired I need to add the rule :

rule "email"
    when 
        e : Email( message != null)
    then 
        insert(e.getMessage());
end

It works fine, but my question is : is there an easier way to have the rule fired on each instance of an object even if it’s an attribute of an other object ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:21:14+00:00Added an answer on May 26, 2026 at 8:21 am

    Yes you can do something like:

    rule "Hello World"
        when
            $email: Email(message.status ==  Message.HELLO, $myMessage: message.message )
    
        then
            System.out.println( $myMessage );
            m.setMessage( "Goodbye cruel world" );
            m.setStatus( Message.GOODBYE );
            update( m );
    end
    

    or you can just insert the message to the working memory using a rule

    Rule "insert message"
       when 
          Email ($message: message)
       then
          insert($message);
    end
    

    Using this approach then you can write rules only using the Message type.

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're using a proprietary tracking system that requires the use of regular expressions to
Using the proprietary filter css in IE (7/8). Trying to apply an additional filter
I have no experience with web services. Historically I've built client-server systems using proprietary
We are about to migrate an intranet web application from using a proprietary forms-based
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using a proprietary framework, I am frequently finding myself in the situation where I
I'm using a proprietary platform that reported memory usage in realtime on screen. I
I am using a proprietary language called VGL which really does not type variables
I've worked on a project using a proprietary non-SQL DB where queries could be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.