graphql-kafka-subscriptions
Apollo graphql subscriptions over Kafka protocol
One producer and one consumer for each node instance. Communication happens over a single kafka topic.
Installation
npm install graphql-kafka-subscriptions
Usage
import { KafkaPubSub } from 'graphql-kafka-subscriptions'
export const pubsub = new KafkaPubSub({
topic: 'anything',
host: 'INSERT_KAFKA_IP',
port: 'INSERT_KAFKA_PORT',
})
With multiple Kafka nodes
export const pubsub = new KafkaPubSub({
topic: 'anything',
host: 'kafka-10.development.foobar.com:9092,kafka-21.development.foobar.com:9092,kafka-22.development.foobar.com:9092',
})
pubsub.publish('messageAdded', {
messageAdded: newMessage,
channelId: message.channelId
});
pubsub.publish({
channel: 'messageAdded',
messageAdded: newMessage,
channelId: message.channelId
});
Special thanks to:
Help greatly appreciated