Advanced Uses

From Open Rail Data Wiki
Jump to: navigation, search

Bridging Topics

It is possible to 'bridge' data from the Data Feeds platforms to your own ActiveMQ server. You may want to do this if:

  • You need to store messages for longer than the durable subscription TTL of 5 minutes
  • You want to have multiple consumers connected over a slow network connection

If you do this, please don't simply re-publish data for other people or organisations. Usage of the Data Feeds platforms is monitored, and more users equals better opportunity for making further data available!

Be warned - this example assumes knowledge of ActiveMQ, and is community-supported only.


Download ActiveMQ and add the following configuration to conf/activemq.xml before the end of the beans tag:

<import resource="camel.xml"/>

Create the file conf/camel.xml with the following:

<?xml version="1.0"?>
<beans xmlns="" xmlns:xsi="" xsi:schemaLocation="">

  <camelContext xmlns="" id="camel">

  <bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616"/>

This sets up a Camel Context in which you can configure routes.

To connect to an ActiveMQ service, add the following bean outside the camelContext tag:

  <bean id="$NAME$" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://$HOSTNAME$:$PORT$"/>
    <property name="userName" value="$USERNAME$"/>
    <property name="password" value="$PASSWORD"/>

Replace $NAME$ with the name of the bean, e.g. "darwin" or "networkrail". Replace $HOSTNAME$:$PORT$ with either or, and $USERNAME$ and $PASSWORD$ with the username/password as appropriate.

To route data from a queue on the National Rail Enquiries service, add the following within the camelContext tag:

  <from uri="$NAME$:queue:$QUEUE$"/>
  <to uri="amq:topic:$TOPIC$"/>

To route data from a topic on the Network Rail service, add the following within the camelContext tag:

  <from uri="$NAME$:topic:$TOPIC$?clientId=$CLIENT_ID$&amp;durableSubscriptionName=$SUBSCRIPTION_NAME$"/>
  <to uri="amq:topic:$TOPIC$"/>

Replace $CLIENT_ID$ with a client ID which start with the email address you use to subscribe, followed by the name of the feed e.g. "" for the TD feed. Set a sensible name for the $SUBSCRIPTION_NAME$ setting, for example, your email address.

Finally, start ActiveMQ, and check the web interface to ensure your data is being routed.

Network Rail Open Data Feeds
Data Feeds About the Feeds Account States Durable Subscriptions Example Code ( PHP / C# / Java / Ruby / Node.js) • Advanced UsesFAQ Release Notes
Train Movements Train Movements Feed Train Activation Train Cancellation Train Movement Train Reinstatement Change of Origin Change of Identity Change of Location TSPEED Field Planned Cancellations Cancellation Codes
TD TD Feed C-Class Messages S-Class Messages Train Describers TD Berths
TSR TSR Feed Route Codes
SCHEDULE SCHEDULE Feed Schedule and Location Records Association Records CIF Codes How Scheduling Works Allowances
Reference Data Reference Data Feed TOC Codes CIF Codes Delay Attribution Codes Identifying Locations (STANOX, TIPLOC, NLC and 3-Alpha Codes) STANOX Geographical Areas Train Planning data