We are trying to refresh the sideinput at a certain interval in a streaming dataflow job. Followed this link https://beam.apache.org/documentation/patterns/side-inputs/ But not able to achieve it syntactically also right. Can someone help with the right way of implementing sideinput refresh for the below piece of code?
PCollection<KV<String, String>> updateVariable = pipeline.apply(JdbcIO.<KV<String, String>>read()
.withDataSourceConfiguration(JdbcIO.DataSourceConfiguration
.create("com.mysql.jdbc.Driver", "jdbc:mysql://" + sqlIp + "/" + sqlDb).withUsername(sqlUser)
.withPassword(sqlPwd))
.withQuery(
"select * from OBD_LOOKUP")
.withCoder(KvCoder.of(StringUtf8Coder.of(), StringUtf8Coder.of()))
.withRowMapper(new JdbcIO.RowMapper<KV<String, String>>() {
@Override
public KV<String, String> mapRow(java.sql.ResultSet resultSet) throws Exception {
/ TODO Auto-generated method stub
return KV.of(resultSet.getString(1), resultSet.getString(2));
}
}));
final PCollectionView<Map<String, String>> lookupCollection = updateVariable
.apply("Assign into Global Window",
Window.<KV<String, String>>into(new GlobalWindows())
.triggering(Repeatedly.forever(AfterProcessingTime.pastFirstElementInPane()))
.accumulatingFiredPanes())
.apply("SideInputViewFormed", View.<String, String>asMap());
PCollection<String> resultnew = result
.apply(ParDo.of(new ObdLookUpSideInput(lookupCollection)).withSideInputs(lookupCollection));