我正在学习ActiveMQ和Camel,目标是创建一个像这样工作的小原型系统:
alt text http://www.paulstovell.com/get/stackoverflow-questions/Queues.png(big )
当订单放入订单系统时,会向任何订户(发布/订阅系统)发送消息,他们可以在处理订单时发挥作用.该订单,航运和进销存应用程序都有自己的ActiveMQ安装,因此,如果任何三个系统都处于离线状态,其他人可以继续工作.有些东西负责在ActiveMQ安装之间移动消息.
如果Apache Camel位于同一个ActiveMQ实例上,那么让Apache Camel通过路由将消息从一个队列移动到另一个队列非常容易.所以这适用于管理订阅队列.
接下来的挑战是将消息从一个ActiveMQ实例推送到另一个实例,这就是我不确定接下来要看什么的位置.
由于我在这个问题上遇到了很多困难,所以我发布了我的解决方案.在activemq代理网络中禁用jmx会删除有关jmx连接器注册的竞争条件.在同一台计算机上启动多个activemq服务器时:
无法启动jmx连接器:无法绑定到URL [rmi:// localhost:1099/jmxrmi]:javax.naming.NameAlreadyBoundException:jmxrmi [Root exception is java.rmi.AlreadyBoundException:jmxrmi]
另一个问题是,即使您没有引起竞争条件,仍然可能发生此异常.即使在等待他们在两者之间正确初始化的同时开始一个接一个的经纪人.如果一个进程由root作为第一个实例运行而另一个进程作为普通用户运行,则用户进程会以某种方式尝试注册自己的jmx连接器,尽管已经有一个.
或者成功注册jmx连接器的代理发生故障时发生的另一个异常:
无法启动jmx连接器:无法绑定到URL [rmi:// localhost:1099/jmxrmi]:javax.naming.ServiceUnavailableException [根异常是java.rmi.ConnectException:连接拒绝主机:localhost; 嵌套异常是:java.net.ConnectException:连接被拒绝]
这些例外导致经纪人网络停止工作或根本不工作.禁用jmx的技巧是,必须在connectionfactory中禁用jmx.文档http://activemq.apache.org/jmx.html并未明确说明这一点.所以我必须奋斗2天,直到我找到解决方案:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core"
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-3.0.xsd http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.3.1.xsd">
<!-- Spring JMS Template -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<constructor-arg ref="connectionFactory" />
</bean>
<!-- Caching, sodass das jms template überhaupt nutzbar ist in sachen performance -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg ref="amqConnectionFactory" />
<property name="exceptionListener" ref="jmsExceptionListener" />
<property name="sessionCacheSize" value="1" />
</bean>
<!--
Jeder Client verbindet sich mit seinem eigenen broker, broker sind untereinander vernetzt. Nur …Run Code Online (Sandbox Code Playgroud) 如何解决错误?
Java Runtime: Oracle Corporation 1.7.0_05 E:\Program Files\Java\jdk1.7.0_05\jre
Heap sizes: current=1004928k free=994439k max=1004928k
JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Dactivemq.classpath=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\conf;F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\../conf;F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\../conf; -Dactivemq.home=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\.. -Dactivemq.base=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\.. -Dactivemq.conf=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\conf -Dactivemq.data=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data -Djava.io.tmpdir=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data\tmp
ACTIVEMQ_HOME: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..
ACTIVEMQ_BASE: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..
ACTIVEMQ_CONF: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\conf
ACTIVEMQ_DATA: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data
Loading message broker from: xbean:activemq.xml
INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@2b9f7952: startup date [Sat Jul 28 18:10:38 CST 2012]; root of context hierarchy
INFO | PListStore:[F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data\localhost\tmp_storage ] started
INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data\kahadb]
INFO …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用新的命名空间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与更新版本交换并包含此
我需要设置消息优先级,以便接收方在低优先级消息之前消耗高优先级消息.
首先,我尝试使用message.setJMSPriority()方法来设置优先级,但它在HornetQ和ActiveMQ中不起作用,所以最后我使用setPriority()方法设置Message Producer的优先级,现在它工作正常.
为什么Messsge.setJMSPriority()不能在任何JMS供应商实现中工作?为什么我们需要设置Producer的优先级而不是消息本身来设置消息的优先级?那么Messsge.setJMSPriority()方法的用途是什么?
任何建议或评论表示赞赏.
本来喜欢使用Amazon SQS,如果它提供了一些相似的FIFO访问,但序列似乎是完全随机的.
是否有什么能够为我提供FIFO排队作为云服务以及SQS的高可用性?
如果这要求太多 - 在EC2中将上述要求放在一起的最简单方法是什么?或者换句话说,在EC2中最简单的高可用性排队解决方案是什么?
感谢您的见解!
我正在使用Apache ActiveMQ version 5.8.0,我下载了Apache ActiveMQ Browser version 2.5.2.8
在Apache ActiveMQ中,我编辑了activemq.xml配置以使用JMX:
<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true" brokerName="localhost" dataDirectory="${activemq.data}">
<!-- This needed to be set to true, otherwise JMX won't start in 5.8.0 -->
<managementContext>
<managementContext createConnector="true"/>
</managementContext>
</broker>
Run Code Online (Sandbox Code Playgroud)
在启动脚本中,我按如下方式设置JMX设置:
#ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=11099 "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONF}/jmx.password"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONF}/jmx.access"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote"
Run Code Online (Sandbox Code Playgroud)
当我重新启动Apache ActiveMQ时,日志显示JMX已启动且可访问:
JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi | org.apache.activemq.broker.jmx.ManagementContext | JMX connector
Run Code Online (Sandbox Code Playgroud)
还检查端口是否正在侦听结果进入侦听端口:
[me@server ~]$ netstat -lptun | grep 1099
(Not all processes could be identified, non-owned process …Run Code Online (Sandbox Code Playgroud) ActiveMQ是一个消息代理,支持许多不同的协议,如Openwire,AMQP和Stomp.要知道这真令人困惑:
我正在创建两个使用JMS进行通信的springboot服务器和客户端应用程序,并且5.12.1activemq 的发布一切正常,但是一旦我更新到5.12.3版本,我就会收到以下错误:
org.springframework.jms.support.converter.MessageConversionException: Could not convert JMS message; nested exception is javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class MyClass! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
Run Code Online (Sandbox Code Playgroud)
我继续提供的URL,我发现我的问题与5.12.2ActiveMQ发布中实现的新安全性有关,我知道我可以通过定义可信包来修复它,但我不知道在哪里可以把这样的配置放在我的SpringBoot项目中.
我在客户端和服务器中对JMS队列的唯一引用是在application.properties中设置它的URI并在我的"main"类上启用JMS @EnableJms,这是我在单独的代理上的配置:
@Configuration
@ConfigurationProperties(prefix = "activemq")
public class BrokerConfiguration {
/**
* Defaults to TCP …Run Code Online (Sandbox Code Playgroud) activemq-classic ×10
java ×3
amqp ×2
jmx ×2
rabbitmq ×2
spring-boot ×2
amazon-ec2 ×1
amazon-sqs ×1
apache-camel ×1
hornetq ×1
messaging ×1
spring ×1
stomp ×1
zeromq ×1