这篇短文源于解决版本兼容性问题. graphql-rabbitmq-subscriptions 这项目已经半年没有Commit了, 和最新的 graphql-subscriptions 有兼容性问题. 最新的 graphql-subscriptions 的GraphQL订阅使用了 AsyncIterator
, PubSubEngine
增长了一个新的接口asyncIterator
, 以下:git
export interface PubSubEngine { publish(triggerName: string, payload: any): boolean; subscribe(triggerName: string, onMessage: Function, options: Object): Promise<number>; unsubscribe(subId: number): any; asyncIterator<T>(triggers: string | string[]): AsyncIterator<T>; }
左边开两个GraphiQL的窗口, 右侧登陆 rabbitmqadmin 图形管理界面. http://localhost:15672, 找到下面这个Exchange:github
点击进入 http://localhost:15672/#/exch...async
而后就能够这样发消息了spa
顺带发一个能跑的DEMO: https://github.com/developerw...code
这里是修改的版本: https://github.com/developerw... 对 graphql-rabbitmq-subscriptions 作了修改, 使其支持以下接口:server
asyncIterator<T>(triggers: string | string[]): AsyncIterator<T>;
RabbitMQ 默认安装, 不作任何修改. Ubuntu 下的安装命令为 apt-get install rabbitmq-server
接口
Github Issue:
https://github.com/cdmbase/gr...rabbitmq
2017-09-09:
1.https://github.com/developerw...
使用 rabbitmq-pub-sub
的 RabbitMqSingletonConnectionFactory
替换RabbitMqConnectionFactory
,不然不会重用链接, 而且建立生大量的Queueip
2017-09-10:
如今graphql-rabbitmq-subscriptions
包的兼容性已经修复, 直接yarn add graphql-rabbitmq-subscriptions
便可.get
Pull Request
: https://github.com/cdmbase/gr...