我认为您需要添加一个 HTTP 传输连接器:
<transportConnector name="http" uri="http://0.0.0.0:8080"/>
在我的情况下,作为 http://localhost:8080 的 URI不起作用。我也觉得默认连接器不安全,用户名和密码已经过时(至少第一次尝试)。
最终解决方案
ActiveMQ 配置 (activemq.xml)
<transportConnectors>
<transportConnector name="http" uri="http://0.0.0.0:8080"/>
</transportConnectors>
Java 客户端(仅限生产者)
try {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("http://localhost:8080");
Connection connection = connectionFactory.createConnection();
connection.start();
// Create a Session
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the best Queue ever
Destination destination = session.createQueue("STACKOVERFLOW.SUPPORT");
// Create a MessageProducer from the Session to the Topic or Queue
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// Create a messages
TextMessage message = session.createTextMessage("I hope this snippets help you :D | Thread: " + Thread.currentThread().getName());
producer.send(message);
//clean up
session.close();
connection.close();
} catch(JMSException e) {
e.printStackTrace();
}