如何在ActiveMQ Artemis群集中启用REST

ZiggyStardust:

我们正在尝试按照ActiveMQ Artemis文档说明设置REST接口我们已经使其可以在2.10.1和2.9.0版本中工作,但只能在独立模式下使用。集群2.9.0是我们当前的生产环境,因此我们正在尝试设置REST接口。

我们有一个使用基于文件的日志的群集主动/被动解决方案。我们的主动/被动解决方案前面有一个Netscaler。我们发现了这个错误报告,这是我们在系统中看到的。此错误已在2.3.0中解决,因此我想我们应该运行TCP而不是in-vm?我们该如何设置?

为我们工作的StdAlone配置:

<web bind="http://lxappqmanv01:8161" path="web">
   <app url="activemq-branding" war="activemq-branding.war"/>
   <app url="artemis-plugin" war="artemis-plugin.war"/>
   <app url="console" war="console.war"/>
   <app url="rest" war="artemis-rest-1.0-SNAPSHOT.war"/>
</web>

在broker.xml中,我们添加了:

<acceptor name="in-vm">vm://0</acceptor>

在rest-messaging.xml中

<rest-messaging>
   <server-in-vm-id>0</server-in-vm-id>
   <use-link-headers>false</use-link-headers>
   <default-durable-send>false</default-durable-send>
   <dups-ok>true</dups-ok>
   <topic-push-store-dir>topic-push-store</topic-push-store-dir>
   <queue-push-store-dir>queue-push-store</queue-push-store-dir>
   <producer-time-to-live>0</producer-time-to-live>
   <producer-session-pool-size>10</producer-session-pool-size>
   <session-timeout-task-interval>1</session-timeout-task-interval>
   <consumer-session-timeout-seconds>300</consumer-session-timeout-seconds>
   <consumer-window-size>-1</consumer-window-size>
   <url>vm://0</url>
</rest-messaging>

在web.xml中

<web-app>
   <listener>
      <listener-class>com.myapp.artemis.MyResteasyBootstrap</listener-class>
   </listener>

   <listener>

<listener-class>org.apache.activemq.artemis.rest.integration.RestMessagingBootstrapListener</listener-class>
   </listener>

   <filter>
      <filter-name>Rest-Messaging</filter-name>

<filter-class>org.jboss.resteasy.plugins.server.servlet.FilterDispatcher</filter-class>
   </filter>

   <filter-mapping>
      <filter-name>Rest-Messaging</filter-name>
      <url-pattern>/*</url-pattern>
   </filter-mapping>
</web-app>

这可以正常工作(包括下面的类时):

package com.myapp.artemis;

import javax.servlet.ServletContextEvent;
import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap;
import org.jboss.resteasy.spi.Registry;


public class MyResteasyBootstrap extends ResteasyBootstrap {
    @Override
    public void contextInitialized(ServletContextEvent event)
    {
        super.contextInitialized(event);
        event.getServletContext().setAttribute(Registry.class.getName(), deployment.getRegistry());
    }
}

如何在集群环境中工作?我们如何使用TCP代替in-vm?

贾斯汀·贝特拉姆(Justin Bertram):

如果要将TCP用于REST,则只需在中配置它rest-messaging.xml,例如:

<rest-messaging>
   <use-link-headers>false</use-link-headers>
   <default-durable-send>false</default-durable-send>
   <dups-ok>true</dups-ok>
   <topic-push-store-dir>topic-push-store</topic-push-store-dir>
   <queue-push-store-dir>queue-push-store</queue-push-store-dir>
   <producer-time-to-live>0</producer-time-to-live>
   <producer-session-pool-size>10</producer-session-pool-size>
   <session-timeout-task-interval>1</session-timeout-task-interval>
   <consumer-session-timeout-seconds>300</consumer-session-timeout-seconds>
   <consumer-window-size>-1</consumer-window-size>
   <url>tcp://127.0.0.1:61616</url>
</rest-messaging>

如果要对主/从HA对使用REST,则应在主代理和从代理“前面”的另一台机器上配置Web应用程序服务器(例如Tomcat或Jetty),并使用如下URL:

<url>(tcp://master:61616,tcp://slave:61616)?ha=true;reconnectAttempts=-1</url>

就是说,我不建议您使用REST,因为尽管REST相对简单,但是没有用于消息传递的标准REST接口,因此您的REST客户端将与ActiveMQ Artemis绑定在一起(这不利于应用程序的可移植性)。通常,STOMP可以很好地替代REST。STOMP是一种简单的基于文本的协议,可以从JavaScript中使用,并且可以在大多数与REST相同的地方使用它,还可以对其进行标准化,因此您会发现许多使用多种不同语言的客户端实现。

此外,当前尚未为REST接口与远程代理之间的连接实现安全性,这意味着任何客户端都可能潜在地连接到代理并使用或产生消息。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在ActiveMQ Artemis中为基于keystore和truststore的MQTT协议启用SSL

ActiveMQ Artemis故障转移与群集

如何在Google Kubernetes Engine群集中启用客户端证书

HA群集ActiveMQ Artemis的正确配置

如何在 ActiveMQ Artemis 中使用发现组形成 3 个节点的对称集群?

如何在ActiveMq嵌入式代理上启用Web控制台

ActiveMQ Artemis的REST API在哪里?

如何加密 ActiveMQ Artemis 中的静态数据?

如何在Redis群集中删除与模式匹配的键

如何在Galera群集中使用MySQL临时表?

如何在Hazelcast群集中配置复制缓存?

Azure Databricks:如何在Databricks群集中添加Spark配置

如何在群集中对不同的缓存进行分组

如何在AKS群集中创建Windows节点池?

为 ActiveMQ Artemis 中的特定记录器启用 TRACE

如何在现有GKE群集上启用Istio SDS

如何解决GKE群集中的“群集有问题”状态?

如何重命名群集中的索引?

如何禁用群集中的Stackdriver Logging代理?

Raft群集中的节点如何知道“多数”?

如何在禁用的字段集中启用一个按钮

如何在gcc程序集中启用预处理器

如何将日志从 ActiveMQ Artemis 1.5.6 迁移到 2.7.0?

如何干净地关闭嵌入式ActiveMQ Artemis

如何使用Spring Boot和ActiveMQ Artemis复制?

如何配置 ActiveMQ Artemis 服务器进行远程访问?

如何解决新的ActiveMQ Artemis安装阻止问题?

如何查找/定义用于ActiveMQ Artemis监视的JMX密钥

如何热导出 ActiveMQ Artemis 的配置并热导入?