Antipatrón: Accede a la carga útil de la solicitud o respuesta cuando la transmisión está habilitada
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Estás viendo la documentación de Apigee y Apigee Hybrid.
Consulta la documentación de Apigee Edge.
En Apigee, el comportamiento predeterminado es que las cargas útiles de solicitud y respuesta HTTP se almacenen en un búfer en memoria antes de que las políticas del proxy de API las procesen.
Si la transmisión está habilitada, las cargas útiles de solicitud y respuesta se transmiten sin modificaciones a la app cliente (para las respuestas) y el extremo de destino (para las solicitudes). La transmisión es útil, en especial si una aplicación acepta o muestra cargas útiles grandes, o si hay una aplicación que muestre datos en fragmentos en el tiempo.
Antipatrón
El acceso a la carga útil de solicitud o respuesta con la transmisión habilitada hace que Apigee regrese al modo de almacenamiento en búfer predeterminado.
Figura 1: Acceso a la carga útil de la solicitud o respuesta con la transmisión habilitada
En la ilustración anterior, se muestra que intentamos extraer variables de la carga útil de la solicitud y convertir la carga útil de la respuesta de JSON a XML mediante la política JSONToXML. Esto inhabilitará la transmisión en Apigee.
Impacto
La transmisión se inhabilitará, lo que puede generar mayores latencias en el procesamiento de los datos.
Se puede observar el uso de la memoria del montón o errores de OutOfMemory en los procesadores de mensajes debido al uso de búferes en la memoria, especialmente si tienes cargas útiles grandes de solicitud o respuesta.
Práctica recomendada
No accedas a la carga útil de la solicitud o respuesta cuando la transmisión está habilitada.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-03 (UTC)"],[[["\u003cp\u003eApigee's default behavior involves buffering HTTP request and response payloads in memory, but streaming can be enabled to send payloads directly to clients or target endpoints.\u003c/p\u003e\n"],["\u003cp\u003eAccessing request or response payloads when streaming is enabled in Apigee will revert the system to the default buffering mode.\u003c/p\u003e\n"],["\u003cp\u003eDisabling streaming by accessing the request/response payload can result in increased latency and higher memory consumption, potentially leading to \u003ccode\u003eOutOfMemory\u003c/code\u003e errors.\u003c/p\u003e\n"],["\u003cp\u003eThe recommended practice is to avoid accessing the request/response payload when streaming is active to maintain the benefits of streaming.\u003c/p\u003e\n"],["\u003cp\u003eStreaming is beneficial for applications that handle large payloads or data delivered in chunks over time.\u003c/p\u003e\n"]]],[],null,["# Antipattern: Accessing the request/response payload when streaming is enabled\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/antipatterns/payload-with-streaming) documentation.*\n\nIn Apigee, the default behavior is that HTTP request and response payloads are stored in an\nin-memory buffer before they are processed by the policies in the API Proxy.\n\nIf streaming is enabled, then request and response payloads are streamed without modification to\nthe client app (for responses) and the target endpoint (for requests). Streaming is useful\nespecially if an application accepts or returns large payloads, or if there's an application that\nreturns data in chunks over time.\n\nAntipattern\n-----------\n\nAccessing the request/response payload with streaming enabled causes Apigee to go back to the\ndefault buffering mode.\n**Figure 1**: Accessing request/response payload with streaming enabled\n\nThe illustration above shows that we are trying to extract variables from the request payload and\nconverting the JSON response payload to XML using JSONToXML policy. This will disable the streaming\nin Apigee.\n\nImpact\n------\n\n- Streaming will be disabled which can lead to increased latencies in processing the data\n- Increase in the heap memory usage or `OutOfMemory` errors can be observed on Message Processors due to use of in-memory buffers especially if we have large request/response payloads\n\nBest practice\n-------------\n\n- Don't access the request/response payload when streaming is enabled.\n\nFurther reading\n---------------\n\n- [Streaming requests and responses](/apigee/docs/api-platform/develop/enabling-streaming)\n- [How does Apigee streaming work?](https://www.googlecloudcommunity.com/gc/Apigee/How-does-APIGEE-Edge-Streaming-work/td-p/38511)\n- [How to handle streaming data together with normal request/response payload in a single API Proxy](https://www.googlecloudcommunity.com/gc/Apigee/How-to-handle-streaming-data-together-with-normal-request/m-p/49986)\n- [Best practices for API proxy design and development](/apigee/docs/api-platform/fundamentals/best-practices-api-proxy-design-and-development)"]]