Proton qpid java example

To run the example, simply type mvn verify from this directory, 
or mvn -PnoServer verify if you want to start and create the server manually.
<

ActiveMQ Artemis 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 mvn verify -Pexample, execute the compile.sh script and start the executable called ./hello

You don't need to do anything special to configure the ActiveMQ Artemis server to accept AMQP clients.

Just for the sake of documentation though we are setting the port of ActiveMQ Artemis 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 61616 default port

     
         <acceptor name="proton-acceptor">tcp://localhost:5672</acceptor>
     
     

Example step-by-step

  1. Create an amqp qpid 1.0 connection.
  2.            connection= new Connection("localhost", 5672, null, null);
            
  3. Create a session
  4.            Session session = connection.createSession();
            
  5. Create a sender
  6.            Sender sender = session.createSender("testQueue");
            
  7. send a simple message
  8.            sender.send(new Message("I am an amqp message"));
            
  9. create a moving receiver, this means the message will be removed from the queue
  10.            Receiver rec = session.createMovingReceiver("testQueue");
            
  11. set some credit so we can receive
  12.           rec.setCredit(UnsignedInteger.valueOf(1), false);
            
  13. receive the simple message
  14.           Message m = rec.receive(5000);
                    System.out.println("message = " + m.getPayload());
            
  15. acknowledge the message
  16.           rec.acknowledge(m);
            
  17. close the connection
  18.           connection.close();