Decision Management (ODM,ADS)

 View Only
  • 1.  How to set the custom exception object in the response from CustomExceptionHandler in ODM

    Posted Tue January 16, 2024 03:07 PM

    How to set the custom exception object in the response from CustomExceptionHandler in ODM?

    I am in the process of migrating ODM 8.9.2 rules to 8.12. I would like to set custom exception message and code and send it back in the response object. But would like to get some guidance on how to pass the response object to the Custom Exception Handler class.



    ------------------------------
    Anishia Casmir Thomas
    ------------------------------


  • 2.  RE: How to set the custom exception object in the response from CustomExceptionHandler in ODM
    Best Answer

    Posted Tue January 16, 2024 05:31 PM

    You can access the response object explicitly from the handleActionException method using the RuleInstance argument to retrieve a parameter

    For example 

      response = (Response) ruleInstance.getEngineData().get("response");
    In the method handleConditionException there is no way to access the engine directly.
    You can use a side effect to initialize the local attribute response with an action exception and reuse it in the handleConditionException method afterward.
    You can refine the process by creating a rule that is called at the beginning of the ruleflow and intentionally throws an exception:
    when {
      c : IlrContext() from ?context;
    }
    then {
      throw new Exception( "initializing exception handler");
    }
    In the handleActionException you initialize the object response you want to reuse and ignore the exception because ruleInstance.getRuleName() equals the name of the rule created to fail.


    ------------------------------
    Alain Robert
    ------------------------------



  • 3.  RE: How to set the custom exception object in the response from CustomExceptionHandler in ODM

    Posted Tue January 16, 2024 07:55 PM

    Thanks Alain for your quick response, was able to get the response object from the EngineData :)Appreciate your quick response :)



    ------------------------------
    Anishia Casmir Thomas
    ------------------------------



  • 4.  RE: How to set the custom exception object in the response from CustomExceptionHandler in ODM

    Posted Wed October 23, 2024 06:03 AM

    Hi @Alain Robert, I come to this searching the community because we have implemented the same pattern that you're proposing here to initialize the
    exception handler with one of the output parameters of the ruleset and it is not working well.

    I don't know if you have access to this support case where I have uploaded a simplified project to reproduce the problem.

    The issue is that DE is creating more than one instance of the exception handler, so that, when the exceptions are managed,
    the handler is not the one initialized with the output parameter.

    I don't know if it's ever happened to you.



    ------------------------------
    Eduardo Izquierdo Lázaro
    Automation Architect
    DECIDE
    Madrid
    609893677
    ------------------------------



  • 5.  RE: How to set the custom exception object in the response from CustomExceptionHandler in ODM

    Posted 6 days ago

    Hi Alain Robert,

    We have recently migrated our on-premise ODM version to the latest ODM on Cloud. During this migration, we are receiving a warning related to the use of legacy classic rule engine APIs, specifically with the IlrContext class in our technical rule implementation. The line of code c: IlrContext() needs to be replaced to support the Decision Engine.

    Could you please advise on how we can replace this line (c: IlrContext()) to ensure compatibility with the Decision Engine? Additionally, if you have any sample exception handling code or a zip file for Decision Engine, could you kindly share it?

    Your prompt assistance would be highly appreciated.



    ------------------------------
    Showkat Ali Beig
    ------------------------------



  • 6.  RE: How to set the custom exception object in the response from CustomExceptionHandler in ODM

    Posted 6 days ago

    Hello,

    Here is a page comparing the APIs for classic rule engine and decision engine: https://www.ibm.com/docs/en/odm/8.11.1?topic=rec-mapping-between-classic-rule-engine-decision-engine-api 

    You may need to contact IBM Support if you have more specific questions.



    ------------------------------
    Antony Viaud
    Product Manager, IBM Decision Automation
    ------------------------------



  • 7.  RE: How to set the custom exception object in the response from CustomExceptionHandler in ODM

    Posted 5 days ago

    In DE the replacement would be literally

    c : com.ibm.rules.engine.ruledef.runtime.RuleEngine() from com.ibm.rules.engine.ruledef.runtime.RuleEngine.this;

    Note however that we have improved the pattern for the exception handler using a ThreadLocal variable which makes the initialization simpler and less intrusive. No need for this particular rule.

    I have attached the sample illustration the use of the variable.

    You will check implementation of exception handler and the init and end task of the ruleflow. 
    Bom methods are added to make the process easier.

    I hope this helps,

    Alain



    ------------------------------
    Alain Robert
    ------------------------------