DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Integrating Apache Doris and Hudi for Data Querying and Migration
  • Problem Analysis in Apache Doris StreamLoad Scenarios
  • Lakehouse: Starting With Apache Doris + S3 Tables
  • An Overview of Asynchronous Processing in Salesforce

Trending

  • Unlocking AI Coding Assistants Part 1: Real-World Use Cases
  • How to Practice TDD With Kotlin
  • Understanding Java Signals
  • Doris: Unifying SQL Dialects for a Seamless Data Query Ecosystem
  1. DZone
  2. Data Engineering
  3. Data
  4. Real-Time Transit Feed Data Processing With Apache NiFi

Real-Time Transit Feed Data Processing With Apache NiFi

Ingesting and processing real-time transit feeds at scale with Apache NiFi.

By 
Tim Spann user avatar
Tim Spann
DZone Core CORE ·
Aug. 26, 19 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
13.7K Views

Join the DZone community and get the full member experience.

Join For Free

GTFS Real-Time Streaming With Apache NiFi

To facilitate ingesting GTFS Real-Time data, I have added a processor that converts GTFS (General Transit Feed Specification) formatted ProtoBuf data into JSON. This is using the standard Google APIs to accomplish this. You can see the Protocol Buffers schema here.

We will be able to get data on trip updates including delays and service alerts, including changed routes and vehicle positions that can have location and congestion information. This is the same information that these public transit systems feed to Google Maps.

An Example NiFi Flow for Accessing GTFS Data

First, we add my new NiFi Processor, which you can get as a source and build the NAR. Or download one of the release builds of my new NiFi NAR archive. This is alpha-level code done very quickly. If you find bugs, please report and suggest updates.

Once it is added to your canvas, you can change the name and scheduling.

The only setting currently is the URL of the GTFS resource (which may require a key from some transportation APIs).

Once it runs, it will quickly return a flow file containing a JSON-formatted version of the GTFS result, as well as some attributes with GTFS information.

The JSON code has a lot of arrays and subsections, not very flat. We could dump this raw to Hive and query it as a JSON document. Or, we can parse it with FlattenJSON, EvaluateJSONPath, SplitJson, or various other options.

As mentioned before, the main sections are tripUpdate, vehicle, and alerts. I will parse this and use this for real-time Slack, Kafka, HBase, and Kudu messaging. This data can become critical to companies that have trucks or people trying to navigate systems.

My first use case is to see if I can find out this data real-time during a time of emergency or events to help communities. Non-profit agents will be able to have real-time status reports of what transportation is available. You have to ingest, cleanse, and transform data to become knowledge and that can empower the community.

Join me in Puerto Rico at the NetHope Global Summit.

Source Code

https://github.com/tspannhw/gtfs/

Nar Release to Install in Apache NiFi 1.9.2

https://github.com/tspannhw/gtfs/releases

Resources

  • https://cdn.mbta.com/realtime/TripUpdates.pb
  • https://cdn.mbta.com/realtime/VehiclePositions.pb
  • https://cdn.mbta.com/realtime/Alerts.pb
  • https://www.mbta.com/developers/gtfs-realtime
  • https://github.com/CUTR-at-USF/gtfs-realtime-validator
Data processing Apache NiFi

Opinions expressed by DZone contributors are their own.

Related

  • Integrating Apache Doris and Hudi for Data Querying and Migration
  • Problem Analysis in Apache Doris StreamLoad Scenarios
  • Lakehouse: Starting With Apache Doris + S3 Tables
  • An Overview of Asynchronous Processing in Salesforce

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!