小菜一只,上面安排优化ActiveMQ的配置。。。我到处瞎鼓捣,现在发送者的速度贼快达到 5000条/s
,
可是消费者的速度太慢了,而且在后台查看,1000条消息只被消费了94条。我勒个去啊,那么多被积压啊。。。我把导出一个jar包当做消费者运行,这样就不会积压,但是速度是 15条/s 这大坑...
我看了网上许多资料,说采用两个连接池来区分。。
求大神给个思想怎么优化消费者的速度,下面上配置:
ActiveMQ.xml
就不发到中间件了,我估计这儿的人多点。。。没多少分了,求大神解惑~小弟感激不尽。
![](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/1.gif)
可是消费者的速度太慢了,而且在后台查看,1000条消息只被消费了94条。我勒个去啊,那么多被积压啊。。。我把导出一个jar包当做消费者运行,这样就不会积压,但是速度是 15条/s 这大坑...
![](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/11.gif)
我看了网上许多资料,说采用两个连接池来区分。。
求大神给个思想怎么优化消费者的速度,下面上配置:
ActiveMQ.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
<bean id=
"jmsFactory"
class
=
"org.apache.activemq.ActiveMQConnectionFactory"
>
<property name=
"brokerURL"
value=
"${jms.brokerURL}"
/>
<property name=
"userName"
value=
"${jms.username}"
/>
<property name=
"password"
value=
"${jms.password}"
/>
<property name=
"dispatchAsync"
value=
"true"
/>
<property name=
"useAsyncSend"
value=
"true"
/>
</bean>
<!-- 设置发送连接池,提高性能 -->
<bean id=
"JmsSenderFactory"
class
=
"org.apache.activemq.pool.PooledConnectionFactory"
destroy-method=
"stop"
>
<property name=
"connectionFactory"
ref=
"jmsFactory"
/>
<property name=
"maxConnections"
value=
"100"
></property>
</bean>
<!-- 设置接收连接池,提高性能 -->
<bean id=
"JmsReveiverFactory"
class
=
"org.apache.activemq.pool.PooledConnectionFactory"
>
<property name=
"connectionFactory"
ref=
"jmsFactory"
/>
<property name=
"maxConnections"
value=
"100"
></property>
</bean>
<!-- Spring JMS Template -->
<bean id=
"jmsTemplate"
class
=
"org.springframework.jms.core.JmsTemplate"
>
<property name=
"connectionFactory"
ref=
"JmsSenderFactory"
/>
<property name=
"defaultDestination"
ref=
"destination"
/>
<!-- 区别它采用的模式:
false
是p2p;
true
是订阅 -->
<property name=
"pubSubDomain"
value=
"false"
/>
<property name=
"messageConverter"
>
<bean
class
=
"org.springframework.jms.support.converter.SimpleMessageConverter"
/>
</property>
</bean>
<!-- Spring JMS Template -->
<bean id=
"jmsTemplate2"
class
=
"org.springframework.jms.core.JmsTemplate"
>
<property name=
"connectionFactory"
ref=
"JmsReveiverFactory"
/>
<property name=
"defaultDestination"
ref=
"destination"
/>
<!-- 区别它采用的模式:
false
是p2p;
true
是订阅 -->
<property name=
"pubSubDomain"
value=
"false"
/>
<property name=
"messageConverter"
>
<bean
class
=
"org.springframework.jms.support.converter.SimpleMessageConverter"
/>
</property>
</bean>
<!-- 发送消息的目的地(一个队列) -->
<bean id=
"destination"
class
=
"org.apache.activemq.command.ActiveMQQueue"
>
<!-- 设置消息队列的名字 -->
<constructor-arg index=
"0"
value=
"${jms.queueName}"
/>
</bean>
<!-- 消息监听 -->
<bean id=
"listenerContainer"
class
=
"org.springframework.jms.listener.DefaultMessageListenerContainer"
>
<property name=
"concurrentConsumers"
value=
"${jms.concurrentConsumers}"
/>
<property name=
"connectionFactory"
ref=
"JmsReveiverFactory"
/>
<property name=
"destinationName"
value=
"${jms.queueName}"
/>
<property name=
"messageListener"
ref=
"messageConsumer"
/>
<property name=
"sessionTransacted"
value=
"true"
/>
<property name=
"pubSubNoLocal"
value=
"true"
></property>
</bean>
<!-- 消息消费者 -->
<bean id=
"messageConsumer"
class
=
"com.voole.jms.MessageConsumer"
>
<property name=
"jmsTemplate2"
ref=
"jmsTemplate2"
></property>
</bean>
<!-- 消息生产 -->
<bean id=
"messageProducer"
class
=
"com.voole.jms.MessageProducer"
>
<property name=
"jmsTemplate"
ref=
"jmsTemplate"
></property>
</bean>
</beans>
|
就不发到中间件了,我估计这儿的人多点。。。没多少分了,求大神解惑~小弟感激不尽。
![](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/11.gif)