gpt4 book ai didi

java - activemq 代理是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-04 13:46:05 25 4
gpt4 key购买 nike

我是 ActiveMQJMS 的新手,并开始探索 hello world 程序的工作原理。

我已经安装了ActiveMQ服务器并运行它。现在,我创建了一个 desctop 应用程序并将 apache_activemq_official_hello_world 复制并粘贴到其中。当我尝试运行它时,出现以下异常:

Caught: javax.jms.JMSException: Could not create Transport. Reason: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localhost,Type=Broker
javax.jms.JMSException: Could not create Transport. Reason: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localhost,Type=Broker
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:252)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:265)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:238)
at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:184)
at com.badmitrii.App$HelloWorldProducer.run(App.java:64)
at java.lang.Thread.run(Thread.java:744)
Caused by: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localhost,Type=Broker
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at org.apache.activemq.broker.jmx.ManagementContext.registerMBean(ManagementContext.java:366)
at org.apache.activemq.broker.jmx.AnnotatedMBean.registerMBean(AnnotatedMBean.java:72)
at org.apache.activemq.broker.BrokerService.startManagementContext(BrokerService.java:2370)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:567)
at org.apache.activemq.transport.vm.VMTransportFactory.doCompositeConnect(VMTransportFactory.java:124)
at org.apache.activemq.transport.vm.VMTransportFactory.doConnect(VMTransportFactory.java:54)
at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:67)
at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:250)
... 5 more

然后

Sent message: 386233378 : Thread-13
Sent message: 535117374 : Thread-16
Sent message: 1659874841 : Thread-17
Received: Hello world! From: Thread-17 : 56191182
Received: Hello world! From: Thread-16 : 1728802812
Received: Hello world! From: Thread-13 : 1191507779
Sent message: 1424811745 : Thread-22
Sent message: 1340394669 : Thread-25
Sent message: 1585379622 : Thread-29
Sent message: 607795742 : Thread-27
Sent message: 807925334 : Thread-32
Received: Hello world! From: Thread-22 : 1629703769
Received: Hello world! From: Thread-29 : 2145661378
Received: Hello world! From: Thread-25 : 1459121566
Received: Hello world! From: Thread-27 : 1628632972
Received: Hello world! From: Thread-32 : 538611977
Received: null

我的问题是,在该示例中我真的需要 ActiveMQ 服务器吗?异常中提到的 ActiveMQ Broker 是什么?

最佳答案

我认为,您所需要的只是 activemq-all-??.??.?.jar。该示例自行完成所有操作。如果您的 ActiveMQ 服务器已启动,您可以将其停止。启动“Hello ActiveMQ”应用程序后,您可能不会看到异常。但最好插入

Thread.sleep(3000); //my fighting against exceptions (could not create transport)

在创建第一个消费者之前。

关于java - activemq 代理是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30827782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com