[jboss-jira] [JBoss JIRA] Commented: (JBRULES-959) Investigate performance delta with MR3 and 3.0.6

Gilles Dubuc (JIRA) jira-events at lists.jboss.org
Thu Jun 28 22:39:58 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBRULES-959?page=comments#action_12367263 ] 
            
Gilles Dubuc commented on JBRULES-959:
--------------------------------------

/*
 * BOBOMessage.java THIS IS THE FACT CLASS USED IN THIS TEST
 *
 * Created on April 5, 2007, 12:08 PM
 *
 * SMS Central 2007
 */

package com.smsc.mitto.rules.client;

import java.io.Serializable;
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

/**
 * A test class to act as a fact given to rules
 * 
 * @author Gilles Dubuc
 */
public final class BOBOMessage implements Serializable {
        private String          message;
        
       
        /**
         * Getter for the String message contained by the BOBOMessage object
         * @return The message String
         * @see #setMessage
         */
        public String getMessage() {
            return this.message;
        }
        
        /**
         * Setter for the String message contained by the BOBOMessage object
         * @param message The new message String to be stored by the BOBOMessage object
         * @see #getMessage
         */
        public void setMessage(final String message) {
            this.message = message;
        }
        
        
        /**
         * Send the message to a given queue
         * @param queuename The name of the queue the message needs to be redirected to
         */
        public void sendToQueue(String queuename) {
            try {
                Context ctx = new InitialContext();
                QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup("QueueConnectionFactory");
                Connection localconnection = connectionFactory.createConnection();
                localconnection.start();
                
                Session localsession = localconnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                
                Queue destination = (Queue) ctx.lookup("queue/" + queuename);
                
                MessageProducer producer = localsession.createProducer(destination);
                
                producer.setDeliveryMode(DeliveryMode.PERSISTENT);
                producer.setTimeToLive(3600000);
                
                TextMessage textmessage = localsession.createTextMessage(this.message);
                
                producer.send(textmessage);
                
                System.out.println("The message received by " + Thread.currentThread().getId() + " has been redirected to queue " + queuename + " according to the rule");
                
                localsession.close();
                localconnection.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        
        
    }


> Investigate performance delta with MR3 and 3.0.6
> ------------------------------------------------
>
>                 Key: JBRULES-959
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-959
>             Project: JBoss Rules
>          Issue Type: Task
>      Security Level: Public(Everyone can see) 
>          Components: All
>    Affects Versions:  4.0.0.MR3
>            Reporter: Michael Neale
>         Assigned To: Michael Neale
>
> // Rule execution time test
> // I give the DRL one fact of class BOBOMessage (made final due to Michael's suggestion)
> // The "message" member of my BOBOMessage fact contains a random combination of the keywords the rule is designed to match
> // A random BOBOMessage like that is generated before every execution
>  
> // MR3's performance: 11:43:01,135 INFO  [RuleLoadBean] Average rule execution time in ms: 2.3991
>  
> // What is measured:
> ruleBase = rsl.getGroupRuleBase(group); // That retrieves the RuleBase from the cache
>  
> StatelessSession session = ruleBase.newStatelessSession();
> session.execute(toBeAsserted.get(group.getId()).toArray());
>  
> // 3.0.6's performance: 12:09:40,446 INFO  [RuleLoadBean] Average rule execution time in ms: 0.7726
>  
> // What is measured:
>  
> ruleBase = rsl.getGroupRuleBase(group); // That retrieves the RuleBase from the cache
>  
> WorkingMemory wm = ruleBase.newWorkingMemory();
> for (Iterator j = toBeAsserted.get(group.getId()).iterator(); j.hasNext();)
> 	wm.assertObject(j.next());
> wm.fireAllRules();
>  
> // The DRL:
>  
> package com.smsc.mitto.rules
>  
> import com.smsc.mitto.rules.client.BOBOMessage;
> import java.lang.String;
>  
> rule "14"
> salience 0
> activation-group "14"
> when
>      m : BOBOMessage( message matches ".*BOBO.*")
> then
>   System.out.println( "BOBO WAS SEEN" );
>   System.out.println( "BOBO WAS REALLY SEEN, DUDE" );
>   drools.setFocus( "17" );
> end
>  
>  
> rule "17"
> salience -20
> agenda-group "17"
> activation-group "17"
> when
>      m : BOBOMessage( message matches ".*CACA.*")
> then
>   System.out.println( "CACA WAS SEEN" );
>   drools.setFocus( "19" );
> end
>  
>  
> rule "19"
> salience -10
> agenda-group "19"
> activation-group "19"
> when
>      m : BOBOMessage( message matches ".*BABA.*")
> then
>   System.out.println( "BABA WAS SEEN" );
>   drools.setFocus( "21" );
> end
>  
>  
> rule "19false"
> salience -20
> agenda-group "19"
> activation-group "19"
> when
>   eval(true)
> then
>   drools.setFocus( "21" );
> end
>  
>  
> rule "21"
> salience -20
> agenda-group "21"
> activation-group "21"
> when
>      m : BOBOMessage( message matches ".*BIBI.*")
> then
>   System.out.println( "BIBI WAS SEEN" );
>   drools.setFocus( "23" );
> end
>  
>  
> rule "21false"
> salience -30
> agenda-group "21"
> activation-group "21"
> when
>   eval(true)
> then
>   drools.setFocus( "23" );
> end
>  
>  
> rule "17false"
> salience -30
> agenda-group "17"
> activation-group "17"
> when
>   eval(true)
> then
>   drools.setFocus( "23" );
> end
>  
>  
> rule "23"
> salience -30
> agenda-group "23"
> activation-group "23"
> when
>      m : BOBOMessage( message matches ".*POOP.*")
> then
>   System.out.println( "POOP WAS SEEN" );
>   drools.setFocus( "25" );
> end
>  
>  
> rule "23false"
> salience -40
> agenda-group "23"
> activation-group "23"
> when
>   eval(true)
> then
>   drools.setFocus( "25" );
> end
>  
>  
> rule "14false"
> salience -10
> agenda-group "14"
> activation-group "14"
> when
>   eval(true)
> then
>   drools.setFocus( "25" );
> end
>  
>  
> rule "25"
> salience -10
> agenda-group "25"
> activation-group "25"
> when
>      m : BOBOMessage( message matches ".*SUPER.*")
> then
>   System.out.println( "SUPER WAS SEEN" );
> end

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list