Jump to content

Advanced Uses

From Open Rail Data Wiki

Bridging Topics

In some cases, you may want to have a local ActiveMQ server for ease of use. You might want to perform further processing on the messages, such as routing certain messages to specific topics or queues, or you might just want a 'known good' client.

This example here is community-supported only.

Configuration

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="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/spring" id="camel">
  </camelContext>

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

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"/>
  </bean>

Replace $NAME$ with the name of the bean, e.g. "darwin" or "networkrail". Replace $HOSTNAME$:$PORT$ with the hostname, a colon and the TCP port for the service, and $USERNAME$ and $PASSWORD$ with your username/password as appropriate.

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

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

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

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

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. "user@example.com-td" 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) • STOMP Client Libraries Advanced UsesFAQ Release Notes
RTPPM RTPPM Feed
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
VSTP VSTP Feed
TSR TSR Feed Route Codes
SCHEDULE SCHEDULE Feed TIPLOC Records 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 (BPLAN)