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);
}
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);
}
Aggregations