定制 trainjunkies-packages/data-feeds-queue-subscriber 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

trainjunkies-packages/data-feeds-queue-subscriber

Composer 安装命令:

composer require trainjunkies-packages/data-feeds-queue-subscriber

包简介

Subscribe to Network Rail & National Rail data feed queues

README 文档

README

CI

PHP package to consume Open Rail Data feeds from National Rail & Network Rail via Active MQ STOMP. Supports durable connections with server heartbeats.

Installation

via Composer

Install Composer and require the package with the below command.

composer require third-rail-packages/data-feeds-queue-subscriber

Getting Started

National Rail - DARWIN PushPort

Signup to the National Rail Open Data feeds to generate your unique credentials. More information can be found on the Open Rail Data Wiki.

./scripts/national-rail

Network Rail - NROD, TRUST, TD

Signup to the Network Rail Open Data platform to generate a username and password for the feeds. Be sure to activate the Active MQ topics you wish to subscribe to. More information can be found on the Open Rail Data Wiki

Example code can be found in ./scripts/network-rail

Durable Subscription with heartbeats

Below example with request a durable connection with supplied Client ID and ActiveMQ subscription name expecting a heartbeat frame from the server every 20 seconds while emitting one every 5.

<?php // ./trust-durable-example.php

use ThirdRailPackages\QueueSubscriber\NetworkRail\Topics;
use ThirdRailPackages\QueueSubscriber\Stomp\DurableSubscription;
use ThirdRailPackages\QueueSubscriber\Stomp\Message;
use ThirdRailPackages\QueueSubscriber\Stomp\StompClientFactory;

include __DIR__ . '/vendor/autoload.php';

try {
    // Additional arguments can be useed to configure Stomp connection
    $client = StompClientFactory::make(
        'publicdatafeeds.networkrail.co.uk',
        61618,
        'mynrod-email@example.com',
        'S3eC7et'
    );

    // Consult Open Rail Data wiki on Best practice for durable subscriptions
    return new DurableSubscription(
        $client,
        'my-nrod-production'
    );

    $subscription->consume(Topics\Trust::MOVEMENT_ALL, function(Message $message) {
        echo PHP_EOL;
        var_dump(json_decode($message->getBody(), true));
        echo PHP_EOL;
    });
} catch (\Exception $e) {
    echo $e->getMessage() . PHP_EOL;
    // Place sleep(X) here or implement exponential backoff
    exit(1);
}

Development

Copy and complete .env.dist to .env with desired feed credentials.

The development environment and dependencies are managed with Docker. In the same directory as the checked out cloned repository, run the below command to start the Docker Compose environment.

docker-compose up -d --build

Login to the app container begin development.

docker-compose run --rm app sh

Example scripts can be executed inside.

php scripts/network-rail/trust.php

Xdebug has also been installed to debug PHP.

An ActiveMQ container is also present to aid development / debugging. The management interface can be accessed through a browser on http://localhost:8181/admin with the credentials admin & admin.

Authors

See also the list of contributors who participated in this project

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固