承接 ufo-tech/rpc-mercure-transport 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ufo-tech/rpc-mercure-transport

最新稳定版本:1.0.0

Composer 安装命令:

composer require ufo-tech/rpc-mercure-transport

包简介

Mercure transport layer for JSON-RPC event broadcasting between services.

README 文档

README

🚀 RpcMercureTransport

Ukraine

Mercure Transport Layer for JSON-RPC-BUNDLE

Adds support for cross-domain events between services via Mercure Hub.

🧬 Idea

This extension for JSON-RPC-BUNDLE allows publishing events from the RPC server to the Mercure Hub and receiving them by other services that are subscribed to the corresponding topics.

This enables building asynchronous event-driven interaction between microservices, without the need for RabbitMQ or other brokers.

License Size package_version fork

Environment Requirements

php_version symfony mercure ufo-tech/rpc-bundle

⚙️ Installation

composer require ufo-tech/rpc-mercure-transport

🔧 Configuration

config/packages/ufo_json_rpc.yaml:

ufo_json_rpc:
  #  ...
  transports:
    async:
      #  ...
      - type: 'mercure'
        config:
          name: 'rpc_socket'
          dsn: '%env(resolve:MERCURE_PUBLIC_URL)%'
          topics_prefix: 'rpc.event.'

🚀 Send a message

If an RpcSocketRequestEvent event is dispatched in the EventDispatcher, the service automatically publishes it to the Mercure Hub.

The library includes syntactic sugar Ufo\RpcMercure\Services\RpcSocketTransport::fireEvent

use Ufo\RpcMercure\Services\RpcSocketTransport;

class SomeService
{
    public function __construct(
        protected RpcSocketTransport $rpcSocketTransport,
    ) {}
    
    public function someMethod(): void
    {
        $this->rpcSocketTransport->fireEvent(
                eventName: 'event.test',
                eventData: [
                    'someKey' => 'some value',
                ]
            ),
        );
    }
}

→ on the Mercure side, this event will be sent to the topic [topics_prefix].request.

Other services in your SOA subscribed to this topic will instantly receive messages via SSE.

📡 Example of subscribing to requests

php bin/console ufo:rpc:socket:consume --topic=request -v
Connect to socket: request                                                                                               


2025-11-19 16:09:30:
>>> {"id":"691debba4a97b","method":"event.test","jsonrpc":"2.0","params":{"$rpc":{"timeout":10,"rayId":"691debba4a97b"}}}

Service "event.test" is not found on RPC Service Map
====================================================================================================

2025-11-19 16:09:30:
>>> {"id":"691debba83412","method":"ping","jsonrpc":"2.0","params":{"$rpc":{"timeout":10,"rayId":"691debba83412"}}}
<<< {"id":"691debba83412","result":"PONG","jsonrpc":"2.0"}


====================================================================================================

2025-11-19 16:09:30:
>>> {"id":"691debba8ef62","method":"Messenger.send","jsonrpc":"2.0","params":{"$rpc":{"timeout":10,"rayId":"691debba8ef62"}}}

Required parameter "message" not passed

📡 Example of subscribing to responses

php bin/console ufo:rpc:socket:consume --topic=response -v
Connect to socket: response                                                                                               

2025-11-19 16:09:30:
{"id":"691debba83412","result":"PONG","jsonrpc":"2.0"}
====================================================================================================
2025-11-19 16:09:30:
{"id":"691debba8ef62","error":"Required parameter "message" not passed","jsonrpc":"2.0"}

🧠 Main idea

  • each RPC service has its own events (domain events)
  • rpc-mercure-transport broadcasts them to the Mercure Hub
  • other services can react to them without direct dependency, just by implementing a method named after the event

🦠 License

MIT © UFO-Tech

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-18