IN
- public class RMQSink<IN> extends RichSinkFunction<IN>
SinkFunction.Context<T>
Modifier and Type | Field and Description |
---|---|
protected com.rabbitmq.client.Channel |
channel |
protected com.rabbitmq.client.Connection |
connection |
protected String |
queueName |
protected SerializationSchema<IN> |
schema |
Constructor and Description |
---|
RMQSink(RMQConnectionConfig rmqConnectionConfig,
String queueName,
SerializationSchema<IN> schema) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Tear-down method for the user code.
|
void |
invoke(IN value)
Called when new data arrives to the sink, and forwards it to RMQ.
|
void |
open(Configuration config)
Initialization method for the function.
|
void |
setLogFailuresOnly(boolean logFailuresOnly)
Defines whether the producer should fail on errors, or only log them.
|
protected void |
setupQueue()
Sets up the queue.
|
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invoke
protected final String queueName
protected transient com.rabbitmq.client.Connection connection
protected transient com.rabbitmq.client.Channel channel
protected SerializationSchema<IN> schema
public RMQSink(RMQConnectionConfig rmqConnectionConfig, String queueName, SerializationSchema<IN> schema)
rmqConnectionConfig
- The RabbitMQ connection configuration RMQConnectionConfig
.queueName
- The queue to publish messages to.schema
- A SerializationSchema
for turning the Java objects received into bytesprotected void setupQueue() throws IOException
IOException
public void setLogFailuresOnly(boolean logFailuresOnly)
logFailuresOnly
- The flag to indicate logging-only on exceptions.public void open(Configuration config) throws Exception
RichFunction
The configuration object passed to the function can be used for configuration and initialization. The configuration contains all parameters that were configured on the function in the program composition.
public class MyMapper extends FilterFunction<String> {
private String searchString;
public void open(Configuration parameters) {
this.searchString = parameters.getString("foo");
}
public boolean filter(String value) {
return value.equals(searchString);
}
}
By default, this method does nothing.
open
in interface RichFunction
open
in class AbstractRichFunction
config
- The configuration containing the parameters attached to the contract.Exception
- Implementations may forward exceptions, which are caught by the runtime. When the
runtime catches an exception, it aborts the task and lets the fail-over logic
decide whether to retry the task execution.Configuration
public void invoke(IN value)
value
- The incoming datapublic void close()
RichFunction
This method can be used for clean up work.
close
in interface RichFunction
close
in class AbstractRichFunction
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.