如何解决如何使用Kafka集成在Spring Batch中调用StepExcecutionListener?
下面是etl.xml中job的配置
<batch:step id="Produce">
<batch:partition partitioner="partitioner">
<batch:handler grid-size="${ partitioner.limit}"></batch:handler>
<batch:step>
<batch:tasklet>
<batch:chunk reader="Reader" writer="kafkaProducer"
commit-interval="20000">
</batch:chunk>
<batch:listeners>
<batch:listener ref="producingListener" />
</batch:listeners>
</batch:tasklet>
</batch:step>
</batch:partition>
</batch:step>
:job>
ListenableFuture
listenableFuture.addCallback(new ListenableFutureCallback
@Override
public void onSuccess(SendResult<String,message > result) {
log.info("marking as SUCCESS");
manager.updateStatus(“soMetable”,KafkaResponse.SUCCESS);
}
@Override
public void onFailure(Throwable ex) {
log.info("marking as FAILURE");
manager.updateKafkaStatus(soMetable,KafkaResponse.FAILURE);
}
}
执行kafkaTemplate.send(message)后,将调用侦听器并完成作业。我看到了 在作业完成后调用onSuccess(),onFailure()。 我如何更改job的配置,以便在收到来自kafka主题的确认后调用监听器?
解决方法
您是否想举一些示例代码,说明您建议阻止等待未来。可能会有帮助。
我没有尝试以下方法,但这是一个主意:
@for (var i = 0; i < Model.Addresses.Count; i++)
{
using (Html.BeginHtmlFieldPrefixScope(string.Format("Addresses[{0}]",i)))
{
@Html.Partial(MVC.Shared.Views._Address,Model.Addresses[i])
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。