ActiveMQ is a multi protocol broker. It will inspect the initial handshake of clients to determine what protocol to use.
All you need to do is to connect a client into activemq's configured port and you should be able connect.
To run this example simply run the command
# first make sure you have the dependencies you need to compile and run the client # You will have to adapt this step according to your platform. Consult the qpid docs for more information. # There is a list of packages you can install as well. [proton-cpp]$ sudo yum install qpid-cpp-client-devel # on a first window [proton-cpp]$ mvn verify # on a second window # That goes without saying but you will of course need g++ (the C++ compiler) installed [proton-cpp]$ ./compile.sh [proton-cpp]$ ./hello
You don't need to do anything special to configure the ActiveMQ server to accept AMQP clients.
Just for the sake of documentation though we are setting the port of ActiveMQ on this example as 5672 which is the port qpid have by default.
This is totally optional and you don't need to follow this convention. You can use any port you chose including ActiveMQ's 5445 default port
<acceptor name="proton-acceptor">
<factory-class>org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="port" value="5672"/>
</acceptor>
We are using qpid cpp client on this example. There are several libraries you may chose from for AMQP. We have ellect one that we consider simple enough for users.
This example is based on qpid's hello world example.
Assuming you are on Linux Fedora, you will need to run this following command
yum install qpid-cpp-client-devel
Consult the qpid documentation, and the required packages for information on other platoforms.
std::string broker = argc > 1 ? argv[1] : "localhost:5445";
std::string address = argc > 2 ? argv[2] : "jms.queue.exampleQueue";
std::string connectionOptions = argc > 3 ? argv[3] : "{protocol:amqp1.0}"; // Look at the docs for more options
Connection connection(broker, connectionOptions);
connection.open();
Session session = connection.createSession();
Sender sender = session.createSender(address);
sender.send(Message("Hello world!"));
Receiver receiver = session.createReceiver(address);
Message message = receiver.fetch(Duration::SECOND * 1);
session.acknowledge();
connection.close();