java - activemq broker是什么意思?

java - activemq broker是什么意思?,第1张

我是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是什么?

最佳答案:

1 个答案:

答案 0 :(得分:0)

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

  

Thread.sleep(3000); //我与异常作斗争(无法创建传输)

在创建第一个使用者之前。

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复