Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-8324

Add support for Camel Autocomplete in Functions Definitions

    XMLWordPrintable

Details

    • SWF Camel Autocomplete
    • False
    • None
    • False
    • 75
    • 75% 75%
    • ---
    • ---
    • 2023 Week 06-08 (from Feb 6), 2023 Week 09-11 (from Feb 27), 2023 Week 12-14 (from Mar 20), 2023 Week 15-17 (from Apr 10), 2023 Week 24-26 (from Jun 12), 2023 Week 18-20 (from May 1), 2023 Week 21-23 (from May 22)

    Description

      To add supportability to Camel Routes within the same Workflow project, it would be a significant enhancement to the editors to add autocomplete as we do for openapi/ansible and so forth.

      The approach for this first iteration is to have a Camel function definition like this:

        "functions": [
          {
            "name": "callSoap",
            "type": "custom",
            "operation": "camel:direct:numberToWords"
          }
        ],
      

      The scheme camel: means that this is a Camel function. After that, we have the Camel endpoint. In this first iteration, only direct is supported. So the endpoint format should be camel:direct:<unique-endpoint-id>.

      To find the endpoints, the editor should look for the XML/YAML files within the project in the src/main/resources/routes. This path won't change. If it's not there, the engine won't load it.

      The editor then must parse these files and add to autocomplete these routes for the user to make the calls.

      This is an example of a Camel Route in XML format:

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- might look like that we are using Spring, but we are not. The XML DSL is derived from there, though -->
      <routes xmlns="http://camel.apache.org/schema/spring">
        <route id="sendSoapMessage">
          <from uri="direct:numberToWords"/>
          <!-- Converting our body to the type expected by the SOAP interface -->
          <bean beanType="java.math.BigInteger" method="valueOf"/>
          <setHeader name="operationName">
            <constant>NumberToWords</constant>
          </setHeader>
          <toD uri="cxf://{{com.dataaccess.webservicesserver.url}}?serviceClass=com.dataaccess.webservicesserver.NumberConversionSoapType&amp;wsdlURL=/wsdl/numberconversion.wsdl"/>
        </route>
      </routes>
      

      The http://camel.apache.org/schema/spring has an XSD in this URI. We can use it to parse/validate the route. YAML should be supported too.

      Another option for users is to declare the Routes in Java classes, but this can be skipped for the editor for now, unless we want to parse Java files too

      When referring to the function in the state, this is how it looks like:

      {
          "functionRef": {
              "refName": "callSoap",
              "arguments": {
                  "body": "${ .number }"
               }
           }
      }
      

      The editor should validate the arguments. It can either be 0 or 1.

      You can see a user's project example here:
      https://github.com/ricardozanini/kogito-addons-quarkus-camel/tree/main/example

      Attachments

        Issue Links

          Activity

            People

              paulovmr Paulo Rego
              rhn-support-zanini Ricardo Zanini Fernandes
              Tomas David Tomas David
              Tomas David Tomas David
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: