Darwin:Push Port: Difference between revisions

From Open Rail Data Wiki
m Remove availability section post-launch
→‎Good Practice: add link to gotchas list
 
(28 intermediate revisions by 9 users not shown)
Line 1: Line 1:
== About ==
The Darwin Push Port is an XML push feed that continuously streams information about the creation of,
and changes to, train schedule records, together with train running predictions made by Darwin.


The Darwin Push Port is an XML push feed that continuously streams information about the creation of, and changes to, train schedule records, together with train running predictions made by Darwin.
The data is made available through http://opendata.nationalrail.co.uk.


The Push Port can be filtered to a specific area of interest by TIPLOC, or to provide information for the entire country. Either way, the information delivered is complex and must be properly interpreted before presentation to end users.
The Push Port requires the user to build a database capable of capturing extremely high volumes of  
information, as well as a query engine to draw the information from your database. There is a large
amount of interpretation work involved in this; however this allows substantial flexibility to apply
the information to any product within the limitations of your own infrastructure.


The Push Port requires the user to build a database capable of capturing extremely high volumes of information, as well as a query engine to draw the information from your database. There is a large amount of interpretation work involved in this; however this allows substantial flexibility to apply the information to any product within the limitations of your own infrastructure.
= Data =
The Push Port has two components:
* Timetable and Timetable Reference Data.
* Real-Time Update Data.


== Data ==
All Darwin data is gzipped ''(except for the Darwin Status Topic)''.  [[Darwin:Push_Port_XML_Schemas|XSDs]] for the interface are available, along with [[:File:Push Port Interface Specification.gz|the specification]].


The Push Port has three components:
= Timetable and Timetable Reference Data =
Darwin makes available Timetable and Timetable Reference Data exposed as static files that are
generated ''usually'' on a daily basis.  The creation of new Timetable and Timetable Reference files
are alerted via ''TimeTableId'' messages in the real-time Update Data.


* Reference Data, available over FTP once a day
== Timetables ==
* Timetable, available over FTP once a day
Timetable data contains a set of schedules covering at least a 48-hour
* Real-time updates, available over Stomp
period held in the Darwin database. This list of schedules provides the basis on
which a Darwin snapshot can be applied.


[[Darwin:Push_Port_XML_Schemas|XSDs]] for the interface are available.
The schedules in the timetable do not include forecast or actual times although
they reflect the latest state that Darwin has when the timetable file was generated,
so any schedule changes, new schedules, false destinations, cancellations and
associations will be included.


== Reference Data ==
== Reference Data ==
 
The Timetable Reference Data contains the following data referenced in timetables:
The reference data contains:
* [[Darwin:Reference_locations|TIPLOCs, CRS codes, TOC codes and location names]]
 
* TIPLOCs, CRS codes, TOC codes and location names
* TOC codes, names and website URLs
* TOC codes, names and website URLs
* Late Running reason codes and text
* [[Darwin:Late Running reason codes and text|Late Running reason codes and text]]
* Cancellation reason codes and text
* [[Darwin:Cancellation reason codes and text|Cancellation reason codes and text]]
* [[Darwin:Via_Locations|Via locations]]
* [[Darwin:Via_Locations|Via locations]]
* CIS codes and names
* [[Darwin:CIS codes and names|CIS codes and names]]
 
== Timetable ==
 
There are two components to the Darwin Timetable:
 
* A timetable snapshot, available once a day via FTP
* Schedule updates via the Real-time feed (see below)
 
== Real-time Updates ==
 
NOTE: All messages in the real-time update stream are sent in XML with the message body compressed using gzip.


Each message in the update feed contains [[Darwin:uR_Element|update response]] element, which is in turn nested inside a 'Pport' element:
= Update Data =
Darwin makes available real-time updates that alert the user to changes in the state of the
Darwin database, or the creation of new Timetable and Timetable Reference Data.  Darwin exposes two
message topics:
* Darwin Live Feed Topic
* Darwin Status Topic


