Apache camel 未调用camel jpa@consumered
我试图在jpa实体上使用@Consumed和camel 这是我的路线:Apache camel 未调用camel jpa@consumered,apache-camel,Apache Camel,我试图在jpa实体上使用@Consumed和camel 这是我的路线: <route id="incomingFileHandlerRoute"> <from uri="jpa://com.menora.inbal.incomingFileHandler.Jpa.model.MessageToDB?consumer.nativeQuery=select * from file_message where mstatus = 'TODO'&cons
<route id="incomingFileHandlerRoute">
<from
uri="jpa://com.menora.inbal.incomingFileHandler.Jpa.model.MessageToDB?consumer.nativeQuery=select
* from file_message where mstatus = 'TODO'&consumer.delay=5000&consumeDelete=false&consumeLockEntity=true&consumer.SkipLockedEntity=true" />
<to uri="bean:incomingFileHandler" />
</route>
我确实从db获得了incomingFileHandler bean的结果,但我没有获得已使用的方法updateStatus。incomingFileHandler bean不断被调用,因为总是有来自db的结果,我有一个类似的实现,在实体中使用camel jpa和注解
@consumered
和@preconsumerd
,但没有调用这些方法
我查看了camel jpa源代码,并在JpaConsumer.java中找到了这一点:
protected DeleteHandler<Object> createPreDeleteHandler() {
// Look for @PreConsumed to allow custom callback before the Entity has been consumed
final Class<?> entityType = getEndpoint().getEntityType();
if (entityType != null) {
// Inspect the method(s) annotated with @PreConsumed
受保护的DeleteHandler createPreDeleteHandler(){
//查找@preconsume以允许在使用实体之前进行自定义回调
最终类entityType=getEndpoint().getEntityType();
if(entityType!=null){
//检查带有@presumed注释的方法
如果entityType
为null
,实体类inst将检查用@consumered
和@presumerd
注释的方法
解决方案:将
entityType=com.xx.yy.MessageToDB
添加到您的URI以设置端点实体类型。我在实体中有一个类似的实现,包括camel jpa和注释@Consumed
和@PreConsumed
,但没有调用这些方法
我查看了camel jpa源代码,并在JpaConsumer.java中找到了这一点:
protected DeleteHandler<Object> createPreDeleteHandler() {
// Look for @PreConsumed to allow custom callback before the Entity has been consumed
final Class<?> entityType = getEndpoint().getEntityType();
if (entityType != null) {
// Inspect the method(s) annotated with @PreConsumed
受保护的DeleteHandler createPreDeleteHandler(){
//查找@preconsume以允许在使用实体之前进行自定义回调
最终类entityType=getEndpoint().getEntityType();
if(entityType!=null){
//检查带有@presumed注释的方法
如果entityType
为null
,实体类inst将检查用@consumered
和@presumerd
注释的方法
解决方案:将
entityType=com.xx.yy.MessageToDB
添加到您的URI中以设置端点实体类型。只是一个观察:选项consumer.SkipLockedEntity
应该是小写的Skip,例如consumer.SkipLockedEntity
您使用哪种版本的驼峰,以及您的路线下一步做什么?可以尝试使用一个简单的路由,只需要从->日志。你也可以尝试在@consumerd
方法中设置一个断点,看看它是否被调用,或者在那里添加一些日志记录等等。我使用的是2.19.1。我在@consumerd方法中设置了断点,但它没有被调用。我删除了consumer.SkipLockedEntity-它没有改变我编辑路由:可能是你的bean会导致异常。请尝试调试该部分。只是观察:选项consumer.skiplocketdentity
应该是小写的Skip,例如consumer.skiplocketdentity
您使用哪种版本的Camel,以及您的路由下一步要做什么?可能尝试使用一个简单的路由,只需执行from->log。您还可以尝试设置一个breakpo在@consumerd
方法中输入int,然后查看是否调用了它,或者在那里添加一些日志记录等。我使用的是2.19.1。我在@consumerd方法中放置了断点,但它没有被调用。我删除了consumer.SkipLockedEntity-它没有更改我编辑路由:可能是您的bean导致了异常。请尝试调试该部分。但为什么要这样做呢是否为空?我在文档中看到:entityType entityClassName覆盖URI中的entityClassName。我说的是它不能为空。是的,但我不明白它何时为空?我在代码中发送它:jpa://com.menora.inbal.incomingFileHandler.Jpa.model.MessageToDBYou 必须更改为:jpa://com.menora.inbal.incomingFileHandler、 Jpa.model.MessageToDB?entityType=com.menora.inbal.incomingFileHandler.Jpa.model.MessageToDB&…是的,好的,但这很奇怪,因为文档没有这样说,但为什么它应该为null?我在文档中看到:entityType entityClassName从URI重写entityClassName。我说的是它不能为null。是的,但我不明白它何时为null?我在代码中发送它:jpa://com.menora.inbal.incomingFileHandler.Jpa.model.MessageTodBy您必须更改为:jpa://com.menora.inbal.incomingFileHandler.Jpa.model.MessageToDB?entityType=com.menora.inbal.incomingFileHandler.Jpa.model.MessageToDB&…是的,好吧,但这很奇怪,因为文档中没有这样说