【ActiveMQ】ActiveMQ “illegal character in hostname“解决

由于主机名redhat6.8中的点.导致URISyntaxException,通过修改activemq.xml中的0.0.0.0为127.0.0.1,使ActiveMQ成功启动。若需跨主机通信,建议修改主机名。
摘要由CSDN通过智能技术生成

系统版本

        Redhat 6.8

ActiveMQ版本

        5.14.5

报错信息

2023-05-22 16:19:00,271 | WARN  | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.net.URISyntaxException: Illegal character in hostname at index 13: ws://redhat6.8:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600 | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main

Illegal character in hostname at index 13: ws://redhat6.8

从上面的报错信息,第13个字符刚好就是主机名里面包含的那个点“."。

问题原因

        目前根据网上查询的资料(连接符-、下划线_,在ActiveMQ的主机名校验中都是非法的),以及错误信息来判断,最大的可能是系统使用的主机名redhat6.8不符合ActiveMQ,也就是ActiveMQ 5.14.5版本不允许主机名存在点"."这种特殊字符存在,当然这个目前还没有查询到相关的说明文档(后续如果查询到,会及时补充完善)

解决方法

        将ActiveMQ的配置文件activemq.xml里面的0.0.0.0配置修改为127.0.0.1或者localhost即可解决,实测ActiveMQ即可成功启动。因为是生产环境,不能随意重启系统,而Redhat 6.8系统修改主机名需要重启系统(坑爹!Redhat 7.x+就不需要重启)。

注意:如果存在跨主机调用ActiveMQ的,建议还是修改主机名,如果配置修改为localhost或者127.0.0.1本地回环地址(即私网地址),会导致跨服务器无法调用。我这边调用ActiveMQ的客户端和ActiveMQ部署在同一台服务器,所以可以做如下修改。

修改前:

<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>

修改后:

<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://127.0.0.1:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://127.0.0.1:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://127.0.0.1:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://127.0.0.1:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://127.0.0.1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>

附:

Redhat / CentOS 7.x+修改静态主机名的命令:

hostnamectl set-hostname --static vm-fdgbj1337
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cnskylee

技术分享我是认真的,期待您打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值