== Darwin Live Feed Topic ==
The live feed topic exposes all update messages. Update messages contain one or more of the following elements:
* [[Darwin:Schedule_Element|Schedule data]]
* [[Darwin:Schedule_Element|Schedule data]]
* [[Darwin:Association_Element|Association data]]
* [[Darwin:Association_Element|Association data]]
Line 49: Line 57:
* [[Darwin:Tracking_ID_corrections|Tracking ID corrections]]
* [[Darwin:Tracking_ID_corrections|Tracking ID corrections]]
* [[Darwin:Alarm_Element|Alarms]]
* [[Darwin:Alarm_Element|Alarms]]
* [[Darwin:Formations|Schedule formation]]
* [[Darwin:Train_Loading|Loading]]
The Live Feed Topic also exposes [[Darwin:TimeTableId_element|TimeTableId]] messages that alert the creation of a new Timetable
or Timetable Reference file.
== uR and sR ==
During normal operation, updates in real-time are issued inside uR elements, but after a period of disconnection between the data platform and Darwin itself, delayed information may enter the feed contained instead inside sR elements. <ref>https://groups.google.com/g/openraildata-talk/c/NQ6GgTHk00k/m/v5VHUD-bBAAJ</ref>
== Status Messages ==
The Status message topic contains status messages about the health and state of the Update Data.
The possible messages are:
; HBINIT : The upstream live feed is running but is initialising its timetable.
   
; HBFAIL : The upstream live feed is shutting down.
   
; HBPENDING : The upstream live feed is operating, but part of the system is currently in failover mode. Data may be queued for a short period. Clients may remain connected and data will be delivered when available.
   
; SNAPSHOT : The Darwin Live Feed has encountered a discontinuity of messages from upstream and is starting a snapshot to re-sync it's state.
   
; SHUTTING-DOWN : Darwin is shutting down and the message topics will soon become unavailable.
= Usage =
== Subscribing to Darwin ==
The Darwin Push Port is made available through http://opendata.nationalrail.co.uk.  By creating an account, you can register
for a subscription to the Darwin feed.
As a user with an active Darwin subscription, navigating to the My Feeds page will display the following details:
; Darwin File Information : This section provides user details for accessing the Timetable and Timetable Reference Data via an Amazon S3 Bucket.
; Darwin FTP Information : This section provides user details for accessing snapshots and 5-minute logs of the real-time Update Data via FTP.


== How do I get the data? ==
; Darwin Topic Information : This section provides user details for accessing real-time Update Data via OpenWire and STOMP message topics.


