Rule Execution Server API

ilog.rules.res.session
Interface IlrStatelessSession

All Superinterfaces:
IlrSession

public interface IlrStatelessSession
extends IlrSession

IlrStatelessSession represents a stateless rule session. A stateless session is a session where the server treats each request as an independent transaction that is unrelated to any previous request.

Code example

The following code example shows how to execute rules in a Java SE session.

  public IlrSessionResponse executeRulesOnJ2SESession(Customer user, ShoppingCart cart) throws IlrFormatException, IlrSessionException  {
    IlrSessionFactory  factory = new IlrJ2SESessionFactory();
    IlrStatelessSession session = factory.createStatelessSession();
    IlrSessionRequest sessionRequest = factory.createRequest();
    sessionRequest.setRulesetPath(IlrPath.parsePath(rulesetPath));
    // Ensure correct version of the ruleset is taken in account
    sessionRequest.setForceUptodate(true);
    sessionRequest.setTraceEnabled(true);
    sessionRequest.getTraceFilter().setInfoAllFilters(true);
    // Set the input parameters for the execution of the rules
    Map inputParameters = new HashMap ();
    Announcement announcement =  new Announcement();
    inputParameters.put("announcement", announcement);
    inputParameters.put("customer", user);
    inputParameters.put("shoppingCart", cart);

    sessionRequest.setInputParameters(inputParameters);
    IlrSessionResponse sessionResponse = session.execute(sessionRequest);
    return sessionResponse;
  }
 

Since:
7.0

Method Summary
 IlrSessionResponse execute(IlrSessionRequest request)
          Executes a ruleset based on a request and returns the execution response.
 void executeAsynchronous(IlrSessionRequest request, IlrAsyncExecutionObserver observer, long timeout)
          Executes a ruleset asynchronously.
 

Method Detail

execute

IlrSessionResponse execute(IlrSessionRequest request)
                           throws IlrSessionException
Executes a ruleset based on a request and returns the execution response. The call blocks until the response has been returned.

Throws:
IlrSessionException - if an error occurred during ruleset execution.
Parameters:
request - The request, this object contains execution details.
Returns:
The execution response.

executeAsynchronous

void executeAsynchronous(IlrSessionRequest request,
                         IlrAsyncExecutionObserver observer,
                         long timeout)
                         throws IlrSessionException
Executes a ruleset asynchronously. When execution is completed, observer is notified. This method does not block until either execution is completed or an error is raised.

Throws:
IlrSessionException - if an error occurred during ruleset execution.
Parameters:
request - The request, this object contains execution details.
observer - The observer that is notified when execution is complete.
timeout - The waiting time when the observer has not been notified of execution completion.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2012