0

I have just installed RedHat Decision Manager 7.3 and can deploy a decision service. So far, I have been using the /server/containers/instances/{containerId} endpoint to call my service, where the payload lists commands to insert objects into working memory.

However, this is a stateful session, and I am trying to work out how you call a decision service using stateless sessions. The documentation is not at all clear on how to do this via the REST API, but has plenty of examples if you were using the Java API (unless I have missed something).

Does anyone have any examples on how to do this via REST?

Any help is gratefully received.

UPDATE First I meant version 7.3 not 7.4, but the documentation looks the same.

So it looks like I was not a million miles away, it looks like from the documentation supplied that I need to specify a session Id in a lookup param, so my request will be something like this:

{
  "lookup": "mysession",
  "commands": [
    {
      "insert": {
        "object": {
          "com.indecision.baggage.Result": {}
        },
        "return-object": true,
        "out-identifier": "results"
      }
    },
    {
      "insert": {
        "object": {
          "com.indecision.baggage.Booking": {
            "fareClass": "First",
            "baggageItems": [
              {
                "com.indecision.baggage.BaggageItem": {
                  "width": 100,
                  "height": 100,
                  "depth": 100,
                  "weight": 20
                }
              }
            ]
          }
        },
        "return-object": true,
        "out-identifier": "booking"
      }
    },
    {
      "insert": {
        "object": {
          "com.indecision.baggage.FlightInformation": {
            "currentWeight": 100000,
            "flightNumber": "IA001",
            "maxOperatingWeight": 200000
          }
        },
        "return-object": true,
        "out-identifier": "flightInfo"
      }
    },
    {
      "fire-all-rules": {
        "out-identifier": "firedActivations"
      }
    }
  ]
}

However when I send in the request, I get the following error message:

{
  "type": "FAILURE",
  "msg": "Error calling container Indecision-Airlines-Baggage-Fee-Calculator: Session 'mysession' not found on container 'Indecision-Airlines-Baggage-Fee-Calculator_1.0.0-SNAPSHOT'.",
  "result": null
}

Now in RH Business Central under the server configurations you can specify a session Id for the decision service, but the Save button is always greyed out regardless of what I try. So my first question is any ideas as to why or how enable the setting of this config?

enter image description here

My second question is if session Id's have to be defined up front then really these services cannot be truly stateless across multiple requests? As I see it, they would need to up front specify what session Id they want to execute under, rather than new requests having a new session created for them by the KIE engine. Or have I got that wrong?

Again thanks in advance for any answers.

Justin Phillips
  • 1,358
  • 2
  • 12
  • 26
  • For any future reader, please do not put 2 questions in one. Open a new one instead. "Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the [ask] page for help clarifying this question." – Hille Oct 08 '19 at 14:52

2 Answers2

1

You can reference this document for RHDM v7.4 API to interact with a knowledge session via either the Java API or REST API: doc link

I believe is a pertinent document so it will show you side-by-side the Java API and its REST API equivalent, so you can use it for your use-case.

The example reported there is relevant to stateless session as well, as long as you use the Batch command to wrap all of your commands; in other words, to me the examples reported in that document are expected to work with stateless session, no problem. If you experience otherwise don't hesitate to report it as a bug

Following the update on the original question

Q1: no, the attached screenshot in the question is about "process configuration". If you want to name a session purposefully, with your Project open in Business Central in the horizontal tab "Settings" in the vertical tab "Kie bases" you can edit the equivalent of the kmodule.xml and name your knowledge bases and session as desired. This identifier will then be the one to reference with the batch command.

Quick example screenshot for your reference:

enter image description here

Please notice on Business Central kmodule definition of session are by default stateless, which is expected.

Q2 not really, as described in the Drools/DM manual, a stateless session reference is not persisted/stateful, so what will happen is that your request will be handled in a stateless manner (because it's indeed a stateless session).

In other words, for any request sent to that stateless session named "mysession", a stateless session instance will handle your request, transparently.

You do not have to configure one session name per request.

tarilabs
  • 2,178
  • 2
  • 15
  • 23
  • I have added some more info and questions after trying what was suggested in the documentation. – Justin Phillips Aug 28 '19 at 08:47
  • 1
    @JustinPhillips I have updated the answer accordingly, although this was potentially another question per-se. I hope this helps you! Don't hesitate to always report bug or questions ;) If this question is answered, kindly don't forget to mark it as answered on StackOverflow. – tarilabs Aug 28 '19 at 09:13
  • Many thanks for the update. I have tried the KIE session setting but for some reason corrupts my project and I can no longer build or deploy my service. It has happen twice now :( Anyway I think I need to raise a bug on this. Is there a JIRA or GitLab repo for logging issues? – Justin Phillips Aug 28 '19 at 14:24
  • 1
    As you mentioned Red Hat Decision Manager, if you have a Red Hat Subscription the Customer Portal is the best support channel you can use. If instead you are using the community version, you can find link to the JIRA: https://issues.jboss.org/projects/DROOLS and all community channels here: https://drools.org/community/getHelp.html – tarilabs Aug 28 '19 at 14:30
  • Thanks. I kind of jumped the gun a bit and logged an issue here: https://issues.jboss.org/browse/RHDM-1074 – Justin Phillips Aug 28 '19 at 15:13
  • @JustinPhillips I believe is in your best interest I reiterate the fact that if you have a Red Hat Subscription, you raise issue through the Red Hat Customer Portal, so that the case is properly handled. I prefer to mention this as I'm not really sure what you meant by "jumped the gun".. If instead you don't have a Red Hat Subscription, then thank you for the JIRA as this will ensure is properly tracked. – tarilabs Aug 28 '19 at 16:25
1

I don't have enough reputation points yet to add a comment on tarilabs' answer, so I'm letting you know here as another answer that we've updated the KIE APIs document that tarilabs mentioned (for Red Hat Decision Manager and Process Automation Manager, and for Drools in community) with a note clarifying how to view or change a KIE session ID for use in the lookup command attribute. Hopefully this will help other users who have your same question. And thank you for raising that ticket about the issue you faced when you tried to modify the KIE session setting.

Also, I've shared with you the 7.4 version of that doc (although the same is updated in 7.3 as well) because I wanted to make you aware of a new Direct Documentation Feedback feature in our Red Hat Decision Manager and Process Automation Manager docs starting 7.4. You can highlight any part of the doc, click Add Feedback, and provide documentation feedback directly to our docs team to be assessed, prioritized, and addressed. For more info about this feature, see this announcement in the Red Hat Customer Portal.

If you have any other specific questions or suggestions for our Decision Manager or Process Automation Manager documentation, feel free to use that feedback feature in the Customer Portal. For community docs, feel free to use the community channels that tarilabs mentioned.

Thanks again for your feedback, Justin!

  • As you noticed, this is not the right place. Instead of dumping the doc changes and links to them you could just answer the question directly. Btw. thats an old question which was already answered. – Hille Oct 08 '19 at 14:53
  • Yes, as I explained, I needed to communicate this information to the asker in follow-up to the answer that my colleague already provided, but I could not (and still cannot) add comments to other people's conversations in SO until I have a rep of 50. So the only way to communicate this important info to the asker was to submit it as another answer to his question. If you know of a better way I could have communicated this info to the asker under these circumstances, please let me know and I'll rectify or do it differently next time. Thanks. – Stetson Robinson Oct 09 '19 at 18:47