Giter Club home page Giter Club logo

stomp-client-python's Introduction

National Rail Open Data Python Example

This repository contains an Python 3 example of how to use the Darwin v16 messages from the National Rail Open Data platform, located at the following URL:

To use this service, you will need to sign up for a free account and subscribe to the 'Darwin' feed.

Configuration

Edit opendata-nationalrail-client.py and set the USERNAME, PASSWORD, HOSTNAME and HOSTPORT variables to the values shown in 'Username', 'Password', 'Messaging host' and 'STOMP Port' on the 'My Feeds' page.

Leave CLIENT_ID set to socket.getfqdn() - this will use the hostname of your client for the durable subscription. You may need to change this to something else if you want to fail over the subscription to a different client. In this case, you could use your username.

The HEARTBEAT_INTERVAL_MS is set by default to 15 seconds (15,000ms) - this should be sufficient for almost every application. Don't change it unless you have a good reason to do so.

RECONNECT_DELAY_SECS will enforce a 15-second delay before exiting. This will let you run the client in a loop, such as through a shell script, and protect against you accidentally degrading the service for everyone by reconnecting far too frequently.

Finally, install the required dependencies by running pip install stomp.py pyxb.

Generating classes

The messages are produced in XML format, and a good way to consume them is by using generated classes with PyXB.

pyxbgen --schema-root=ppv16 --module PPv16 rttiPPTSchema_v16.xsd

Running the code

The opendata-nationalrail-client.py script will show the raw message body and print the timestamp from the parsed XML through the classes generated by PyXB.

Support

For support and questions with using Darwin, please use the forum at the following URL:

stomp-client-python's People

Contributors

poggs avatar codebox avatar ignoredambience avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.