flink读取rabbitmq数据

  • 1.所需依赖
 <dependency>
      <groupId>org.apache.flink</groupId>
      <artifactId>flink-connector-rabbitmq_2.11</artifactId>
      <version>1.9.0</version>
    </dependency>
  • 2.获取RMQSource
  public static RMQSource<String> getRMQSource() {
        final RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder()
                .setHost("localhost")
                .setVirtualHost("/")
                .setPort(5672)
                .setUserName("guest")
                .setPassword("guest")
                .build();
        return new RMQSource<String>(
                connectionConfig,   // rabbitmq连接的配置
                "tutu",  // rabbitmq的队列名,消费的队列名
                true,    // 使用相关编号,至少一次时设置为false
                new SimpleStringSchema());// 反序列化成java的对象
    }

你可能感兴趣的:(flink学习)