To access the data feeds you must register for an account at [https://datafeeds.nationalrail.co.uk]. Once you have submitted the registration form, you should receive a confirmation email. Follow the instructions in the email and set your new password.
'''Important''' - Please note NRDP accounts expire after extended periods of no use. The unused account expiry period is
currently set to 30 days. If you create an account and do not consume any of the feeds during this time your account  
will be deleted. If your account has been deleted, you will receive a notification email, and you will be able to
re-register for a new account.


Once you have set your password and signed in, navigate to the data feeds screen by clicking on the My Feeds link at the top of the page.  You will find your queue name, username and password, as well as details of the username and password you should use to download data from the FTP service.
== How do I consume the data? ==


Keep your queue name private, and do not let others know what it is.
=== Timetable and Reference Data ===
Timetable and Reference data can be obtained via an Amazon S3 Bucket.  You will be required to connect and authenticate to S3 via the details given in ''Darwin File Information'' on your ''My Feeds'' page.


== Accessing the data feeds ==
The reference data filenames are in the format "yyyymmddnnnnnn_ref_v3.xml.gz" (e.g. "PPTimetable/20230201021854_ref_v3.xml.gz"). There's usually several days of historical reference data, and different versions, so make sure you select the latest one for the right version (v3 is the correct reference data version for v16).


The data from the Push Port is available on datafeeds.nationalrail.co.uk via [http://en.wikipedia.org/wiki/Streaming_Text_Oriented_Messaging_Protocol STOMP] on TCP port 61613, and [http://activemq.apache.org/openwire.html OpenWire] on TCP port 61616.
The reference data was previously available via FTP, this is no longer the case.  


You will need a STOMP client (available in most languages - a list is available [http://stomp.github.io/implementations.html here]) or an [http://activemq.apache.org/openwire.html OpenWire client].
=== Keeping up to date ===
Timetable and Reference Data is updated ''usually'' on a daily basis.  To indicate that a new Timetable or Timetable Reference
file is available, the real-time topic will send a ''TimeTableId'' message, to identify the new Timetable or Timetable Reference Data file name.


Messages bodies are compressed using gzip before being placed on per-user queues.
A separate ''TimeTableId'' message will be sent for each individual Timetable or Reference
Data file that becomes available. Thus, multiple ''TimeTableId'' messages will be generated
in succession, one for each Timetable and Reference file schema version.


Real-time feeds can be made durable, so messages are not lost if a client experiences a brief disconnection. See the page on [[Durable_Subscription|durable subscriptions]] and the code examples below for more information. Each user's queue maintains 5 minutes worth of Push Port messages.
Note that due to existing schema limitations, the TimeTableId message has mandatory
attributes for timetable file and timetable reference data file names. Since the
TimeTableId notification message is only reporting the presence of a single file, only
one of these attributes will be populated with a valid file name. The other attribute will
consist only of white space.


'''Important''' - Please note that once you have registered for an account, if you leave your message queue idle for an extended period, i.e. you do not connect your STOMP client to pull data down, your account and queue will be deleted. The unused account expiry period is currently set to 100 days. If your account has been deleted, you will receive a notification email, and you will be able to re-register for a new account at [https://datafeeds.nationalrail.co.uk/ datafeeds.nationalrail.co.uk]
=== Update Data via FTP ===
The FTP server provides non real-time Update Data for users that missed the real-time updates. All files are gzipped.


== Accessing the Darwin timetable, reference data, and snapshot files ==
Darwin regularly creates ''Snapshot'' files, containing the entire state of Darwin at a given point in time. The latest snapshot file is available over FTP for end users.
Darwin releases the timetable and reference data file once a day. These files along with a snapshot file that is taken shortly after the timetable has been downloaded are made available for download via an FTP site. All Push Port messages that are older than 5 minutes are also placed in this FTP site in log files,  with each log file containing 5 minutes of Push Port messages. It should be noted that the messages in the log files in the FTP site are not compressed.


The FTP site's URL and access credentials are displayed in the My Feeds screen.
Every 5 minutes of Live Feed Data since the last snapshot will be available in log files, and available over FTP.


== Good Practice ==
=== Real-Time Update Data via OpenWire & Stomp Message Topics ===
You should follow the [[good practice]] guide when using this service.
The Darwin Live Feed Topic and Darwin Status Messages Topic are exposed via ActiveMQ, and can be connected to
via [http://activemq.apache.org/openwire.html OpenWire] or [http://stomp.github.io/stomp-specification-1.2.html STOMP]. The credentials for connecting can be obtained via your ''Darwin Topic Information'' section on your ''My Feeds'' page.


== Examples ==
If you're using STOMP, you should bear in mind that the message bodies are gzip-compressed, which means selecting a client library which properly supports the content-length header and can handle binary messages is essential. A partial [[List of STOMP Client Libraries]] is available to help with this.
 
STOMP and OpenWire allow durable and non-durable subscriptions.  If you would like Darwin to retain messages for you on disconnection,
you should use a durable subscription.  Please note that message retention is limited, and is implemented to allow for short term
subscriber failure, not long term message persistence.
 
'''Important''':  The following must be true when connecting to a Darwin Topic:
* Watching Advisory Topics must be turned off.
* If you are using a Durable Subscriber, your Client ID '''must''' begin with your username.
 
=== Detecting Real-Time Discontinuity ===
Each Update message contains a ''SequenceNumber'' header.  The sequence number runs from 0 to 9,999,999.
Upon reaching the end of this range the sequence number wraps around to 0.
 
NRDP guarantees messages are produced with sequential sequence numbers, therefore a missing sequence number
indicates a missed message.
 
For example, if you received the following sequence numbers in order:
 
    0, 1, 2, 4, 5, 6
 
Then you have missed the message with sequence number 3.
 
=== Filtering ===
If you wish to, you may filter the Darwin Live Feed by message type using JMS Selectors on the MessageType header. Available message types and their respective
codes include:
{| class="wikitable"
!Description
!Code
|-
|Schedule updates (consisting of Schedule, DeactivatedSchedule)
|SC
|-
|Association updates
|AS
|-
|Schedule formations
|SF
|-
|Train order
|TO
|-
|Actual and Forecast Information
|TS
|-
|Loading
|LO
|-
|Station messages
|OW
|-
|Notifications (consisting of TrainAlert, TrackingID, RTTIAlarm)
|NO
|}
Please note that if you choose to filter messages, you will not be able to detect discontinuities in the Darwin feed.
 
= Good Practice =
You should follow the [[Good_Practice|good practice guide]] when using this service.
 
See also [[Darwin:Gotchas|a list of potential gotchas]].
 
= Examples =
Code examples for STOMP clients are available in [https://github.com/openraildata Github].
Code examples for STOMP clients are available in [https://github.com/openraildata Github].


The [[Advanced Uses|advanced usage]] page contains examples of some advanced applications for the data feeds, including bridging the ActiveMQ feeds to your own messaging server.
The advanced usage page contains examples of some advanced applications for the data feeds, including bridging the ActiveMQ  
feeds to your own messaging server.
 
= Version 12 Support =


== Support ==
Push Port v12 is no longer available as of mid-May 2019.


= Support =
If you are having problems with the feeds:
If you are having problems with the feeds:
* First, read this wiki - there's a lot of material here that will help you
* First, read this wiki - there's a lot of material here that will help you
* Check [https://twitter.com/open_rail_feeds twitter] to see if an issue has been reported
* If you want to discuss your problem with other people working with the service, the [https://groups.google.com/d/forum/openraildata-talk openraildata-talk] group on Google Groups will be useful
* If you want to discuss your problem with other people working with the service, the [https://groups.google.com/d/forum/openraildata-talk openraildata-talk] group on Google Groups will be useful
* Finally, if you're still having a problem, email [mailto:darwind3.support@rockshore.net darwind3.support@rockshore.net]
* Finally, if you're still having a problem, email [mailto:dsg_nrdp.support@caci.co.uk dsg_nrdp.support@caci.co.uk]
 
= References =
<references />
 
{{Navtable-NreDataFeeds}}
 
[[Category:National Rail Enquiries Data Feeds]]

Latest revision as of 18:21, 21 November 2023

The Darwin Push Port is an XML push feed that continuously streams information about the creation of, and changes to, train schedule records, together with train running predictions made by Darwin.

The data is made available through http://opendata.nationalrail.co.uk.

The Push Port requires the user to build a database capable of capturing extremely high volumes of information, as well as a query engine to draw the information from your database. There is a large amount of interpretation work involved in this; however this allows substantial flexibility to apply the information to any product within the limitations of your own infrastructure.

Data

The Push Port has two components:

  • Timetable and Timetable Reference Data.
  • Real-Time Update Data.

All Darwin data is gzipped (except for the Darwin Status Topic). XSDs for the interface are available, along with the specification.

Timetable and Timetable Reference Data

Darwin makes available Timetable and Timetable Reference Data exposed as static files that are generated usually on a daily basis. The creation of new Timetable and Timetable Reference files are alerted via TimeTableId messages in the real-time Update Data.

Timetables

Timetable data contains a set of schedules covering at least a 48-hour period held in the Darwin database. This list of schedules provides the basis on which a Darwin snapshot can be applied.

The schedules in the timetable do not include forecast or actual times although they reflect the latest state that Darwin has when the timetable file was generated, so any schedule changes, new schedules, false destinations, cancellations and associations will be included.

Reference Data

The Timetable Reference Data contains the following data referenced in timetables:

Update Data

Darwin makes available real-time updates that alert the user to changes in the state of the Darwin database, or the creation of new Timetable and Timetable Reference Data. Darwin exposes two message topics:

  • Darwin Live Feed Topic
  • Darwin Status Topic

Darwin Live Feed Topic

The live feed topic exposes all update messages. Update messages contain one or more of the following elements:

The Live Feed Topic also exposes TimeTableId messages that alert the creation of a new Timetable or Timetable Reference file.

uR and sR

During normal operation, updates in real-time are issued inside uR elements, but after a period of disconnection between the data platform and Darwin itself, delayed information may enter the feed contained instead inside sR elements. [1]

Status Messages

The Status message topic contains status messages about the health and state of the Update Data. The possible messages are:

HBINIT
The upstream live feed is running but is initialising its timetable.
HBFAIL
The upstream live feed is shutting down.
HBPENDING
The upstream live feed is operating, but part of the system is currently in failover mode. Data may be queued for a short period. Clients may remain connected and data will be delivered when available.
SNAPSHOT
The Darwin Live Feed has encountered a discontinuity of messages from upstream and is starting a snapshot to re-sync it's state.
SHUTTING-DOWN
Darwin is shutting down and the message topics will soon become unavailable.

Usage

Subscribing to Darwin

The Darwin Push Port is made available through http://opendata.nationalrail.co.uk. By creating an account, you can register for a subscription to the Darwin feed.

As a user with an active Darwin subscription, navigating to the My Feeds page will display the following details:

Darwin File Information
This section provides user details for accessing the Timetable and Timetable Reference Data via an Amazon S3 Bucket.
Darwin FTP Information
This section provides user details for accessing snapshots and 5-minute logs of the real-time Update Data via FTP.
Darwin Topic Information
This section provides user details for accessing real-time Update Data via OpenWire and STOMP message topics.

Important - Please note NRDP accounts expire after extended periods of no use. The unused account expiry period is currently set to 30 days. If you create an account and do not consume any of the feeds during this time your account will be deleted. If your account has been deleted, you will receive a notification email, and you will be able to re-register for a new account.

How do I consume the data?

Timetable and Reference Data

Timetable and Reference data can be obtained via an Amazon S3 Bucket. You will be required to connect and authenticate to S3 via the details given in Darwin File Information on your My Feeds page.

The reference data filenames are in the format "yyyymmddnnnnnn_ref_v3.xml.gz" (e.g. "PPTimetable/20230201021854_ref_v3.xml.gz"). There's usually several days of historical reference data, and different versions, so make sure you select the latest one for the right version (v3 is the correct reference data version for v16).

The reference data was previously available via FTP, this is no longer the case.

Keeping up to date

Timetable and Reference Data is updated usually on a daily basis. To indicate that a new Timetable or Timetable Reference file is available, the real-time topic will send a TimeTableId message, to identify the new Timetable or Timetable Reference Data file name.

A separate TimeTableId message will be sent for each individual Timetable or Reference Data file that becomes available. Thus, multiple TimeTableId messages will be generated in succession, one for each Timetable and Reference file schema version.

Note that due to existing schema limitations, the TimeTableId message has mandatory attributes for timetable file and timetable reference data file names. Since the TimeTableId notification message is only reporting the presence of a single file, only one of these attributes will be populated with a valid file name. The other attribute will consist only of white space.

Update Data via FTP

The FTP server provides non real-time Update Data for users that missed the real-time updates. All files are gzipped.

Darwin regularly creates Snapshot files, containing the entire state of Darwin at a given point in time. The latest snapshot file is available over FTP for end users.

Every 5 minutes of Live Feed Data since the last snapshot will be available in log files, and available over FTP.

Real-Time Update Data via OpenWire & Stomp Message Topics

The Darwin Live Feed Topic and Darwin Status Messages Topic are exposed via ActiveMQ, and can be connected to via OpenWire or STOMP. The credentials for connecting can be obtained via your Darwin Topic Information section on your My Feeds page.

If you're using STOMP, you should bear in mind that the message bodies are gzip-compressed, which means selecting a client library which properly supports the content-length header and can handle binary messages is essential. A partial List of STOMP Client Libraries is available to help with this.

STOMP and OpenWire allow durable and non-durable subscriptions. If you would like Darwin to retain messages for you on disconnection, you should use a durable subscription. Please note that message retention is limited, and is implemented to allow for short term subscriber failure, not long term message persistence.

Important: The following must be true when connecting to a Darwin Topic:

  • Watching Advisory Topics must be turned off.
  • If you are using a Durable Subscriber, your Client ID must begin with your username.

Detecting Real-Time Discontinuity

Each Update message contains a SequenceNumber header. The sequence number runs from 0 to 9,999,999. Upon reaching the end of this range the sequence number wraps around to 0.

NRDP guarantees messages are produced with sequential sequence numbers, therefore a missing sequence number indicates a missed message.

For example, if you received the following sequence numbers in order:

   0, 1, 2, 4, 5, 6

Then you have missed the message with sequence number 3.

Filtering

If you wish to, you may filter the Darwin Live Feed by message type using JMS Selectors on the MessageType header. Available message types and their respective codes include:

Description Code
Schedule updates (consisting of Schedule, DeactivatedSchedule) SC
Association updates AS
Schedule formations SF
Train order TO
Actual and Forecast Information TS
Loading LO
Station messages OW
Notifications (consisting of TrainAlert, TrackingID, RTTIAlarm) NO

Please note that if you choose to filter messages, you will not be able to detect discontinuities in the Darwin feed.

Good Practice

You should follow the good practice guide when using this service.

See also a list of potential gotchas.

Examples

Code examples for STOMP clients are available in Github.

The advanced usage page contains examples of some advanced applications for the data feeds, including bridging the ActiveMQ feeds to your own messaging server.

Version 12 Support

Push Port v12 is no longer available as of mid-May 2019.

Support

If you are having problems with the feeds:

  • First, read this wiki - there's a lot of material here that will help you
  • Check twitter to see if an issue has been reported
  • If you want to discuss your problem with other people working with the service, the openraildata-talk group on Google Groups will be useful
  • Finally, if you're still having a problem, email dsg_nrdp.support@caci.co.uk

References


National Rail Enquiries Data Feeds
Data Feeds About the Feeds Darwin Webservice (Public) Darwin Webservice (Staff) Historical Service Performance Push Port KnowledgeBaseDTDLocations (PoC)Real Time Journey Planner
LDB API About
LDB-SV API About
HSP About
DTD About Fares Timetable
Push Port About XML Schemas Schedules Associations Train Status Station Messages Alarms Train Order Train Alerts Formations Formation loading