Search in sources :

Example 1 with MQPullConsumerScheduleService

use of org.apache.rocketmq.client.consumer.MQPullConsumerScheduleService in project rocketmq-externals by apache.

the class RocketMQSource method open.

@Override
public void open(Configuration parameters) throws Exception {
    LOG.debug("source open....");
    Validate.notEmpty(props, "Consumer properties can not be empty");
    Validate.notNull(schema, "KeyValueDeserializationSchema can not be null");
    this.topic = props.getProperty(RocketMQConfig.CONSUMER_TOPIC);
    this.group = props.getProperty(RocketMQConfig.CONSUMER_GROUP);
    Validate.notEmpty(topic, "Consumer topic can not be empty");
    Validate.notEmpty(group, "Consumer group can not be empty");
    if (offsetTable == null) {
        offsetTable = new ConcurrentHashMap<>();
    }
    if (restoredOffsets == null) {
        restoredOffsets = new ConcurrentHashMap<>();
    }
    runningChecker = new RunningChecker();
    pullConsumerScheduleService = new MQPullConsumerScheduleService(group);
    consumer = pullConsumerScheduleService.getDefaultMQPullConsumer();
    consumer.setInstanceName(String.valueOf(getRuntimeContext().getIndexOfThisSubtask()));
    RocketMQConfig.buildConsumerConfigs(props, consumer);
}
Also used : MQPullConsumerScheduleService(org.apache.rocketmq.client.consumer.MQPullConsumerScheduleService)

Example 2 with MQPullConsumerScheduleService

use of org.apache.rocketmq.client.consumer.MQPullConsumerScheduleService in project rocketmq-externals by apache.

the class RocketMQSourceTest method setUp.

@Before
public void setUp() throws Exception {
    deserializationSchema = new SimpleKeyValueDeserializationSchema();
    Properties props = new Properties();
    rocketMQSource = new RocketMQSource(deserializationSchema, props);
    setFieldValue(rocketMQSource, "topic", topic);
    setFieldValue(rocketMQSource, "runningChecker", new SingleRunningCheck());
    setFieldValue(rocketMQSource, "offsetTable", new ConcurrentHashMap<>());
    setFieldValue(rocketMQSource, "restoredOffsets", new ConcurrentHashMap<>());
    pullConsumerScheduleService = new MQPullConsumerScheduleService("g");
    consumer = mock(DefaultMQPullConsumer.class);
    pullConsumerScheduleService.setDefaultMQPullConsumer(consumer);
    setFieldValue(rocketMQSource, "consumer", consumer);
    setFieldValue(rocketMQSource, "pullConsumerScheduleService", pullConsumerScheduleService);
}
Also used : SimpleKeyValueDeserializationSchema(org.apache.rocketmq.flink.common.serialization.SimpleKeyValueDeserializationSchema) MQPullConsumerScheduleService(org.apache.rocketmq.client.consumer.MQPullConsumerScheduleService) Properties(java.util.Properties) DefaultMQPullConsumer(org.apache.rocketmq.client.consumer.DefaultMQPullConsumer) Before(org.junit.Before)

Aggregations

MQPullConsumerScheduleService (org.apache.rocketmq.client.consumer.MQPullConsumerScheduleService)2 Properties (java.util.Properties)1 DefaultMQPullConsumer (org.apache.rocketmq.client.consumer.DefaultMQPullConsumer)1 SimpleKeyValueDeserializationSchema (org.apache.rocketmq.flink.common.serialization.SimpleKeyValueDeserializationSchema)1 Before (org.junit.Before)1