Messaging

Use the Messaging policy to trigger a messaging extension based on the specified conditions to enable request and response transformations.

For the Messaging policy kind, configure these specifications:
Code view Form view Description
enabled N.A.

Specifies whether the policy is active. Set the value to true to enable the policy, and set it to false to disable the policy.

condition Conditions

Conditions are used to specify when the policy is run. You can add multiple conditions with logical operators. Provide the condition in the format: {set} operator {value} condition {set} operator {value}

You can configure the following conditions in the Conditions section:

  • Transform the requests that comply with all the configured conditions in the code view by using and, or in the form view by selecting the AND option.
  • Transform the requests that comply with any one configured condition in the code view by using or, or in the form view by selecting the OR option.

You can use the following operators in the code view and in the form view by using the Add condition button, which is optional.

  • Equals
  • Equals ignore case
  • Not equals
  • Not equals ignore case
  • Contains
  • Not Contains
  • Exists
  • Not Exists
  • IP Range
  • Greater Than
  • Lesser Than
messageConfig Messaging
Configures the messaging system details such as connection, destination, and message format. Define these message configurations:
  • Connection alias name
  • Destination name
  • Destination type.

    Select either QUEUE or TOPIC.

  • ReplyTo name, which is an optional field.
  • ReplyTo type.

    Select either QUEUE or TOPIC.

  • Time to live, enter the value in milliseconds.
  • Time to wait, enter the value in milliseconds.
  • Delivery mode.

    Select either Non persistent or Persistent.

request_processing Request processing

Specifies the request processing parameters.

You can configure the following transformation fields for both setPayload and remove functions:

  • Set the payload content type in the code view by using setPayload and in the form view, use the Payload type field, which is an optional step.

    Configure the content type in the code view using content-types, and in the form view use the Payload type field, which is an optional step. You can also choose to activate the Auto-format payload option.

    These are the content types that can be configured:
    • application/jsonin the code view and JSON in the form view. This is the default content type. On selecting this option, a code editor opens up for you to configure the content requirements.

    • application/xmlin the code view and XML in the form view. On selecting this, you get an option to upload an XML file.

    • text/plainin the code view and Text in the form view. On selecting this, you get a plain text box to configure the file.

  • Add or update a new header in the message configuration request in the code view by using set and configure the key and value.

    In the form view, use the Add header parameter button for this configuration where you can specify the Header name and Header value.

response_processing Response processing

Specifies the response processing parameters.

  • Specify the response processing parameters in the code view by using response_processing, or in the form view using the Response processing section.

    Configure the following details:
    • Complete response from the messaging extension is forwarded back to the client in the code view when you set the copyEntireResponse to true.

      In the form view, you can configure this by selecting the Copy entire response field, which is optional.

    • Specify if the API execution should be stopped in case of messaging extension invocation failure in the code view when you set the abortAPIExecutionForFailure to true.

      In the form view, you can configure this by selecting the Abort API execution in case of failure field, which is optional.

    • Click the button in the Transformation section to configure the response processing transformation.
    • In the code view, configure the set function and add the required details as key and value.

      In the form view, use the Add transformations button for this configuration where you can specify the Variable and Value, which are both optional fields.

namespaces Namespace

Configure the metadata for the message configuration request.

In the code view, under namespaces, configure the prefix and URI.

In the form view, use the Custom metadata extension tab to configure the metadata. Click the Add namespace button for this configuration and specify the Namespace prefix and Namespace URL, which are both optional fields.

Example of a Messaging policy in code view.

kind: InvokeMessagingExtension
apiVersion: api.webmethods.io/beta
metadata:
  name: messaging-extension
  version: 1
  namespace: sample
  tags:
      - invoke
      - messaging
      - extension
      - policy
spec:
  enabled: true
  condition: (${request.httpMethod} equals POST) or (${request.headers.name} notEquals ${request.payload.jsonPath[$.customer.name]})
   # other operators include Equals, Equals ignore case, Not equals, Not equals ignore case, Contains, Not Contains, Exists, Not Exists, IP Range, Greater Than, Lesser Than
  messageConfig:
    $ref: sample:MessageConfig:1.0
  request_processing:
    transformations:
    set:
      - key: ${request.headers.h2}
        value: test4
      - key: ${request.query.q2}
        value: ${request.payload.jsonPath[$.customer.name]}
    setPayload:
      content-types:
        - application/json: |
                      {"empid" : "1"}
        - application/xml: | 
                      <a>a<a>
        - text/plain: |
                    sample text
      default-ContentType: application/json
      xsl:
        - feature:
            - name: test
              value: value
          $path: ./a/a.xsl
          content: sdsd
    remove:
  response_processing:
    transformations:
    set:
      - key: ${request.headers.h2}
        value: test4
      - key: ${request.query.q2}
        value: ${request.payload.jsonPath[$.customer.name]}
    copyEntireResponse: true
    abortAPIExecutionForFailure: true 
  namespaces:
      - prefix: ps1
        URI: http://test.com
      - prefix: ps2
        URI: http://test2.com