Transport scheme NOT recognized: [amqp]

2019-07-18 04:42发布

问题:

Am trying to use AMQP with ActiveMQ and am getting the following error

Transport scheme NOT recognized: [amqp]

This is my code

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
        "amqp://localhost:61616");

Connection connection = null;
try {
    connection = connectionFactory.createConnection();
    connection.start();

    Session session = connection.createSession(false,
            Session.AUTO_ACKNOWLEDGE);

    Queue queue = session.createQueue("somequeue");

    MessageProducer producer = session.createProducer(queue);

    // We will send a small text message saying 'Hello'
    TextMessage message = session.createTextMessage();
    message.setText("Publishing : New Message ");
    producer.send(message);

    connection.close();
} catch (Exception e) {

}

回答1:

Please note that AMQP in ActiveMQ is implemented in the Server only and not in the JMS client. The JMS client actually implements the "default" OpenWire protocol (and the intra-JVM transport).

You should use some other client library to communicate with ActiveMQ using AMQP, such as Apache QPID which is recommended by ActiveMQ.