5. Support Engineering Group : Interacting with Tracking Data on RabbitMQ This page last changed on Sep 26, 2012 by kgomes. This page documents how to subscribe to and publish to tracking data from the RabbitMQ server at MBARI. ### Architecture The current architecture for MBARI's tracking messages is shown in the VERY large diagram below. ### Consuming messages ##### Java Subscriber If you are interested in consuming tracking messages from the RabbitMQ server using Java, you are in the right spot. The first thing you will need to do is get the supporting libraries from RabbitMQ website. https://www.rabbitmq.com/download.html From the Java client download, you will need several libraries on your classpath: rabbitmq-client.jar commons-cli-1.1.jar commons-io-1.2.jar After that, you can write your client code to connect up to and listen for tracking related messages. Below is some example code to connect to MBARI's messaging server and subscribe to the tracking message exchange. Some things to note: In your code, when you create a queue, you MUST make sure it is unique. If you have questions, contact MBARI about what queue name you should use. If you using something like your reverse domain, that is pretty sure to be unique, but it is probably best to ask. Please note that when you declare the queue, make sure the fourth parameter is true so the queue will auto delete when your client shuts down. This is important because if queues are left in fanout exchanges, they will simply fill with messages until the client connects to drain them. Currently, the RabbitMQ server is behind MBARI's firewall. That will change in the future, but if you are outside, you will have to work with MBARI to get connected to the proper ports through the firewall. You will have to work with MBARI before hand to get a username and password for the RabbitMQ server. The body of the message will be a marshalled Google protocol buffer payload of the following form:
       package MBARItracking;

       message PlatformReport {
       	enum PlatformType {
       		MBARI_SHIP = 0;
       		AIS = 1;
       		AUV = 2;
       		DRIFTER = 3;
       		MOORING = 4;
       		GLIDER = 5;
       	}
       	optional PlatformType type = 1;
       	optional string name = 2;
       	optional double epoch_seconds = 3;
       	optional double latitude = 4;
       	optional double longitude = 5;
       	optional string source = 6;
       	optional uint64 mmsi = 7;
       	optional uint64 imei = 8;
       	optional string iso_datetime = 9;

       }
Java Code
    package org.mbari.odss.messaging;

    import com.rabbitmq.client.Channel;
    import com.rabbitmq.client.Connection;
    import com.rabbitmq.client.ConnectionFactory;
    import com.rabbitmq.client.QueueingConsumer;

    public class TestConnection {

            // The name of the exchange to connect to
    	private static final String EXCHANGE_NAME = "auvs_pb";

            // The main method
    	public static void main(String[] argv) throws java.io.IOException,
    			java.lang.InterruptedException {

                    // The RabbitMQ ConnectionFactory
    		ConnectionFactory factory = new ConnectionFactory();

    		// MBARI's messaging server is 'messaging.shore.mbari.org
    		factory.setHost("messaging.shore.mbari.org");

                    // RabbitMQ uses virtual hosts as a top level concept.
                    // MBARI's virtual host is 'trackingvhost'
    		factory.setVirtualHost("trackingvhost");

                    // Now set your user credentials (need to get this set up with MBARI)
    		factory.setUsername("username");
    		factory.setPassword("password");

                    // Create a connection
    		Connection connection = factory.newConnection();

                    // Create a channel
    		Channel channel = connection.createChannel();

                    // Create a queue that you will pull messages from (must be unique)
    		channel.queueDeclare("my_queue_name", true, false, true, null);

                    // Bind the queue to the proper exchange
    		channel.queueBind("my_queue_name", EXCHANGE_NAME, "");

                    // Now print a message on how to get out to the user
    		System.out.println(" [*] Waiting for messages. To exit press CTRL+C");

                    // Create a consumer to listen for messages on the proper channel
    		QueueingConsumer consumer = new QueueingConsumer(channel);
    		channel.basicConsume("my_queue_name", true, consumer);

                    // Enter infinite loop
    		while (true) {
                            // Block and listen for message
    			QueueingConsumer.Delivery delivery = consumer.nextDelivery();

                            // Extract the message body and print it to the console
    			String message = new String(delivery.getBody());
    			System.out.println(" [x] Received '" + message + "'");
    		}
    	}
    }
##### Python Consumer This is still to be done, but using the above information and this here: https://www.rabbitmq.com/devtools.html#python-dev You should be able to figure it out ... ### Publishing Messages If you want to get your platforms positions into the tracking system, there are a couple of ways: Email messages or direct interaction with RabbitMQ. ##### Email Publisher If you want to email your positions, you must first decide what type of platform you fall into. The types that are currently supported are: AIS AUV Drifter Glider Mooring Ship Once you have decided, that determines what email address to send your messages to: AIS -> aistrack@mbari.org AUV -> auvtrack@mbari.org Drifter -> driftertrack@mbari.org Glider -> glidertrack@mbari.org Mooring -> mooringtrack@mbari.org Ship -> ship track@mbari.org Then you just need to put the proper information into the subject of the message and leave the body blank: platformName,timestamp,longitude,_latitude Where: platformName is the name you would like to use for your platform NOTE IT MUST BE 9 CHARACTERS OR LESS timestamp is the time of the location fix in decimal epoch seconds longitude is, well, the longitude latitude is, well, the latitude ##### Java Publisher To be documented ... ##### Python Publisher To be documented ... Attachments: TrackingData.jpg (image/jpeg)

Document generated by Confluence on Feb 03, 2026 16:22