這篇短文源於解決版本兼容性問題. 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...