package org.springblade;

import lombok.extern.slf4j.Slf4j;
import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.rabbitmq.RMQSource;
import org.springblade.sink.mongodb.MongoSink;
import org.springblade.utils.RabbitUtils;


@Slf4j
public class StreamingJob {

	public static void main(String[] args) throws Exception {

		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		final DataStream<String> stream = env
			.addSource(new RMQSource<String>(
				RabbitUtils.getRMQConnectionConfig(),
				"LogDirectQueue",
				true,
				new SimpleStringSchema()))
			.setParallelism(1);

		stream.addSink(new MongoSink());
		stream.print("demo");
		env.execute("job");
	}
}
