Rule Execution Server API

Package ilog.rules.res.session.async

Provides classes for asynchronous ruleset execution via the Rule Sessions API.

See:
          Description

Interface Summary
IlrAsyncExecutionObserver Implementations of IlrAsyncExecutionObserver are notified of execution events during asynchronous rule session execution.
 

Class Summary
IlrAsyncExecutionEndedEvent IlrAsyncExecutionEndedEvent represents an event that indicates the normal completion of an asynchronous ruleset execution.
IlrAsyncExecutionEvent IlrAsyncExecutionEvent is the top level markup interface for an asynchronous execution event.
IlrAsyncExecutionFailedEvent IlrAsyncExecutionFailedEvent represents an event indicating that asynchronous ruleset execution failed to complete.
 

Package ilog.rules.res.session.async Description

Provides classes for asynchronous ruleset execution via the Rule Sessions API. Asynchronous execution is limited to stateless rule sessions.

Code example

  // The stateless session is created as usual
  IlrStatelessSession statelessSession = getSessionFactory().createStatelessSession();
  IlrSessionRequest request = sessionFactory.createRequest();
  request.setRulesetPath(IlrPath.parsePath("/bigsequential/1.0/bigsequentialruleset/1.0"));
  request.setInputParameter("param1", "ruoa");
        
        // The Observer is created and will be called when the execution failed or ended.
  IlrAsyncExecutionObserver myObserver = new IlrAsyncExecutionObserver() {
    public void update(IlrAsyncExecutionEvent event) {
      if (event instanceof IlrAsyncExecutionEndedEvent) {
        IlrAsyncExecutionEndedEvent endedEvent = (IlrAsyncExecutionEndedEvent)event;
        IlrSessionResponse response = endedEvent.getResponse();
        assertNotNull("ended exec event references null response", response);
        assertNotNull("expected param not found in response", response.getOutputParameters().get("param1"));
        hasExecuted = true;
      } else if (event instanceof IlrAsyncExecutionFailedEvent) {
        IlrAsyncExecutionFailedEvent failedEvent = (IlrAsyncExecutionFailedEvent)event;
        String msg = "observer got notified of an error, e=" + failedEvent.getException().getMessage();
        fail(msg);                    
      }
    }
  };
  // asynchronous execution with your observer. Your code is not blocked by the ruleset execution  
  statelessSession.executeAsynchronous(request, myObserver, -1);    


Rule Execution Server API

© Copyright IBM Corp. 1987, 2013