Package org.apache.pulsar.io.core
Interface SourceContext
- All Superinterfaces:
BaseContext
Interface for a source connector providing information about environment where it is running.
It also allows to propagate information, such as logs, metrics, states, back to the Pulsar environment.
-
Method Summary
Modifier and TypeMethodDescriptionGet the output topic of the source.org.apache.pulsar.common.io.SourceConfigGet the source config.The name of the source that we are executing.<T> org.apache.pulsar.client.api.ConsumerBuilder<T>newConsumerBuilder(org.apache.pulsar.client.api.Schema<T> schema) Create a ConsumerBuilder with the schema.<T> org.apache.pulsar.client.api.TypedMessageBuilder<T>newOutputMessage(String topicName, org.apache.pulsar.client.api.Schema<T> schema) New output message using schema for serializing to the topic.Methods inherited from interface org.apache.pulsar.functions.api.BaseContext
deleteState, deleteStateAsync, getCounter, getCounterAsync, getInstanceId, getLogger, getNamespace, getNumInstances, getPulsarClient, getPulsarClientBuilder, getSecret, getState, getStateAsync, getStateStore, getStateStore, getTenant, incrCounter, incrCounterAsync, putState, putStateAsync, recordMetric
-
Method Details
-
getSourceName
String getSourceName()The name of the source that we are executing.- Returns:
- The Source name
-
getOutputTopic
String getOutputTopic()Get the output topic of the source.- Returns:
- output topic name
-
getSourceConfig
org.apache.pulsar.common.io.SourceConfig getSourceConfig()Get the source config.- Returns:
- source config
-
newOutputMessage
<T> org.apache.pulsar.client.api.TypedMessageBuilder<T> newOutputMessage(String topicName, org.apache.pulsar.client.api.Schema<T> schema) throws org.apache.pulsar.client.api.PulsarClientException New output message using schema for serializing to the topic.- Type Parameters:
T-- Parameters:
topicName- The name of the topic for output messageschema- provide a way to convert between serialized data and domain objects- Returns:
- the message builder instance
- Throws:
org.apache.pulsar.client.api.PulsarClientException
-
newConsumerBuilder
<T> org.apache.pulsar.client.api.ConsumerBuilder<T> newConsumerBuilder(org.apache.pulsar.client.api.Schema<T> schema) throws org.apache.pulsar.client.api.PulsarClientException Create a ConsumerBuilder with the schema.- Type Parameters:
T-- Parameters:
schema- provide a way to convert between serialized data and domain objects- Returns:
- the consumer builder instance
- Throws:
org.apache.pulsar.client.api.PulsarClientException
-