I'm now getting a valid connection but no messages - I thought it was a five minute refresh on push. Can't quite see how to debug it if I'm getting a valid connection and no messages.
For information, here's the test class I'm using for the connection:
package org.uth.networkrail.tests;
import net.ser1.stomp.Client;
import net.ser1.stomp.Listener;
import org.uth.networkrail.listeners.NetworkRailListener;
/**
* Simple connection and message test.
* @author Ian 'Uther' Lawson
*/
public class NetworkRailConnectTest1
{
private static final String SERVER = "
datafeeds.nationalrail.co.uk";
private static final int PORT = 61613;
public static void main( String[] args )
{
if( args.length != 3 )
{
System.out.println( "Usage: java NetworkRailConnectTest1 user password topic");
System.exit(0);
}
new NetworkRailConnectTest1( args[0], args[1], args[2]);
}
public NetworkRailConnectTest1( String username, String password, String topic )
{
try
{
long start = System.currentTimeMillis();
System.out.println( "[NRCT1] Connecting to datafeeds....");
Client client = new Client( SERVER, PORT, username, password );
if( client.isConnected())
{
long end = System.currentTimeMillis();
System.out.println( "[NRCT1] Connected to " + SERVER + ":" + PORT + " in " + (end-start) + "ms.");
System.out.println( "[NRCT1] Subscribing to " + topic );
Listener listener = new NetworkRailListener();
client.subscribe(topic, listener);
System.out.println( "[NRCT1] Listening on topic...");
}
else
{
System.out.println( "[NRCT1] Failed to connect.");
}
}
catch( Exception exc )
{
System.out.println( "Exception occurred: " + exc.toString());
}
}
}
And here's the listener:
package org.uth.networkrail.listeners;
import java.util.Map;
import net.ser1.stomp.Listener;
import org.uth.networkrail.utils.HumanReadableDate;
/**
* First test listener to read message from the Network Rail ActiveMQ topics.
* @author Ian 'Uther' Lawson
*/
public class NetworkRailListener implements Listener
{
@Override
public void message( Map Header, String body )
{
long now = System.currentTimeMillis();
System.out.println( "[" + HumanReadableDate.getDate(now) + "] received message.");
System.out.println( " Message size: " + body.length());
}
}
For parameters I use the generic d3 username and password and my specific queue.
All look right?