我有一个可怕的夜晚试图找出RabbitMQ和SpringXD的情况,遗憾的是没有成功。
问题: SpringXD反复关闭RabbitMQ连接, 或报告与频道缓存大小相关的警告。
来自SpringXD日志的片段(在流初始化/自动装配期间):
2016-05-03T07:42:43+0200 1.3.0.RELEASE WARN
DeploymentsPathChildrenCache-0 listener.SimpleMessageListenerContainer
- CachingConnectionFactory's channelCacheSize can not be less than the
number of concurrentConsumers so it was reset to match: 4
...
2016-05-03T07:54:17+0200 1.3.0.RELEASE ERROR AMQP Connection
192.168.120.125:5672 connection.CachingConnectionFactory - Channel shutdown: connection error
2016-05-03T17:38:58+0200 1.3.0.RELEASE ERROR AMQP Connection
192.168.120.125:5672 connection.CachingConnectionFactory - Channel shutdown: connection error; protocol method:
method<connection.close>(reply-code=504, reply-text=CHANNEL_ERROR -
second 'channel.open' seen, class-id=20, method-id=10)
来自RabbitMQ日志的片段:
=WARNING REPORT==== 3-May-2016::08:08:09 === closing AMQP connection <0.22276.61> (192.168.120.125:59350 -> 192.168.120.125:5672): client
unexpectedly closed TCP connection
=ERROR REPORT==== 3-May-2016::08:08:11 === closing AMQP connection 0.15409.61> (192.168.120.125:58527 -> 192.168.120.125:5672):
{writer,send_failed,{error,closed}}
状态阻塞错误很少
=ERROR REPORT==== 3-May-2016::17:38:58 === Error on AMQP connection <0.20542.25> (192.168.120.125:59421 -> 192.168.120.125:5672, vhost:
'/', user: 'xd', state: blocked), channel 7: operation channel.open
caused a connection exception channel_error: "second 'channel.open'
seen"
我的设置(6个节点)
- springxd 1.3.0 distributed (zookeeper)
- RabbitMQ 3.6.0, Erlang R16B03-1 cluster
ackMode: AUTO ## or NONE
autoBindDLQ: false
backOffInitialInterval: 1000
backOffMaxInterval: 10000
backOffMultiplier: 2.0
batchBufferLimit: 10000
batchingEnabled: false
batchSize: 200
batchTimeout: 5000
compress: false
concurrency: 4
deliveryMode: NON_PERSISTENT ## or PERSISTENT
durableSubscription: false
maxAttempts: 10
maxConcurrency: 10
prefix: xdbus.
prefetch: 1000
replyHeaderPatterns: STANDARD_REPLY_HEADERS,*
republishToDLQ: false
requestHeaderPatterns: STANDARD_REQUEST_HEADERS,*
requeue: true
transacted: false
txSize: 1000
弹簧: RabbitMQ的:
addresses:
priv1:5672,priv2:5672,priv3:5672,
priv4:5672,priv5:5672,priv6:5672
adminAddresses:
http://priv1:15672, http://priv2:15672, http://priv3:15672, http://priv4:15672, http://priv5:15672,http://priv6:15672
nodes:
rabbit@priv1,rabbit@priv2,rabbit@priv3,
rabbit@priv4,rabbit@priv5,rabbit@priv6
username: xd
password: xxxx
virtual_host: /
useSSL: false
ha-xdbus政策:
- ^xdbus\. all
- ha-mode: exactly
- ha-params: 2
- queue-master-locator: min-masters
Rabbit conf
[
{rabbit,
[
{tcp_listeners, [5672]},
{queue_master_locator, "min-masters"}
]
}
].
当ackMode为NONE时,会发生以下情况:
最终消费者的数量降至零,我有一个不能从该状态恢复的僵尸流,这反过来导致不必要的排队。
当ackMode为AUTO时,会发生以下情况:
有些消息永远不会消失。
SpringXD流和持久队列
Rabbit模块用作源或接收器,没有自定义自动装配。
典型的流定义如下:
摄入:
event_generator | rabbit --mappedRequestHeaders=XDRoutingKey --routingKey='headers[''XDRoutingKey'']'
加工/水槽:
rabbit --queues='xdbus.INQUEUE-A' | ENRICHMENT-PROCESSOR-A | elastic-sink
rabbit --queues='xdbus.INQUEUE-B' | ENRICHMENT-PROCESSOR-B | elastic-sink
xdbus.INQUEUE-xxx是从Rabbit管理GUI手动创建的。 (耐久)
GLOBAL统计数据(来自RabbitMQ管理员)
最后:
如果有人能够回答配置的错误,我将不胜感激(我非常确定网络运行良好,因此没有网络问题,并且没有与最大打开文件限制相关的问题)。
信息速率从2K /秒到最大30k /秒不等,这是相对较小的负载。
谢谢!
伊万
答案 0 :(得分:2)
我们看到了一些similar instability when churning channels at a high rate。
解决方法是增加频道缓存大小以避免高速搅拌;目前还不清楚不稳定性在哪里,但我不相信它是在春季AMQP。
然而,一个问题是XD不会将channelCacheSize
公开为属性。
上面链接的答案有一个解决办法,即通过替换总线配置XML来添加属性。增加缓存大小解决了用户的问题。
我们有open JIRA issue to expose the property但尚未实施。
我看到你最初将此贴出来作为该问题的“答案”。
有人可以更具体一点,并解释一下究竟应该安装rabbit-bus.xml的原因以及为什么会发生这种情况。
正如它所说,你需要把它放在xd config目录下:
xd/config/META-INF/spring-xd/bus/rabbit-bus.xml
。
修改强>
使用总线扩展机制的技术......
$ cat xd/config/META-INF/spring-xd/bus/ext/cf.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="rabbitConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg ref="rabbitFactory" />
<property name="addresses" value="${spring.rabbitmq.addresses}" />
<property name="username" value="${spring.rabbitmq.username}" />
<property name="password" value="${spring.rabbitmq.password}" />
<property name="virtualHost" value="${spring.rabbitmq.virtual_host}" />
<property name="channelCacheSize" value="${spring.rabbitmq.channelCacheSize:100}" />
</bean>
</beans>
编辑:测试结果
预先填充的队列foo
,包含100万条消息。
concurrency: 10
prefetch: 1000
txSize: 1000
xd:>stream create foo --definition "rin:rabbit --concurrency=10 --maxConcurrency=10 --prefetch=1000 --txSize=1000 | t1:transform | t2:transform | rout:rabbit --routingKey='''bar'''" --deploy
Created and deployed new stream 'foo'
因此,使用此配置,我们最终会有40位消费者。
我从未在公交车上看过超过29个出版频道,有10个出版商用于接收。
在不到5分钟内(通过foo
,bar
和xdbus.foo.0
)发布了400万条消息,从xdbus.foo.1
转移到xdbus.foo.2
。< / p>
没有错误 - 但我的笔记本电脑需要冷静下来:D