此内容没有您所选择的语言版本。
8.2. Queue Sizing
8.2.1. Controlling Queue Size
复制链接链接已复制到粘贴板!
				Controlling the size of queues is an important part of performance management in a messaging system.
			
				When queues are created, you can specify a maximum queue size (
qpid.max_size) and maximum message count (qpid.max_count) for the queue.
			qpid.max_size is specified in bytes. qpid.max_count is specified as the number of messages.
			
				The following 
qpid-config creates a queue with a maximum size in memory of 200MB, and a maximum number of 5000 messages:
			qpid-config add queue my-queue --max-queue-size=204800000 --max-queue-count 5000
qpid-config add queue my-queue --max-queue-size=204800000 --max-queue-count 5000
				In an application, the 
qpid.max_count and qpid.max_size directives go inside the arguments of the x-declare of the node. For example, the following address will create the queue as the qpid-config command above:
			- Python
- tx = ssn.sender("my-queue; {create: always, node: {x-declare: {'auto-delete': True, arguments:{'qpid.max_count': 5000, 'qpid.max_size': 204800000}}}}")- tx = ssn.sender("my-queue; {create: always, node: {x-declare: {'auto-delete': True, arguments:{'qpid.max_count': 5000, 'qpid.max_size': 204800000}}}}")- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
				Note that the 
qpid.max_count attribute will only be applied if the queue does not exist when this code is executed.
			Behavior when limits are reached: 
qpid.policy_type
					The behavior when a queue reaches these limits is configurable. By default, on non-durable queues the behavior is reject: further attempts to send to the queue result in a TargetCapacityExceeded exception being thrown at the sender.
				
				The configurable behavior is set using the 
qpid.policy_type option. The possible values are:
			- reject
- Message publishers throw an exceptionTargetCapacityExceeded. This is the default behavior for non-durablequeues.
- ring
- The oldest messages are removed to make room for newer messages.
				The following example 
qpid-config command sets the limit policy to ring:
			qpid-config add queue my-queue --max-queue-size=204800 --max-queue-count 5000 --limit-policy ring
qpid-config add queue my-queue --max-queue-size=204800 --max-queue-count 5000 --limit-policy ring
				The same thing is achieved in an application like so:
			
- Python
- tx = ssn.sender("my-queue; {create: always, node: {x-declare: {'auto-delete': True, arguments:{'qpid.max_count': 5000, 'qpid.max_size': 204800, 'qpid.policy_type': 'ring'}}}}")- tx = ssn.sender("my-queue; {create: always, node: {x-declare: {'auto-delete': True, arguments:{'qpid.max_count': 5000, 'qpid.max_size': 204800, 'qpid.policy_type': 'ring'}}}}")- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
See Also: