问题
What is the key difference between the following properties :
1)spring.rabbitmq.listener.direct.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
2)spring.rabbitmq.listener.simple.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
回答1:
With Spring AMQP 1.7.x and earlier (boot 1.5.x uses that version), there was only one listener container (SimpleMessageListenerContainer
).
Spring AMQP introduced a new listener container (the DirectMessageListenerContainer
); boot therefore, now, has 2 sets of properties, depending on which property you choose.
Actually, the help for the ...direct...
property is incorrect since that container does not support transaction size.
The prefetch
represents how many unacknowledged messages are allowed at each consumer. The simple container's transaction-size
represents how many messages are processed before a transaction is committed; it also represents how many messages are processed before an ack
is sent.
See the Spring AMQP documentation for more information about these properties.
回答2:
Looks like these properties were applicable in older version of spring boot When I used this documentation specific to the version https://docs.spring.io/spring-boot/docs/1.5.3.RELEASE/reference/html/common-application-properties.html then only this property is available : spring.rabbitmq.listener.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
来源:https://stackoverflow.com/questions/52434549/rabbit-spring-boot-properties