python连接kafka生产者,消费者脚本

# -*- coding: utf-8 -*-

'''''
    使用kafka-Python 1.3.3模块
    # pip install kafka==1.3.5
    # pip install kafka-python==1.3.5
'''

import sys
import time
import json

from kafka import KafkaProducer
from kafka import KafkaConsumer
from kafka.errors import KafkaError


KAFAKA_HOST = "101.236.51.235"
KAFAKA_PORT = 9092
KAFAKA_TOPIC = "test"


class Kafka_producer():
    '''''
    生产模块:根据不同的key,区分消息
    '''

    def __init__(self, kafkahost,kafkaport, kafkatopic, key):
        self.kafkaHost = kafkahost
        self.kafkaPort = kafkaport
        self.kafkatopic 

你可能感兴趣的:(python连接kafka生产者,消费者脚本)