Skip to content

ayeshLK/weather-reporter

Repository files navigation

Weather Reporter

The project contains a Websub-compliant hub implementation which acts as a weather alerts distribution hub. News channels that need to receive weather alerts for a particular location can subscribe to the hub and receive periodic weather alerts. The hub uses Open Weather Map API to retrieve weather reports for a given location.

Following is the high-level component diagram for this implementation.

drawing

Implementation

As depicted in the component diagram, the implementation is backed by the Apache Kafka message broker. Therefore, the Apache Kafka message broker will be doing most of the heavy lifting.

The following flow diagram depicts the notification dispatching flow with the Apache Kafka integration.

drawing

According to the flow diagram, there are two components, namely Notification Sender and Notification Receiver available within the hub. The Notification Sender component periodically publishes weather reports into a Kafka topic. The Notification Receiver component listens to the Kafka topic and upon receiving an event, it forwards the message to the News Receiver (News channel). Each Notification Receiver component is directly associated with a corresponding News Receiver and each Notification Sender is directly associated with a particular location for which the weather reports are generated.

The diagram below illustrates how the components within the hub are mapped to Kafka topics and consumer groups.

drawing

As every Notification Sender is linked to a location, a corresponding Kafka topic will be assigned to each location. Additionally, since each Notification Receiver is connected to a News Receiver, a unique Kafka consumer group will be allocated to every Notification Receiver.

Usage

This section discusses how to set up and run the deployment of the weather reporter hub.

Setting up Apache Kafka

Refer to Apache Kafka Quickstart guide for the instruction on setting up a Kafka server on your local machine.

Starting the Hub

  1. Get the API_KEY from Open Weather Map and set up OPEN_WEATHER_APP_KEY environment variable.
export OPEN_WEATHER_APP_KEY="xxxx"
  1. Go into weather-reporter-hub directory.
cd weather-reporter-hub
  1. Execute the following command to build the hub project.
bal build
  1. Execute the following command to run the hub.
bal run target/bin/weather_reporter.jar

Subscribing to the weather notifications

  1. Go into examples/subscriber directory.
cd examples/subscriber
  1. Execute the following command to build the sample news receiver.
bal build news_receiver.bal
  1. Execute the following command to run the sample news receiver.
bal run news_receiver.jar

Releases

No releases published

Packages

No packages published