2015-01-05 07:45:36 -05:00
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
2014-10-31 06:20:28 -04:00
< html >
< head >
2015-05-13 06:12:07 -04:00
< title > ActiveMQ Artemis JMS Message Consumer Rate Limiting< / title >
2015-08-10 10:41:52 -04:00
< link rel = "stylesheet" type = "text/css" href = "../../../common/common.css" / >
< link rel = "stylesheet" type = "text/css" href = "../../../common/prettify.css" / >
< script type = "text/javascript" src = "../../../common/prettify.js" > < / script >
2014-10-31 06:20:28 -04:00
< / head >
< body onload = "prettyPrint()" >
< h1 > JMS Message Consumer Rate Limiting< / h1 >
2015-08-05 15:33:20 -04:00
< pre > To run the example, simply type < b > mvn verify< / b > from this directory, < br > or < b > mvn -PnoServer verify< / b > if you want to start and create the server manually.< / pre >
2014-10-31 06:20:28 -04:00
2015-05-13 06:12:07 -04:00
< p > With ActiveMQ Artemis you can specify a maximum consume rate at which a JMS MessageConsumer will consume messages.
2015-07-06 15:42:36 -04:00
This can be specified when creating or configuring the connection factory. See < code > jndi.properties< / code > .< / p >
2015-05-13 06:12:07 -04:00
< p > If this value is specified then ActiveMQ Artemis will ensure that messages are never consumed at a rate higher than
2015-07-06 15:42:36 -04:00
the specified rate. This is a form of consumer < i > throttling< / i > .< / p >
2014-10-31 06:20:28 -04:00
< h2 > Example step-by-step< / h2 >
2015-07-06 15:42:36 -04:00
< p > In this example we specify a < code > consumer-max-rate< / code > of < code > 10< / code > messages per second in the < code > jndi.properties< / code >
file when configuring the connection factory:< / p >
2014-10-31 06:20:28 -04:00
< pre class = "prettyprint" >
< code >
2015-07-06 15:42:36 -04:00
connectionFactory.ConnectionFactory=tcp://localhost:61616?consumerMaxRate=10
2014-10-31 06:20:28 -04:00
< / code >
< / pre >
< p > We then simply consume as many messages as we can in 10 seconds and note how many messages are actually consumed.< / p >
< p > We note that the number of messages consumed per second never exceeds the specified value of < code > 10< / code > messages per second.< / p >
< / body >
2015-01-05 07:45:36 -05:00
< / html >