ActiveMQ在分布式系统作用和安装

来源:互联网 发布:淘宝开服装店教程 编辑:程序博客网 时间:2024/05/22 02:56

场景:支付场景
1.支付成功之后系统进行成本计算要收商户多少钱
2.商户的模块得进行计费处理 
3.更新用户和商户的余额
4.进行风控归档
5.通知商户发货等等

http://activemq.apache.org/
conf/jetty.xml
一个是消息通讯的端口(默认为 61616) conf/activemq.xml 找到61616修改就行了
一个是管理控制台端口(默认为 8161)可在 conf/jetty.xml 中修改,如下:
<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
  <!-- the default port number for the web console -->
 <property name="host" value="0.0.0.0"/>
  <property name="port" value="8161"/>
</bean>

安全配置(消息安全)
ActiveMQ 如果不加入安全机制的话,任何人只要知道消息服务的具体地址(包括 ip,端口,消息地址
[ 队列或者主题地址 ] , ) ,都可以肆无忌惮的发送、接收消息。 关于 ActiveMQ 安装配置
http://activemq.apache.org/security.html
添加activemq访问的权限 activemq-01/conf/activemq.xml
broker节点里面加
<plugins>
    <simpleAuthenticationPlugin>
        <users>
            <authenticationUser username="zhouhao" password="zhouhao" groups="users,admins"/>
        </users>
       </simpleAuthenticationPlugin>
</plugins>
定义了一个用户用户名为zhouhao 密码是zhouhao 角色是users admins
设置admin用户的用户名和密码 activemq-01/conf/jetty.xml
<bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">
    <property name="name" value="BASIC" />
    <property name="roles" value="admin" />
    <property name="authenticate" value="true" />
</bean>
确保 authenticate 为true 默认是true
控制台的登录用户名密码保存在 conf/jetty-realm.properties 文件中,内容如下:
$ vi /home/wusc/activemq-01/conf/jetty-realm.properties
# Defines users that can access the web (console, demo, etc.)
# username: password [,rolename ...]
admin: zhouhao, admin
注意:用户名和密码的格式是
用户名 : 密码 ,角色名