文档库 最新最全的文档下载
当前位置:文档库 › active mq的基本配置

active mq的基本配置

active mq的基本配置
active mq的基本配置

1.ActiveMQ包含了很多features(详见https://www.wendangku.net/doc/ef16298674.html,/features.html ),

不同的需求,不同的环境,需要不同的features,当然需要不同的配置。在这里我只写了最基本的配置,算是抛砖了,希望引出更多关于ActiveMQ的高级配置。

假设已经正确安装ActiveMQ5.0,同时及其IP地址为192.168.1.148,具体使用时可以改为自己的IP。下面讲解的配置实现的features如下:

1. 客户端可以通过tcp://19

2.168.1.148连接ActiveMQ。

2. 消息持久化保存,重启服务器不会丢失消息。

3. 可以通过http://192.168.1.148:8161/admin监控ActiveMQ服务器

配置

ActiveMQ默认使用的是XML格式配置,从4.0版本开始用MBean的方式实现XML配置,配置文件在${activemq.home}/conf目录下,文件名为activemq.xml。最新的默认配置见

https://www.wendangku.net/doc/ef16298674.html,/repos/asf/activemq/trunk/assembly/src/release/conf/activemq.xml 。下面为本篇文章使用的配置,及重要部分的解释。

Xml代码

1.

2. xmlns="https://www.wendangku.net/doc/ef16298674.html,/schema/beans"

3. xmlns:amq="http://activemq.org/config/1.0"

4. xmlns:xsi="https://www.wendangku.net/doc/ef16298674.html,/2001/XMLSchema-instance"

xsi:schemaLocation="https://www.wendangku.net/doc/ef16298674.html,/schema/beans https://www.wendangku.net/doc/ef16298674.html,/schema/beans/spring-beans-2.0.xsd

5. http://activemq.org/config/1.0 http://activemqhttps://www.wendangku.net/doc/ef16298674.html,/schema/

class=hilite1>activemq-core.xsd

6. http://activemqhttps://www.wendangku.net/doc/ef16298674.html,/camel/schema/spring>

7.

8.

9.

10.

11.

12. xmlns="http://activemq.org/config/1.0" brokerName="192.168.1.148"

persistent ="true" dataDirectory="${activemq.base}/data" useShutdownHook="false">

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. xmlns="http://activemq.org/config/1.0"/>

52.

53.

54. xmlns="https://www.wendangku.net/doc/ef16298674.html,/schemas/jetty/1.0">

55.

56.

57.

58.

59.

60.

logUrlOnStart="true" />

61.

62.

63.

64.

1.

2. xmlns="https://www.wendangku.net/doc/ef16298674.html,/schema/beans"

3. xmlns:amq="http://activemq.org/config/1.0"

4. xmlns:xsi="https://www.wendangku.net/doc/ef16298674.html,/2001/XMLSchema-instance"

xsi:schemaLocation="https://www.wendangku.net/doc/ef16298674.html,/schema/beans https://www.wendangku.net/doc/ef16298674.html,/schema/beans/spring-beans-2.0.xsd

5. http://activemq.org/config/1.0 http://activemqhttps://www.wendangku.net/doc/ef16298674.html,/schema/activemq-core.xsd

6. http://activemqhttps://www.wendangku.net/doc/ef16298674.html,/camel/schema/spring>

7.

8.

9.

10.

11.

12. xmlns="http://activemq.org/config/1.0" brokerName="192.168.1.148" persistent ="true" dataDirectory="${activemq.base}/data" useShutdownHook="false">

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. xmlns="http://activemq.org/config/1.0"/>

52.

53.

54. xmlns="https://www.wendangku.net/doc/ef16298674.html,/schemas/jetty/1.0">

55.

56.

57.

58.

59.

60.

logUrlOnStart="true" />

61.

logUrlOnStart="true" />

62.

63.

64.

注释

关于XML配置中元素的具体信息可以参考https://www.wendangku.net/doc/ef16298674.html,/xbean-xml-reference-50.html 下面介绍本篇配置使用的一些重要元素。

DispathPolicy

ActiveMQ支持3中不同的分发策略(避免翻译了以后误解,这里用原文):

1. :Simple dispatch policy that sends a message to every subscription that matches the message.

2. :Simple dispatch policy that sends a message to every subscription that matches the message.

3. :Dispatch policy that causes every subscription to see messages in the same order.

SubscriptionRecoveryPolicy

ActiveMQ支持6种恢复策略,可以自行选择使用不同的策略

1. :keep a fixed count of last messages.

2. :keep a fixed amount of memory available in RAM for message history which is evicted in time

order.

3. :only keep the last message.

4. :disable recovery of messages.

5. :perform a user specific query mechanism to load any messages they may have missed.

6. :keep a timed buffer of messages around in memory and use that to recover new subscriptions.

PersistenceAdapter

https://www.wendangku.net/doc/ef16298674.html,/persistence 讲解了关于persistence的信息。ActiveMQ5.0使用AMQ Message Store 持久化消息,这种方式提供了很好的性能(The AMQ Message Store is an embeddable transactional message storage solution that is extremely fast and reliable.)默认使用该存储方式即可,如果想使用JDBC来存储,可以查找文档配置。

Summary

本篇文章只提供了基本配置信息。如果需要更多的文章,可以查看ActiveMQ的文档。

讲了安装和简单的配置,下一篇将介绍和Sping的整合,以及多个queue,多个topic,多个producer,多个consumer的配置,使用。

原贴地址:https://www.wendangku.net/doc/ef16298674.html,/blog/239885

2.xmlns="https://www.wendangku.net/doc/ef16298674.html,/schema/beans"

3.xmlns:amq="https://www.wendangku.net/doc/ef16298674.html,/config/1.0"

4.xmlns:xsi="https://www.wendangku.net/doc/ef16298674.html,/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.

org/schema/beans https://www.wendangku.net/doc/ef16298674.html,/schema/beans/spring-beans-2.0.xsd

5. https://www.wendangku.net/doc/ef16298674.html,/config/1.0 https://www.wendangku.net/doc/ef16298674.html,/schema/activemq-core.xsd

6. https://www.wendangku.net/doc/ef16298674.html,/camel/schema/spring>

7.

8.

9.

10.

11.

12.

tory="${activemq.base}/data"useShutdownHook="false">

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.

activemq持久化配置,设置为主从模式(带复制的主从模式,应用mysql数据库)

2009年06月17日星期三 10:41

别的不用多看罗,配置文件如下

xmlns="https://www.wendangku.net/doc/ef16298674.html,/schema/beans"

xmlns:amq="https://www.wendangku.net/doc/ef16298674.html,/schema/core"

xmlns:xsi="https://www.wendangku.net/doc/ef16298674.html,/2001/XMLSchema-instance"

xsi:schemaLocation="https://www.wendangku.net/doc/ef16298674.html,/schema/beans

https://www.wendangku.net/doc/ef16298674.html,/schema/beans/spring-beans-2.0.xsd

https://www.wendangku.net/doc/ef16298674.html,/schema/core https://www.wendangku.net/doc/ef16298674.html,/schema/core/activemq-core.xsd

https://www.wendangku.net/doc/ef16298674.html,/camel/schema/spring

https://www.wendangku.net/doc/ef16298674.html,/camel/schema/spring/camel-spring.xsd">

file:///${activemq.base}/conf/credentials.properties

trustStore="file:${activemq.base}/conf/broker.ts" trustStorePassword="password"/>

discoveryUri="multicast://default"/>

**

** https://www.wendangku.net/doc/ef16298674.html,/enterprise-integration-patterns.html

-->

org.foo.bar

logUrlOnStart="true"/>

logUrlOnStart="true"/>

-->

已主从模式运行(192.168.2.137为主,192.168.2.136为从),还需在客户端上运行如下命令:

java.naming.provider.url=failover:(tcp://192.168.2.137:61616,tcp://192.168.2.136:61616)?

randomize=false #没有这一行的话,就变成了networks of brokers initialReconnectDelay=10 #这里的单位是毫秒

activemq的目录里有个example,只要简单配置一下build.xml,即可测试activemq的message的consume和query

64.

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

https://www.wendangku.net/doc/ef16298674.html,/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.

-->

-

-

xmlns:amq="https://www.wendangku.net/doc/ef16298674.html,/schema/core" xmlns:xsi="https://www.wendangku.net/doc/ef16298674.html,/2001/XMLSchema-instance"

xsi:schemaLocation="https://www.wendangku.net/doc/ef16298674.html,/schema/beans

https://www.wendangku.net/doc/ef16298674.html,/schema/beans/spring-beans-2.0.xsd https://www.wendangku.net/doc/ef16298674.html,/schema/core https://www.wendangku.net/doc/ef16298674.html,/schema/core/activemq-core.xsd">

-

-

-

file:${activemq.base}/conf/credentials.properties

-

-

dataDirectory="${activemq.base}/data" destroyApplicationContextOnStop="true">

-

-

-

-

-

-

-

-

-->

-

-

-

-

-

-

-

-

Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details

-->

-

相关文档