【问题标题】:Setup of spring-boot application with JMS, Artemis and JGroups with jdbc_ping使用 jdbc_ping 使用 JMS、Artemis 和 JGroups 设置 spring-boot 应用程序
【发布时间】:2020-06-02 06:18:58
【问题描述】:

我已经在我的计算机上本地设置了一个 Artemis HA-Custer 示例,以了解它的基本工作原理。现在我想准备将其推送到 Kubernetes 集群中。因此,我想更改代理节点的初始成员发现方式,因此我也可以在云中使用它。我想将 JMS 和 JGroups 与“jdbc_ping”一起使用。其实我不确定,如果我做得对,所以也许你可以告诉我。

到目前为止,经纪人已成功地将他们的信息放入 db-table 中并且显然已连接。当我从我的 java 应用程序中尝试以下 connectionFactory 时,它启动时没有错误并与代理连接。但在某些方面,我不确定它是否正确运行。

@Bean
public ConnectionFactory connectionFactory() {
    TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());

    ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, transportConfiguration);
    return cf;
}

所以现在唯一的问题是,如何正确设置 connectionFactory 以使用 JGroups。

更新:

INFO 24528 --- [enerContainer-1] o.s.j.l.DefaultMessageListenerContainer  : JMS message listener invoker needs to establish shared Connection

ERROR 24528 --- [enerContainer-1] o.s.j.l.DefaultMessageListenerContainer  : Could not refresh JMS Connection for destination 'TestA' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: Failed to create session factory; nested exception is ActiveMQInternalErrorException[errorType=INTERNAL_ERROR message=AMQ219004: Failed to initialise session factory]

【问题讨论】:

    标签: spring-boot spring-jms activemq-artemis jgroups


    【解决方案1】:

    ActiveMQ Artemis documentation 涵盖了这个:

    最后,支持jgroups 方案,它为服务器发现提供了udp 方案的替代方案。 URL 模式可以是jgroups://channelName?file=jgroups-xml-conf-filename,其中jgroups-xml-conf-filename 是指类路径上包含JGroups 配置的XML 文件,也可以是jgroups://channelName?properties=some-jgroups-properties。在这两种情况下,channelName 是给创建的 jgroups 通道的名称。

    在您的代码中,您可以执行以下操作:

    @Bean
    public ConnectionFactory connectionFactory() {
        return new ActiveMQConnectionFactory("jgroups://channelName?file=jgroups-xml-conf-filename");
    }
    

    在您的情况下,客户端将需要访问代理正在使用的同一数据库,以便使用该信息进行发现。

    【讨论】:

    • 我在启动应用程序后收到以下错误消息:"DefaultMessageListenerContainer : JMS message listener invoker needs to establish shared Connection" 和 "Could not refresh JMS Connection for destination 'TestB' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: Failed to create session factory; nested exception is ActiveMQInternalErrorException[errorType=INTERNAL_ERROR message=AMQ219004: Failed to initialise session factory]"
    • 我对这篇文章的看法是,它的优势可能是,你可以更容易地适应它,例如你想做一个 jgroups kube_ping 而不是 jdbc_ping。所以你不需要更改类路径中的文件。但我不确定这是否是一种适当的连接方式。
    • 是否有带有该错误消息的堆栈跟踪?您使用的是哪个版本的 ActiveMQ Artemis?你确定你的 JGroups 配置文件在类路径上吗?
    • 我使用的是 apache-artemis-2.11.0 版本。没有堆栈跟踪,只有 INFO 和 ERROR 消息。我将在我的帖子中再次将它们用于可视化。实际上配置文件在类路径上,我什至在文件夹中移动了一点以检查是否有区别,但事实并非如此。此外,如果我从项目中删除它,也会有相同的日志。也许它无法处理 url 的“jgroups://”部分?
    猜你喜欢
    • 2016-01-21
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    • 2020-08-31
    • 2015-11-21
    • 2013-11-04
    • 2020-01-16
    • 2016-08-10
    相关资源
    最近更新 更多