Beispiel #1
0
        private StreamPipelineWrapper CreateStreamPipelineWrapper()
        {
            StreamPipelineWrapper ForKafka()
            {
                var client = new KafkaStreamClient(KafkaConfigForSample.BrokerList);
                var topic  = client.StreamTopic(TopicConfiguration.Topic).Into(streamId => ProcessStream(streamId, dataFormatClient));

                return(new StreamPipelineWrapper(client, topic));
            }

            StreamPipelineWrapper ForMqtt()
            {
                var client = new MqttStreamClient(MqttConnectionConfigForSample.Current);
                var topic  = client.StreamTopic(TopicConfiguration.Topic).Into(streamId => ProcessStream(streamId, dataFormatClient));

                return(new StreamPipelineWrapper(client, topic));
            }

            switch (Configuration.SelectedTransport)
            {
            case StreamingTransport.Kafka:
                return(ForKafka());

            case StreamingTransport.Mqtt:
                return(ForMqtt());

            default:
                throw new NotSupportedException();
            }
        }
        private OutputTopicWrapper CreateOutputTopicWrapper()
        {
            OutputTopicWrapper ForKafka()
            {
                var client = new KafkaStreamClient(KafkaConfigForSample.BrokerList);
                var topic  = client.OpenOutputTopic(TopicConfiguration.Topic);

                return(new OutputTopicWrapper(client, topic));
            }

            OutputTopicWrapper ForMqtt()
            {
                var client = new MqttStreamClient(MqttConnectionConfigForSample.Current);
                var topic  = client.OpenOutputTopic(TopicConfiguration.Topic);

                return(new OutputTopicWrapper(client, topic));
            }

            switch (Configuration.SelectedTransport)
            {
            case StreamingTransport.Kafka:
                return(ForKafka());

            case StreamingTransport.Mqtt:
                return(ForMqtt());

            default:
                throw new NotSupportedException();
            }
        }
 public MqttStreamAdapter(MqttConnectionConfig config)
 {
     client = new MqttStreamClient(config);
 }