| <!DOCTYPE HTML> |
| <html lang="en" > |
| |
| <head> |
| |
| <meta charset="UTF-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| <title>Flow Control | ActiveMQ Artemis Documentation</title> |
| <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
| <meta name="description" content=""> |
| <meta name="generator" content="GitBook 2.1.0"> |
| |
| |
| <meta name="HandheldFriendly" content="true"/> |
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
| <meta name="apple-mobile-web-app-capable" content="yes"> |
| <meta name="apple-mobile-web-app-status-bar-style" content="black"> |
| <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png"> |
| <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon"> |
| |
| <link rel="stylesheet" href="gitbook/style.css"> |
| |
| |
| |
| |
| |
| |
| <link rel="next" href="./send-guarantees.html" /> |
| |
| |
| <link rel="prev" href="./transaction-config.html" /> |
| |
| |
| |
| </head> |
| <body> |
| |
| |
| <div class="book" data-level="20" data-basepath="." data-revision="Wed Jun 08 2016 13:05:37 GMT+0100 (BST)"> |
| |
| |
| <div class="book-summary"> |
| <div class="book-search"> |
| <input type="text" placeholder="Type to search" class="form-control" /> |
| </div> |
| <ul class="summary"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="chapter " data-level="0" data-path="index.html"> |
| |
| |
| <a href="./index.html"> |
| <i class="fa fa-check"></i> |
| |
| Introduction |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1" data-path="notice.html"> |
| |
| |
| <a href="./notice.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>1.</b> |
| |
| Legal Notice |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="2" data-path="preface.html"> |
| |
| |
| <a href="./preface.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>2.</b> |
| |
| Preface |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="3" data-path="project-info.html"> |
| |
| |
| <a href="./project-info.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>3.</b> |
| |
| Project Info |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="4" data-path="messaging-concepts.html"> |
| |
| |
| <a href="./messaging-concepts.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>4.</b> |
| |
| Messaging Concepts |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="5" data-path="architecture.html"> |
| |
| |
| <a href="./architecture.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>5.</b> |
| |
| Architecture |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="6" data-path="using-server.html"> |
| |
| |
| <a href="./using-server.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>6.</b> |
| |
| Using the Server |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="7" data-path="using-jms.html"> |
| |
| |
| <a href="./using-jms.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>7.</b> |
| |
| Using JMS |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="8" data-path="using-core.html"> |
| |
| |
| <a href="./using-core.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>8.</b> |
| |
| Using Core |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="9" data-path="jms-core-mapping.html"> |
| |
| |
| <a href="./jms-core-mapping.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>9.</b> |
| |
| Mapping JMS Concepts to the Core API |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="10" data-path="client-classpath.html"> |
| |
| |
| <a href="./client-classpath.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>10.</b> |
| |
| The Client Classpath |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="11" data-path="examples.html"> |
| |
| |
| <a href="./examples.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>11.</b> |
| |
| Examples |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="12" data-path="wildcard-routing.html"> |
| |
| |
| <a href="./wildcard-routing.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>12.</b> |
| |
| Routing Messages With Wild Cards |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="13" data-path="wildcard-syntax.html"> |
| |
| |
| <a href="./wildcard-syntax.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>13.</b> |
| |
| Understanding the Apache ActiveMQ Artemis Wildcard Syntax |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="14" data-path="filter-expressions.html"> |
| |
| |
| <a href="./filter-expressions.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>14.</b> |
| |
| Filter Expressions |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="15" data-path="persistence.html"> |
| |
| |
| <a href="./persistence.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>15.</b> |
| |
| Persistence |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="16" data-path="configuring-transports.html"> |
| |
| |
| <a href="./configuring-transports.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>16.</b> |
| |
| Configuring Transports |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="17" data-path="connection-ttl.html"> |
| |
| |
| <a href="./connection-ttl.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>17.</b> |
| |
| Detecting Dead Connections |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="18" data-path="slow-consumers.html"> |
| |
| |
| <a href="./slow-consumers.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>18.</b> |
| |
| Detecting Slow Consumers |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="19" data-path="transaction-config.html"> |
| |
| |
| <a href="./transaction-config.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>19.</b> |
| |
| Resource Manager Configuration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter active" data-level="20" data-path="flow-control.html"> |
| |
| |
| <a href="./flow-control.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>20.</b> |
| |
| Flow Control |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="21" data-path="send-guarantees.html"> |
| |
| |
| <a href="./send-guarantees.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>21.</b> |
| |
| Guarantees of sends and commits |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="22" data-path="undelivered-messages.html"> |
| |
| |
| <a href="./undelivered-messages.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>22.</b> |
| |
| Message Redelivery and Undelivered Messages |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="23" data-path="message-expiry.html"> |
| |
| |
| <a href="./message-expiry.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>23.</b> |
| |
| Message Expiry |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="24" data-path="large-messages.html"> |
| |
| |
| <a href="./large-messages.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>24.</b> |
| |
| Large Messages |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="25" data-path="paging.html"> |
| |
| |
| <a href="./paging.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>25.</b> |
| |
| Paging |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="26" data-path="queue-attributes.html"> |
| |
| |
| <a href="./queue-attributes.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>26.</b> |
| |
| Queue Attributes |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="27" data-path="scheduled-messages.html"> |
| |
| |
| <a href="./scheduled-messages.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>27.</b> |
| |
| Scheduled Messages |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="28" data-path="last-value-queues.html"> |
| |
| |
| <a href="./last-value-queues.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>28.</b> |
| |
| Last-Value Queues |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="29" data-path="message-grouping.html"> |
| |
| |
| <a href="./message-grouping.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>29.</b> |
| |
| Message Grouping |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="30" data-path="pre-acknowledge.html"> |
| |
| |
| <a href="./pre-acknowledge.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>30.</b> |
| |
| Extra Acknowledge Modes |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="31" data-path="management.html"> |
| |
| |
| <a href="./management.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>31.</b> |
| |
| Management |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="32" data-path="security.html"> |
| |
| |
| <a href="./security.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>32.</b> |
| |
| Security |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="33" data-path="resource-limits.html"> |
| |
| |
| <a href="./resource-limits.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>33.</b> |
| |
| Resource Limits |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="34" data-path="jms-bridge.html"> |
| |
| |
| <a href="./jms-bridge.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>34.</b> |
| |
| The JMS Bridge |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="35" data-path="client-reconnection.html"> |
| |
| |
| <a href="./client-reconnection.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>35.</b> |
| |
| Client Reconnection and Session Reattachment |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="36" data-path="diverts.html"> |
| |
| |
| <a href="./diverts.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>36.</b> |
| |
| Diverting and Splitting Message Flows |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="37" data-path="core-bridges.html"> |
| |
| |
| <a href="./core-bridges.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>37.</b> |
| |
| Core Bridges |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="38" data-path="duplicate-detection.html"> |
| |
| |
| <a href="./duplicate-detection.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>38.</b> |
| |
| Duplicate Message Detection |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="39" data-path="clusters.html"> |
| |
| |
| <a href="./clusters.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>39.</b> |
| |
| Clusters |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="40" data-path="ha.html"> |
| |
| |
| <a href="./ha.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>40.</b> |
| |
| High Availability and Failover |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="41" data-path="graceful-shutdown.html"> |
| |
| |
| <a href="./graceful-shutdown.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>41.</b> |
| |
| Graceful Server Shutdown |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="42" data-path="libaio.html"> |
| |
| |
| <a href="./libaio.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>42.</b> |
| |
| Libaio Native Libraries |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="43" data-path="thread-pooling.html"> |
| |
| |
| <a href="./thread-pooling.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>43.</b> |
| |
| Thread management |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="44" data-path="logging.html"> |
| |
| |
| <a href="./logging.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>44.</b> |
| |
| Logging |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="45" data-path="rest.html"> |
| |
| |
| <a href="./rest.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>45.</b> |
| |
| REST Interface |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="46" data-path="embedding-activemq.html"> |
| |
| |
| <a href="./embedding-activemq.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>46.</b> |
| |
| Embedding Apache ActiveMQ Artemis |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="47" data-path="karaf.html"> |
| |
| |
| <a href="./karaf.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>47.</b> |
| |
| Apache Karaf |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="48" data-path="spring-integration.html"> |
| |
| |
| <a href="./spring-integration.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>48.</b> |
| |
| Spring Integration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="49" data-path="aerogear-integration.html"> |
| |
| |
| <a href="./aerogear-integration.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>49.</b> |
| |
| AeroGear Integration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="50" data-path="vertx-integration.html"> |
| |
| |
| <a href="./vertx-integration.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>50.</b> |
| |
| VertX Integration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="51" data-path="intercepting-operations.html"> |
| |
| |
| <a href="./intercepting-operations.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>51.</b> |
| |
| Intercepting Operations |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="52" data-path="protocols-interoperability.html"> |
| |
| |
| <a href="./protocols-interoperability.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>52.</b> |
| |
| Protocols and Interoperability |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="53" data-path="tools.html"> |
| |
| |
| <a href="./tools.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>53.</b> |
| |
| Tools |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="54" data-path="maven-plugin.html"> |
| |
| |
| <a href="./maven-plugin.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>54.</b> |
| |
| Maven Plugin |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="55" data-path="perf-tuning.html"> |
| |
| |
| <a href="./perf-tuning.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>55.</b> |
| |
| Troubleshooting and Performance Tuning |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="56" data-path="configuration-index.html"> |
| |
| |
| <a href="./configuration-index.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>56.</b> |
| |
| Configuration Reference |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| |
| |
| <li class="divider"></li> |
| <li> |
| <a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
| Published with GitBook |
| </a> |
| </li> |
| |
| </ul> |
| </div> |
| |
| <div class="book-body"> |
| <div class="body-inner"> |
| <div class="book-header"> |
| <!-- Actions Left --> |
| <a href="#" class="btn pull-left toggle-summary" aria-label="Table of Contents"><i class="fa fa-align-justify"></i></a> |
| <a href="#" class="btn pull-left toggle-search" aria-label="Search"><i class="fa fa-search"></i></a> |
| |
| <div id="font-settings-wrapper" class="dropdown pull-left"> |
| <a href="#" class="btn toggle-dropdown" aria-label="Font Settings"><i class="fa fa-font"></i> |
| </a> |
| <div class="dropdown-menu font-settings"> |
| <div class="dropdown-caret"> |
| <span class="caret-outer"></span> |
| <span class="caret-inner"></span> |
| </div> |
| |
| <div class="buttons"> |
| <button type="button" id="reduce-font-size" class="button size-2">A</button> |
| <button type="button" id="enlarge-font-size" class="button size-2">A</button> |
| </div> |
| |
| <div class="buttons font-family-list"> |
| <button type="button" data-font="0" class="button">Serif</button> |
| <button type="button" data-font="1" class="button">Sans</button> |
| </div> |
| |
| <div class="buttons color-theme-list"> |
| <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">White</button> |
| <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">Sepia</button> |
| <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">Night</button> |
| </div> |
| </div> |
| |
| </div> |
| |
| <!-- Actions Right --> |
| |
| <div class="dropdown pull-right"> |
| <a href="#" class="btn toggle-dropdown" aria-label="Share"><i class="fa fa-share-alt"></i> |
| </a> |
| <div class="dropdown-menu font-settings dropdown-left"> |
| <div class="dropdown-caret"> |
| <span class="caret-outer"></span> |
| <span class="caret-inner"></span> |
| </div> |
| <div class="buttons"> |
| <button type="button" data-sharing="twitter" class="button"> |
| Share on Twitter |
| </button> |
| <button type="button" data-sharing="google-plus" class="button"> |
| Share on Google |
| </button> |
| <button type="button" data-sharing="facebook" class="button"> |
| Share on Facebook |
| </button> |
| <button type="button" data-sharing="weibo" class="button"> |
| Share on Weibo |
| </button> |
| <button type="button" data-sharing="instapaper" class="button"> |
| Share on Instapaper |
| </button> |
| </div> |
| </div> |
| </div> |
| |
| |
| |
| <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a> |
| |
| |
| <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a> |
| |
| |
| <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a> |
| |
| |
| |
| |
| |
| <!-- Title --> |
| <h1> |
| <i class="fa fa-circle-o-notch fa-spin"></i> |
| <a href="./" >ActiveMQ Artemis Documentation</a> |
| </h1> |
| </div> |
| |
| <div class="page-wrapper" tabindex="-1"> |
| <div class="page-inner"> |
| |
| |
| <section class="normal" id="section-"> |
| |
| <h1 id="flow-control">Flow Control</h1> |
| <p>Flow control is used to limit the flow of data between a client and |
| server, or a server and another server in order to prevent the client or |
| server being overwhelmed with data.</p> |
| <h2 id="consumer-flow-control">Consumer Flow Control</h2> |
| <p>This controls the flow of data between the server and the client as the |
| client consumes messages. For performance reasons clients normally |
| buffer messages before delivering to the consumer via the <code>receive()</code> |
| method or asynchronously via a message listener. If the consumer cannot |
| process messages as fast as they are being delivered and stored in the |
| internal buffer, then you could end up with a situation where messages |
| would keep building up possibly causing out of memory on the client if |
| they cannot be processed in time.</p> |
| <h2 id="window-based-flow-control">Window-Based Flow Control</h2> |
| <p>By default, Apache ActiveMQ Artemis consumers buffer messages from the server in a |
| client side buffer before the client consumes them. This improves |
| performance: otherwise every time the client consumes a message, |
| Apache ActiveMQ Artemis would have to go the server to request the next message. In |
| turn, this message would then get sent to the client side, if one was |
| available.</p> |
| <p>A network round trip would be involved for <em>every</em> message and |
| considerably reduce performance.</p> |
| <p>To prevent this, Apache ActiveMQ Artemis pre-fetches messages into a buffer on each |
| consumer. The total maximum size of messages (in bytes) that will be |
| buffered on each consumer is determined by the <code>consumerWindowSize</code> |
| parameter.</p> |
| <p>By default, the <code>consumerWindowSize</code> is set to 1 MiB (1024 * 1024 |
| bytes).</p> |
| <p>The value can be:</p> |
| <ul> |
| <li><p><code>-1</code> for an <em>unbounded</em> buffer</p> |
| </li> |
| <li><p><code>0</code> to not buffer any messages.</p> |
| </li> |
| <li><p><code>>0</code> for a buffer with the given maximum size in bytes.</p> |
| </li> |
| </ul> |
| <p>Setting the consumer window size can considerably improve performance |
| depending on the messaging use case. As an example, let's consider the |
| two extremes:</p> |
| <h3 id="fast-consumers">Fast consumers</h3> |
| <p>Fast consumers can process messages as fast as they consume them (or |
| even faster)</p> |
| <p>To allow fast consumers, set the <code>consumerWindowSize</code> to -1. This |
| will allow <em>unbounded</em> message buffering on the client side.</p> |
| <p>Use this setting with caution: it can overflow the client memory if |
| the consumer is not able to process messages as fast as it receives |
| them.</p> |
| <h3 id="slow-consumers">Slow consumers</h3> |
| <p>Slow consumers takes significant time to process each message and it |
| is desirable to prevent buffering messages on the client side so |
| that they can be delivered to another consumer instead.</p> |
| <p>Consider a situation where a queue has 2 consumers; 1 of which is |
| very slow. Messages are delivered in a round robin fashion to both |
| consumers, the fast consumer processes all of its messages very |
| quickly until its buffer is empty. At this point there are still |
| messages awaiting to be processed in the buffer of the slow consumer |
| thus preventing them being processed by the fast consumer. The fast |
| consumer is therefore sitting idle when it could be processing the |
| other messages.</p> |
| <p>To allow slow consumers, set the <code>consumerWindowSize</code> to 0 (for no |
| buffer at all). This will prevent the slow consumer from buffering |
| any messages on the client side. Messages will remain on the server |
| side ready to be consumed by other consumers.</p> |
| <p>Setting this to 0 can give deterministic distribution between |
| multiple consumers on a queue.</p> |
| <p>Most of the consumers cannot be clearly identified as fast or slow |
| consumers but are in-between. In that case, setting the value of |
| <code>consumerWindowSize</code> to optimize performance depends on the messaging |
| use case and requires benchmarks to find the optimal value, but a value |
| of 1MiB is fine in most cases.</p> |
| <h3 id="using-core-api">Using Core API</h3> |
| <p>If Apache ActiveMQ Artemis Core API is used, the consumer window size is specified by |
| <code>ServerLocator.setConsumerWindowSize()</code> method and some of the |
| <code>ClientSession.createConsumer()</code> methods.</p> |
| <h3 id="using-jms">Using JMS</h3> |
| <p>If JNDI is used on the client to instantiate and look up the connection |
| factory the consumer window size is configured in the JNDI context |
| environment, e.g. <code>jndi.properties</code>. Here's a simple example using the |
| "ConnectionFactory" connection factory which is available in the context |
| by default:</p> |
| <pre><code>java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory |
| connectionFactory.myConnectionFactory=tcp://localhost:61616?consumerWindowSize=0 |
| </code></pre><p>If the connection factory is directly instantiated, the consumer window |
| size is specified by <code>ActiveMQConnectionFactory.setConsumerWindowSize()</code> |
| method.</p> |
| <p>Please see the examples for an example which shows how to configure Apache ActiveMQ Artemis to |
| prevent consumer buffering when dealing with slow consumers.</p> |
| <h2 id="rate-limited-flow-control">Rate limited flow control</h2> |
| <p>It is also possible to control the <em>rate</em> at which a consumer can |
| consume messages. This is a form of throttling and can be used to make |
| sure that a consumer never consumes messages at a rate faster than the |
| rate specified.</p> |
| <p>The rate must be a positive integer to enable this functionality and is |
| the maximum desired message consumption rate specified in units of |
| messages per second. Setting this to <code>-1</code> disables rate limited flow |
| control. The default value is <code>-1</code>.</p> |
| <p>Please see <a href="examples.html">the examples chapter</a> for a working example of limiting consumer rate.</p> |
| <h3 id="using-core-api">Using Core API</h3> |
| <p>If the Apache ActiveMQ Artemis core API is being used the rate can be set via the |
| <code>ServerLocator.setConsumerMaxRate(int consumerMaxRate)</code> method or |
| alternatively via some of the <code>ClientSession.createConsumer()</code> methods.</p> |
| <h3 id="using-jms">Using JMS</h3> |
| <p>If JNDI is used to instantiate and look up the connection factory, the |
| max rate can be configured in the JNDI context environment, e.g. |
| <code>jndi.properties</code>. Here's a simple example using the "ConnectionFactory" |
| connection factory which is available in the context by default:</p> |
| <pre><code>java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory |
| java.naming.provider.url=tcp://localhost:61616?consumerMaxRate=10 |
| </code></pre><p>If the connection factory is directly instantiated, the max rate size |
| can be set via the <code>ActiveMQConnectionFactory.setConsumerMaxRate(int |
| consumerMaxRate)</code> method.</p> |
| <blockquote> |
| <p><strong>Note</strong></p> |
| <p>Rate limited flow control can be used in conjunction with window based |
| flow control. Rate limited flow control only effects how many messages |
| a client can consume in a second and not how many messages are in its |
| buffer. So if you had a slow rate limit and a high window based limit |
| the clients internal buffer would soon fill up with messages.</p> |
| </blockquote> |
| <p>Please see <a href="examples.html">the examples chapter</a> for an example which shows how to configure ActiveMQ Artemis to |
| prevent consumer buffering when dealing with slow consumers.</p> |
| <h2 id="producer-flow-control">Producer flow control</h2> |
| <p>Apache ActiveMQ Artemis also can limit the amount of data sent from a client to a |
| server to prevent the server being overwhelmed.</p> |
| <h3 id="window-based-flow-control">Window based flow control</h3> |
| <p>In a similar way to consumer window based flow control, Apache ActiveMQ Artemis |
| producers, by default, can only send messages to an address as long as |
| they have sufficient credits to do so. The amount of credits required to |
| send a message is given by the size of the message.</p> |
| <p>As producers run low on credits they request more from the server, when |
| the server sends them more credits they can send more messages.</p> |
| <p>The amount of credits a producer requests in one go is known as the |
| <em>window size</em>.</p> |
| <p>The window size therefore determines the amount of bytes that can be |
| in-flight at any one time before more need to be requested - this |
| prevents the remoting connection from getting overloaded.</p> |
| <h4 id="using-core-api">Using Core API</h4> |
| <p>If the Apache ActiveMQ Artemis core API is being used, window size can be set via the |
| <code>ServerLocator.setProducerWindowSize(int producerWindowSize)</code> method.</p> |
| <h4 id="using-jms">Using JMS</h4> |
| <p>If JNDI is used to instantiate and look up the connection factory, the |
| producer window size can be configured in the JNDI context environment, |
| e.g. <code>jndi.properties</code>. Here's a simple example using the |
| "ConnectionFactory" connection factory which is available in the context |
| by default:</p> |
| <pre><code>java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory |
| connectionFactory.myConnectionFactory=tcp://localhost:61616?producerWindowSize=10 |
| </code></pre><p>If the connection factory is directly instantiated, the producer window |
| size can be set via the |
| <code>ActiveMQConnectionFactory.setProducerWindowSize(int |
| producerWindowSize)</code> method.</p> |
| <h4 id="blocking-producer-window-based-flow-control">Blocking producer window based flow control</h4> |
| <p>Normally the server will always give the same number of credits as have |
| been requested. However, it is also possible to set a maximum size on |
| any address, and the server will never send more credits than could |
| cause the address's upper memory limit to be exceeded.</p> |
| <p>For example, if I have a JMS queue called "myqueue", I could set the |
| maximum memory size to 10MiB, and the the server will control the number |
| of credits sent to any producers which are sending any messages to |
| myqueue such that the total messages in the queue never exceeds 10MiB.</p> |
| <p>When the address gets full, producers will block on the client side |
| until more space frees up on the address, i.e. until messages are |
| consumed from the queue thus freeing up space for more messages to be |
| sent.</p> |
| <p>We call this blocking producer flow control, and it's an efficient way |
| to prevent the server running out of memory due to producers sending |
| more messages than can be handled at any time.</p> |
| <p>It is an alternative approach to paging, which does not block producers |
| but instead pages messages to storage.</p> |
| <p>To configure an address with a maximum size and tell the server that you |
| want to block producers for this address if it becomes full, you need to |
| define an AddressSettings (<a href="queue-attributes.html">Configuring Queues Via Address Settings</a>) block for the address and specify |
| <code>max-size-bytes</code> and <code>address-full-policy</code></p> |
| <p>The address block applies to all queues registered to that address. I.e. |
| the total memory for all queues bound to that address will not exceed |
| <code>max-size-bytes</code>. In the case of JMS topics this means the <em>total</em> |
| memory of all subscriptions in the topic won't exceed max-size-bytes.</p> |
| <p>Here's an example:</p> |
| <pre><code><address-settings> |
| <address-setting match="jms.queue.exampleQueue"> |
| <max-size-bytes>100000</max-size-bytes> |
| <address-full-policy>BLOCK</address-full-policy> |
| </address-setting> |
| </address-settings> |
| </code></pre><p>The above example would set the max size of the JMS queue "exampleQueue" |
| to be 100000 bytes and would block any producers sending to that address |
| to prevent that max size being exceeded.</p> |
| <p>Note the policy must be set to <code>BLOCK</code> to enable blocking producer flow |
| control.</p> |
| <blockquote> |
| <p><strong>Note</strong></p> |
| <p>Note that in the default configuration all addresses are set to block |
| producers after 10 MiB of message data is in the address. This means |
| you cannot send more than 10MiB of message data to an address without |
| it being consumed before the producers will be blocked. If you do not |
| want this behaviour increase the <code>max-size-bytes</code> parameter or change |
| the address full message policy.</p> |
| </blockquote> |
| <h3 id="rate-limited-flow-control">Rate limited flow control</h3> |
| <p>Apache ActiveMQ Artemis also allows the rate a producer can emit message to be limited, |
| in units of messages per second. By specifying such a rate, Apache ActiveMQ Artemis |
| will ensure that producer never produces messages at a rate higher than |
| that specified.</p> |
| <p>The rate must be a positive integer to enable this functionality and is |
| the maximum desired message consumption rate specified in units of |
| messages per second. Setting this to <code>-1</code> disables rate limited flow |
| control. The default value is <code>-1</code>.</p> |
| <p>Please see <a href="examples.html">the examples chapter</a> for a working example of limiting producer rate.</p> |
| <h4 id="using-core-api">Using Core API</h4> |
| <p>If the Apache ActiveMQ Artemis core API is being used the rate can be set via the |
| <code>ServerLocator.setProducerMaxRate(int producerMaxRate)</code> method or |
| alternatively via some of the <code>ClientSession.createProducer()</code> methods.</p> |
| <h4 id="using-jms">Using JMS</h4> |
| <p>If JNDI is used to instantiate and look up the connection factory, the |
| max rate size can be configured in the JNDI context environment, e.g. |
| <code>jndi.properties</code>. Here's a simple example using the "ConnectionFactory" |
| connection factory which is available in the context by default:</p> |
| <pre><code>java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory |
| connectionFactory.myConnectionFactory=tcp://localhost:61616?producerMaxRate=10 |
| </code></pre><p>If the connection factory is directly instantiated, the max rate size |
| can be set via the <code>ActiveMQConnectionFactory.setProducerMaxRate(int |
| producerMaxRate)</code> method.</p> |
| |
| |
| </section> |
| |
| |
| </div> |
| </div> |
| </div> |
| |
| |
| <a href="./transaction-config.html" class="navigation navigation-prev " aria-label="Previous page: Resource Manager Configuration"><i class="fa fa-angle-left"></i></a> |
| |
| |
| <a href="./send-guarantees.html" class="navigation navigation-next " aria-label="Next page: Guarantees of sends and commits"><i class="fa fa-angle-right"></i></a> |
| |
| </div> |
| </div> |
| |
| |
| <script src="gitbook/app.js"></script> |
| |
| <script> |
| require(["gitbook"], function(gitbook) { |
| var config = {"fontSettings":{"theme":null,"family":"sans","size":2}}; |
| gitbook.start(config); |
| }); |
| </script> |
| |
| |
| </body> |
| |
| </html> |