这是本节的多页打印视图。 点击此处打印.

返回本页常规视图.

ActiveMQ

1 - 服务端配置

Mapping to JMS

场景: java客户端消费使用openwire协议连接 go客户端使用amqp协议,生产消息,采用默认配置将在java消费端获取到ascii码, 是由于消息头不一致造成的 使用transport.transformer=jms,将amqp消息头和消息体的编码方式转换成jms的消息头和消息体 java的客户端就可以正确接收到消息了 http://activemq.apache.org/amqp.html

There are three basic conversion strategies that can be used with AMQP and inter-operating with the JMS API.

Strategy Description
native (Default) Wraps the bytes of the AMQP message into a JMS BytesMessage and maps the headers of the AMQP message to headers on the JMS message.
raw Wraps the bytes of the AMQP message into a JMS BytesMessage.
jms Maps headers of the AMQP message to JMS message headers and the body of the AMQP message to the JMS body.

Set the transformer transport option on the transportConnector to the desired mapping strategy. For example, to inter-operate with JMS at the payload level, set the transformer option to jms:

<transportConnector name="amqp" uri="amqp://localhost:5672?transport.transformer=jms"/>

修改使用账号密码:

当前目录下,找到activemq.xml。滑到最底下 在节点前添加以下代码:

        ...
        <!-- destroy the spring context on shutdown to stop jetty -->
        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>
        <!-- 添加访问ActiveMQ的账号密码 -->
        <plugins>
            <simpleAuthenticationPlugin>
                <users>
                    <authenticationUser username="elink" password="elink888" groups="users,admins"/>
                </users>
            </simpleAuthenticationPlugin>
        </plugins>
    </broker>