简体   繁体   中英

Flink RMQSource

I want to test RMQSource class for receiving data from RabbitMQ, but i don´t know how to config the Rabbit virtual host for my exchange, and i think is the problem i have. My code:

import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.streaming.connectors.rabbitmq.RMQSource
import org.apache.flink.streaming.util.serialization.SimpleStringSchema

object rabbitjob {
  val env = StreamExecutionEnvironment.getExecutionEnvironment
  val stream = env.addSource(new RMQSource[String]("192.168.1.11", 5672,"user","pass", "inbound.input.data",false, new SimpleStringSchema())).print


def main (args:Array[String]){
    env.execute("Test Rabbit")
 }
} 

Error in IntelliJ IDE: Error:(10, 29) could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String] val stream = env.addSource(new RMQSource[String]("192.168.1.11", 5672,"user","pass", "inbound.input.data",false, new SimpleStringSchema())).print

^

Error:(10, 29) not enough arguments for method addSource: (implicit evidence$7: org.apache.flink.api.common.typeinfo.TypeInformation[String])org.apache.flink.streaming.api.scala.DataStream[String]. Unspecified value parameter evidence$7. val stream = env.addSource(new RMQSource[String]("192.168.1.11", 5672,"user","pass", "inbound.input.data",false, new SimpleStringSchema())).print

^

Any idea how to solve it or alternatives?? Thank you in advance.

Things changed over time. Please have a look at RMQConnectionConfig : here you can find the way to specify a virtual host through builder pattern.

You need to provide the vhost name as well. Take a look at AMQP URI spec .

In your case the whole AMQP URI would look like would be "user:pass@192.168.1.11:5672/TestVHost" .

The error you're seeing is a Scala compile time error caused by some needed imports not being there. Whenever you are using the Flink Scala API you should include the following:

import org.apache.flink.api.scala._

This will solve the compile time problem you're having.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM