IntegrationCallout policy

Extensible policy

This page applies to Apigee and Apigee hybrid.

The IntegrationCallout policy lets you run an Application Integration that has an API trigger. However, before running an integration, you must run the SetIntegrationRequest policy. The SetIntegrationRequest policy creates a request object and makes the object available to the IntegrationCallout policy as a flow variable. The request object has the integration details such as the API trigger name, integration project ID, integration name, and other details configured in the SetIntegrationRequest policy. The IntegrationCallout policy uses the flow variable of the request object to run the integration. You can configure the IntegrationCallout policy to save the integration run response in a flow variable.

The IntegrationCallout policy is helpful if you want to run integration in the middle of your proxy flow. Alternately, instead of configuring the IntegrationCallout policy, you can also run an integration by specifying an integration endpoint as your target endpoint. For more information, see IntegrationEndpoint.

This policy is an Extensible policy and use of this policy might have cost or utilization implications, depending on your Apigee license. For information on policy types and usage implications, see Policy types.

<IntegrationCallout>

Specifies the IntegrationCallout policy.

Default Value N/A
Required? Required
Type Complex type
Parent Element N/A
Child Elements <DisplayName>
<AsyncExecution>
<Request>
<Response>

The following table provides a high-level description of the child elements of <IntegrationCallout>:

Child Element Required? Description
<DisplayName> Optional A custom name for the policy.
<AsyncExecution> Optional Specifies if the integration must run in synchronous mode or asynchronous mode.
<Request> Required The flow variable having the request object created by the SetIntegrationRequest policy.
<Response> Optional The flow variable to save the integration's response.

The <IntegrationCallout> element uses the following syntax:

Syntax

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<IntegrationCallout continueOnError="[true|false]" enabled="[true|false]" name=POLICY_NAME>
  <DisplayName>POLICY_DISPLAY_NAME</DisplayName>
  <AsyncExecution>BOOLEAN_ASYNC_EXECUTION</AsyncExecution>
  <Request clearPayload="[true|false]">REQUEST_FLOW_VARIABLE_NAME</Request>
  <Response>RESPONSE_FLOW_VARIABLE_NAME</Response>
</IntegrationCallout>

Example

The following example shows the IntegrationCallout policy definition:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<IntegrationCallout continueOnError="false" enabled="true" name="Integration-Callout">
  <DisplayName>Integration-Callout-1</DisplayName>
  <AsyncExecution>true</AsyncExecution>
  <Request clearPayload="true">my_request_flow_var</Request>
  <Response>my_response_flow_var</Response>
</IntegrationCallout>

This element has the following attributes that are common to all policies:

Attribute Default Required? Description
name N/A Required

The internal name of the policy. The value of the name attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the <DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

continueOnError false Optional Set to false to return an error when a policy fails. This is expected behavior for most policies. Set to true to have flow execution continue even after a policy fails. See also:
enabled true Optional Set to true to enforce the policy. Set to false to turn off the policy. The policy will not be enforced even if it remains attached to a flow.
async   false Deprecated This attribute is deprecated.

Child element reference

This section describes the child elements of <IntegrationCallout>.

<DisplayName>

Use in addition to the name attribute to label the policy in the management UI proxy editor with a different, more natural-sounding name.

The <DisplayName> element is common to all policies.

Default Value N/A
Required? Optional. If you omit <DisplayName>, the value of the policy's name attribute is used.
Type String
Parent Element <PolicyElement>
Child Elements None

The <DisplayName> element uses the following syntax:

Syntax

<PolicyElement>
  <DisplayName>POLICY_DISPLAY_NAME</DisplayName>
  ...
</PolicyElement>

Example

<PolicyElement>
  <DisplayName>My Validation Policy</DisplayName>
</PolicyElement>

The <DisplayName> element has no attributes or child elements.

<AsyncExecution>

Specifies the mode to run the integration. You can run the integration either synchronously or asynchronously.

If set to true, the integration runs asynchronously. And if set to false, the integration runs synchronously.

  • Asynchronous mode: When the request to run the integration reaches the endpoint, the endpoint immediately returns the integration execution IDs, but starts the execution of integration at the time specified by the <ScheduleTime> element. If you have not set the <ScheduleTime> element, the integration is scheduled to run immediately. Even though the integration is scheduled to run immediately, its execution may start after a few seconds. When the integration starts to execute, the following two things happen:
    • The integration returns the HTTP 200 OK status code so that the caller can continue processing.
    • The IntegrationCallout policy completes.
    Once started, the integration will have a maximum time limit of 50 minutes to complete the execution.
  • Synchronous mode: When the request to run the integration reaches the endpoint, the endpoint immediately starts the execution of the integration and waits for the response. The maximum time limit to complete the execution is 2 minutes. After finishing the execution, the endpoint returns a response with the execution IDs and other response data.
