我正在尝试使用新的命名空间jakarta
而不是迁移到 Spring Boot 3 javax
,但 ActiveMQ Classic 客户端尚未更新并且已被弃用。有没有办法继续使用旧的ActiveMQ客户端?
我尝试了新的 ActiveMQ Artemis 客户端,但它们似乎无法与 ActiveMQ Classic 服务器互操作。包含旧的 ActiveMQ 客户端会导致无法使用 JMSTemplate 进行配置,因为 JMSTemplate 使用 jakarta.xx 并期望ConnectionFactory
来自 jakarta.xx 而不是 javax.xx
编辑:不起作用,所以唯一的方法是升级到 ActiveMQ Artemis。这样代码库也几乎没有变化。
编辑:2023 年 4 月:新的ActiveMQ 客户端发布。您只需要将spring-boot-starter-activemq
与更新版本交换并包含此
大家早,
我最近一直在与spring-boot-artemis-starter挣扎.我对它的spring-boot支持的理解如下:
spring.artemis.mode=embedded
,和tomcat一样,spring-boot将实现通过tcp(服务器模式)可访问的代理.以下命令应该成功:nc -zv localhost 61616
spring.artmis.mode=native
和spring-boot只会根据spring.artemis.*
属性(客户端模式)配置jms模板.客户端模式可以在我的机器上使用独立的artemis服务器.不幸的是,我无法在服务器模式下到达tcp端口.
如果有人确认我对嵌入式模式的理解,我将不胜感激.
感谢您的旅行帮助
经过一番挖掘后,我注意到spring-boot-starter-artemis开箱即用的实现使用了org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory
acceptor.我想知道这不是根本原因(我再也不是专家).但似乎有一种方法可以自定义artemis配置.因此我尝试了以下配置而没有任何运气:
@SpringBootApplication
public class MyBroker {
public static void main(String[] args) throws Exception {
SpringApplication.run(MyBroker.class, args);
}
@Autowired
private ArtemisProperties artemisProperties;
@Bean
public ArtemisConfigurationCustomizer artemisConfigurationCustomizer() {
return configuration -> {
try {
configuration.addAcceptorConfiguration("netty", "tcp://localhost:" + artemisProperties.getPort());
} catch (Exception e) {
throw new RuntimeException("Failed to add netty transport acceptor to artemis instance");
}
};
}
}
Run Code Online (Sandbox Code Playgroud) 我遇到了一个问题,即执行器探测 JMS 运行状况失败,即使我的路由可以连接并向 JMS 生成消息。简而言之,执行器说它已关闭,但它正在工作。
技术堆栈和技术说明:
org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
连接工厂。我的路线就像筹码一样简单:
<route id="timer-cluster-producer-route">
<from uri="timer:producer-ticker?delay=5000"/>
<setBody>
<groovy>
result = ["Name":"Johnny"]
</groovy>
</setBody>
<marshal>
<json library="Jackson"/>
</marshal>
<to uri="ref:jms-producer-cluster-event" />
</route>
Run Code Online (Sandbox Code Playgroud)
基于 XML 的 Artemis 配置
由于 Spring-boot 支持基于 java 的配置,我正忙于相应地迁移我们的 XML beans。因此,我将一个工作 beans.xml 文件粘贴到项目中并启动了路由,我可以发送消息流,并且运行状况检查返回正常。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="jmsConnectionFactory"
class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
<property name="user" value="artemis"/>
<property name="password" value="artemis"/>
<property name="connectionLoadBalancingPolicyClassName" value="org.apache.activemq.artemis.api.core.client.loadbalance.RoundRobinConnectionLoadBalancingPolicy"/>
</bean>
<!--org.messaginghub.pooled.jms.JmsPoolConnectionFactory-->
<!--org.apache.activemq.jms.pool.PooledConnectionFactory-->
<bean id="jmsPooledConnectionFactory"
class="org.apache.activemq.jms.pool.PooledConnectionFactory"
init-method="start" destroy-method="stop"> …
Run Code Online (Sandbox Code Playgroud) 我正在Windows .NET环境中使用RabbitMQ,ActiveMQ和Apache Artemis进行一些测试.RabbitMQ和ActiveMQ附带一个Web界面,您可以在其中查看有关您的经纪人,队列,消息等的信息,但Artemis没有.我真的希望能够在Web界面中监控我的Artemis代理,或者至少使用一些cmd/PowerShell命令.
我在这个页面上读到了一些可用于监控ActiveMQ实例的第三方工具,我认为它也适用于Artemis.不幸的是,我无法使用这些第三方工具.其中一些似乎在Windows上运行不正常,有些是旧的/不活动的.
我的客户通过C#中的NMS(.NET Messaging API)与代理进行通信.如果有人能够监控他们的Artemis经纪人,特别是在Windows机器上,请告诉我你是如何做到的!
编辑:
我现在已经设法与Jolokia REST API进行通信.通过GET请求,
http://username:password@localhost:8161/jolokia/read/org.apache.activemq.artemis:*
我可以看到有关我的队列的大量信息,例如添加和使用的消息.这是一个很好的信息,可以帮助我,但我想了解有关当前内存使用情况和磁盘使用情况的信息.
在互联网上如此笨拙之后,令人惊讶的是,我找不到使用带有ActiveMQ(Artemis)的WildFly 10中的JMS推送到远程消息队列的示例配置.为了恶化这种情况standalone-full.xml
并不局限于一个模式(为什么???),当我最终在GitHub上找到它的XSD时,它不包含任何文档,说明每个节点/属性的含义以及可以放入什么值.
以下是standalone-full.xml的原始配置.
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<security-setting name="#">
<role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
</security-setting>
<address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
<http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
<http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0"/>
<http-acceptor name="http-acceptor" http-listener="default"/>
<http-acceptor name="http-acceptor-throughput" http-listener="default">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
<pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
</server>
</subsystem> …
Run Code Online (Sandbox Code Playgroud) 下面是我尝试使用 Apache Camel 反应流解决方案将发布者连接到订阅者(骆驼路由的代码如下所示)跨 JVM 的
为了使通信能够跨越 JVM,似乎需要一个“代理”服务器。因此,我已经实现了 Artemis 代理并相应地修改了 application.properties 文件(根据我对如何这样做的最佳理解)。
此外,为了缩小焦点,选择使用 smallrye-ampq 连接器。
问题:
订阅者应该接收并记录字符串值(来自正文):
-
-
-
:blahblahblah
:blahblahblah
:blahblahblah
-
-
-
Run Code Online (Sandbox Code Playgroud)
--相反,它正在记录值,如下所示:
-
-
-
:Exchange[ID-LAPTOP-4LR4PMVQ-1576639597494-0-289]
:Exchange[ID-LAPTOP-4LR4PMVQ-1576639597494-0-292]
:Exchange[ID-LAPTOP-4LR4PMVQ-1576639597494-0-295]
-
-
-
Run Code Online (Sandbox Code Playgroud)
题:
为什么发布者发送的有效负载没有到达订阅者,我可以修改哪些代码/配置来修复它?
提前感谢您的帮助!
“出版商”路线
package aaa.bbb.ccc.jar;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.eclipse.microprofile.reactive.messaging.Outgoing;
import org.reactivestreams.Publisher;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService;
import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@ApplicationScoped
public class CamelPub extends RouteBuilder {
@Inject
CamelContext ctx;
CamelReactiveStreamsService crss;
static int x = 0; …
Run Code Online (Sandbox Code Playgroud) java apache-camel reactive-programming activemq-artemis smallrye
启用持久性后broker.xml
,当-Xms
&-Xmx
设置为 4GB 并global-max-size
设置为默认 200Mb(大部分设置只是由 Artemiscreate
命令创建的)时,我会在一天或三天内根据处理的数据速率收到以下异常。配置类似于这个帖子。
2020-08-03 02:25:58,969 WARN [org.apache.activemq.artemis.core.server] AMQ222033: Page file 000000005.page had incomplete records at position 9,259,622 at record number 4,224
2020-08-03 02:31:19,390 WARN [org.apache.activemq.artemis.core.server] AMQ222288: Page 5, message 4,224 could not be found on offset 9,259,622, with starting message 4,224. This represents a logic error or inconsistency on the data, and the system will try once again from the beggining of the page file.
2020-08-03 …
Run Code Online (Sandbox Code Playgroud) 我有一个带有队列的独立远程 Artemis 服务器,我想配置 WildFly 以便通过 WildFly 本身连接该队列。版本为WildFly 12.0.0.Final和Artemis 2.5.0。
在 Artemis 上,我在broker.xml文件中配置了一个队列,如下所示:
<addresses>
<address name="DemoQueue">
<anycast>
<queue name="DemoQueue" />
</anycast>
</address>
</addresses>
Run Code Online (Sandbox Code Playgroud)
然后我在 WildFly 上配置了一个池连接工厂,创建:
我在standalone-full.xml文件中的最终配置如下:
<server>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<outbound-socket-binding name="remote-artemis">
<remote-destination host="localhost" port="61616"/>
</outbound-socket-binding>
</socket-binding-group>
<subsystem xmlns="urn:jboss:domain:messaging-activemq:3.0">
<server name="default">
...
<remote-connector name="remote-artemis" socket-binding="remote-artemis"/>
<pooled-connection-factory name="remote-artemis" entries="java:/jms/RemoteArtemisCF" connectors="remote-artemis"/>
</server>
</subsystem>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<bindings>
<external-context name="java:global/federation/remotequeue" module="org.apache.activemq.artemis" class="javax.naming.InitialContext"> …
Run Code Online (Sandbox Code Playgroud) 我在 ActiveMQ Artemis 2.20 中向队列发送一条消息,然后导航到 Web 控制台来查看该消息,但我只能看到有限的字符。我可以配置 Web 控制台以可视化队列中的完整消息正文吗?
我有一个用于 ActiveMQ-Artemis 的 k8 部署(使用 minikube)。在此,我公开了代理(61616)和控制台(8161)的端口。将端口指向服务。它运行良好。我还为控制台配置了入口控制器。
服务.yaml
kind: Service
metadata:
name: artemis-service
spec:
type: ClusterIP
ports:
- port: 8161
name: http-console
protocol: TCP
targetPort: 8161
- port: 61616
name: netty-connector
protocol: TCP
targetPort: 61616
selector:
app: artemis
Run Code Online (Sandbox Code Playgroud)
Ingress.yaml
kind: Ingress
metadata:
name: broker-ingress
labels:
name: broker-ingress
spec:
ingressClassName: nginx
rules:
- host: artemis.broker.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: artemis-service
port:
number: 8161
Run Code Online (Sandbox Code Playgroud)
当我点击时,我可以访问 activemq 控制台,http://artemis.broker.com
现在我想使用 NGINX 控制器公开 TCP 端口 (61616),通过它我可以使用 TCP URL 将消息发布/消费到 …
activemq-artemis ×10
spring-boot ×3
apache-camel ×2
java ×2
jms ×2
wildfly ×2
broker ×1
kubernetes ×1
minikube ×1
nms ×1
smallrye ×1
wildfly-10 ×1