Antipadrão: acessar o payload de solicitação/resposta quando o streaming estiver ativado
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Esta é a documentação da Apigee e da Apigee híbrida.
Confira a documentação da Apigee Edge.
Na Apigee, o comportamento padrão é que os payloads HTTP de solicitação e resposta sejam armazenados em um
buffer na memória antes de serem processados pelas políticas no proxy da API.
Se o streaming estiver ativado, os payloads de solicitação e resposta serão transmitidos sem modificação para
o app cliente (para respostas) e o endpoint de destino (para solicitações). O streaming é útil especialmente se um aplicativo aceitar ou retornar payloads grandes ou se houver um aplicativo que retorne dados em partes ao longo do tempo.
Antipadrão
O acesso ao payload de solicitação/resposta com streaming ativado faz com que a Apigee retorne ao modo de buffer padrão.
Figura 1: acesso ao payload de solicitação/resposta com streaming ativado
A ilustração acima mostra que estamos tentando extrair variáveis do payload da solicitação e
converter o payload da resposta JSON em XML usando a política JSONToXML. Isso desativará o streaming
na Apigee.
Impacto
O streaming será desativado, o que pode aumentar a latência no processamento dos dados.
É possível observar um aumento no uso de memória de heap ou erros de OutOfMemory nos processadores de mensagens devido ao uso de buffers na memória, especialmente se houver grandes payloads de solicitação/resposta
Prática recomendada
Não acesse o payload de solicitação/resposta quando o streaming estiver ativado.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 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)"]]