ancashoria / graphql-kafka-subscriptions

Apollo graphql subscriptions over Kafka protocol
MIT License
187 stars 55 forks source link

Nothing coming back from asyncIterator #30

Closed Davenporten closed 4 years ago

Davenporten commented 4 years ago

I'm just trying to test my KafkaPubSub and have a really simple setup:

Resolver

  Subscription: {
    messageCreated: {
      subscribe: () => pubsub.asyncIterator(MESSAGE_CREATED)
    }
  }

Publish

setInterval(() => {
  let r = pubsub.publish({
    channel: MESSAGE_CREATED,
    messageCreated: { id, content: new Date().toString() },
  });

  console.log(r, id)

  id++;
}, 5000);

The publishes are happening and I see no error with them, but even though my subscription is started up in the playground it just listens and nothing ever comes through. I'm not sure if maybe it is something with kafka itself? My configs are

export const KafkaPubSubConfig = {
    topic: <TOPIC>,
    host: <BROKER>,
    port: <PORT>,
    groupId: 'graphql-sub-test',
}

export const PublisherKafkaPubSubConfig = {
    ...KafkaPubSubConfig,
    globalConfig: {

        'security.protocol': 'sasl_ssl',
        'ssl.endpoint.identification.algorithm': 'https',
        'ssl.ca.location': <PATH_TO_CERT>,
        'enable.ssl.certificate.verification': false,
        'ssl.keystore.location': <PATH_TO_KEYSTORE>,
        'ssl.keystore.password': <PASSWORD>,
        'sasl.mechanism': 'GSSAPI',
        'sasl.kerberos.keytab': <PATH_TO_KEYTAB>,
        'sasl.kerberos.principal': <PRINCIPAL>,
        'sasl.kerberos.service.name': <NAME>,
        'group.id': 'librd-test',
    }
}
Davenporten commented 4 years ago

So I figured out that all it was that I needed to be updating the group.id in my tests. Once I started doing that I didn't have a problem.