Default Value false
Required? Optional
Type Boolean
Parent Element <IntegrationCallout>
Child Elements None

The <AsyncExecution> element uses the following syntax:

Syntax

<AsyncExecution>BOOLEAN</AsyncExecution>

Example

The following example sets asynchronous execution to true:

<AsyncExecution>true</AsyncExecution>

<Request>

Specifies the flow variable having the request object created by the SetIntegrationRequest policy. The IntegrationCallout policy sends this request object to Application Integration for running the integration.

Default Value N/A
Required? Required
Type String
Parent Element <IntegrationCallout>
Child Elements None

The <Request> element uses the following syntax:

Syntax

<Request clearPayload="true">FLOW_VARIABLE_NAME</Request>

Example

The following example specifies that the request object is available in the my_request_flow_var flow variable:

<Request clearPayload="true">my_request_flow_var</Request>

The following table describes the attributes of <Request>:

Attribute Required? Type Description
clearPayload Optional boolean

Specifies if the request object should be cleared from the memory after sending the request to run the integration.

  • If set to true, Apigee clears the request object.
  • If set to false, Apigee doesn't clear the request object.

If you don't specify this attribute, the default value is true and the request object is cleared from the memory.

<Response>

Specifies the flow variable for saving the integration's response.

If you don't specify this element, the policy saves the response in the integration.response flow variable.

Default Value integration.response
Required? Optional
Type String
Parent Element <IntegrationCallout>
Child Elements None

The output of the integration can be accessed by integration.response.content or flow_variable.content. The <Response> element uses the following syntax:

Syntax

<Response>FLOW_VARIABLE_NAME</Response>

Example

The following example saves the response of the integration run in the my_response_flow_var flow variable:

<Response>my_response_flow_var</Response>

Error codes

本部分介绍当此政策触发错误时的故障代码、错误消息以及由 Apigee 设置的故障变量。在您要开发故障规则来处理故障时,此信息非常重要。如需了解详情,请参阅您需要了解的有关政策错误的信息和处理故障。

运行时错误

政策执行时可能会发生这些错误。

故障代码 HTTP 状态 原因
entities.UnresolvedVariable 500 如果 Apigee 无法解析 integration.project.id 或 integration.name 变量,则会发生此错误。
steps.integrationcallout.ExecutionFailed 500

如果后端目标服务返回 HTTP 错误状态,例如 4xx 或 5xx,则可能会发生此错误。可能的原因包括:

  • 使用代理部署的服务账号用于运行集成的权限不正确。
  • 集成或 API 触发器不存在。
  • 您的 Google Cloud 项目未启用 Application Integration。
  • 您在 SetIntegrationRequest 政策中配置了 <ScheduleTime> 元素,并且 IntegrationCallout 政策将 AsyncExecution 设置为 false。
steps.integrationcallout.NullRequestVariable 500 如果在 <Request> 中指定的流变量为 null,则会发生此错误。
steps.integrationcallout.RequestVariableNotMessageType 500 当 Request 元素指定的流变量不是消息类型时,会发生此错误。
steps.integrationcallout.RequestVariableNotRequestMessageType 500 当 Request 元素指定的流变量不是请求消息类型时,会发生此错误。
messaging.adaptors.http.filter.GoogleTokenGenerationFailure 500

此错误可能是由服务账号配置错误造成的。可能的原因包括:

  • 您的项目中不存在使用代理部署的服务账号。
  • 使用代理部署的服务账号已停用。

故障变量

只要政策中存在执行错误,Apigee 就会生成错误消息。您可以在错误响应中查看这些错误消息。很多时候,系统生成的错误消息可能与您的产品上下文无关。您可能希望根据错误类型自定义错误消息,以使消息更有意义。

如需自定义错误消息,可以使用故障规则或 RaiseFault 政策。如需了解故障规则与 RaiseFault 政策之间的差异,请参阅 FaultRule 与 RaiseFault 政策。您必须使用故障规则和 RaiseFault 政策中的 Condition 元素来检查条件。Apigee 提供每个政策独有的故障变量,并在政策触发运行时错误时设置故障变量的值。通过使用这些变量,您可以检查特定的错误情况并采取适当的操作。如需详细了解如何检查错误条件,请参阅构建条件。

下表介绍了特定于此政策的故障变量。

变量 其中 示例
fault.name fault.name 可以匹配运行时错误表中列出的任何故障。故障名称是故障代码的最后一部分。 fault.name Matches "UnresolvedVariable"
IntegrationCallout.POLICY_NAME.failed POLICY_NAME 是抛出故障的政策的用户指定名称。 IntegrationCallout.integration-callout-1.failed = true
如需详细了解政策错误,请参阅您需要了解的政策错误相关信息。

Related topics

If you want to learn more about Application Integration feature, see Application Integration overview