当前位置: 首页 > 知识库问答 >
问题:

为什么我在处理器中使用“命名查询”。process()方法不起作用-我该怎么修?

云宝
2023-03-14

我在处理器中使用的“命名查询”。process()方法不起作用

--为什么-我该怎么修?

谢谢您的帮助!:-)

这是有问题的“命名查询”的JPA实体。。。

即。,

@NamedQuery(name = "ThingTable.byUpdateTs", query = "SELECT e FROM ThingTable e WHERE e.updateTs > :updateTs")

“命名查询”用于流程方法代码(如下),但不起作用。。。

即。,

@Override
public void process(Exchange msg) throws Exception {
    String firedTime = msg.getIn().getHeader("firedTime", String.class);

    ZonedDateTime zdtnow = ZonedDateTime.parse(firedTime, formatter2);
    zdtnow = zdtnow.withZoneSameInstant(ZoneId.of("America/New_York")); // ...in case springboot server defaults to UTC/GMT time zone...

    ZonedDateTime startZDT = zdtnow.minusMonths(24); //.minusSeconds(65); 
    
    //*********** this is the line of code using the "named query" ********** 
    String pollingQuery="jpa:aaa.bbb.ccc.jar.ThingTable?namedQuery=ThingTable.byUpdateTs&updateTs='" + startZDT.format(formatter) + "'";

    msg.getIn().setBody(pollingQuery);
}

处理器。此驼峰路线中使用了process()方法。。。

即。,

from("timer://pollingTimer?fixedRate=true&period=60000")
        .process(theProcessor::process)
        .toD("${body}")
        .split(body())
        .convertBodyTo(java.lang.String.class, "UTF-8")
        .log("===============>>> NEW MESSAGE: ${body}");  

stacktrace的一个片段描述了错误:

即。,

-
-
-
2020-12-30 23:53:32.191 ERROR 1 --- [://pollingTimer] o.a.c.p.e.DefaultErrorHandler            : Failed delivery for (MessageId: ID-7499dc21186b-1609372412151-0-1 on ExchangeId: ID-7499dc21186b-1609372412151-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa://aaa.bbb.ccc.jar.ThingTable?namedQuery=byUpdateTs&updateTs=%272018-12-30+18%3A53%3A31%27 due to: Failed to resolve endpoint: jpa://aaa.bbb.ccc.jar.ThingTable?namedQuery=byUpdateTs&updateTs=%272018-12-30+18%3A53%3A31%27 due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{updateTs='2018-12-30 18:53:31'}]

Message History (complete message history is disabled)
---------------------------------------------------------------------------------------------------------------------------------------

RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route1            ] [route1            ] [from[timer://pollingTimer?fixedRate=true&period=60000]                        ] [       333]
 ...
[route1            ] [toD1              ] [${body}                                                                       ] [         0]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------


org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jpa://aaa.bbb.ccc.jar.ThingTable?namedQuery=byUpdateTs&updateTs=%272018-12-30+18%3A53%3A31%27 due to: Failed to resolve endpoint: jpa://aaa.bbb.ccc.jar.ThingTable?namedQuery=byUpdateTs&updateTs=%272018-12-30+18%3A53%3A31%27 due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{updateTs='2018-12-30 18:53:31'}]
 at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:876) ~[camel-base-3.3.0.jar!/:3.3.0]
 at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:771) ~[camel-base-3.3.0.jar!/:3.3.0]
 at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:72) ~[camel-support-3.3.0.jar!/:3.3.0]
 at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:114) ~[camel-support-3.3.0.jar!/:3.3.0]
 at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:92) ~[camel-support-3.3.0.jar!/:3.3.0]
 at org.apache.camel.processor.SendDynamicProcessor.resolveEndpoint(SendDynamicProcessor.java:287) ~[camel-base-3.3.0.jar!/:3.3.0]
 at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:155) ~[camel-base-3.3.0.jar!/:3.3.0]
 at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:395) ~[camel-base-3.3.0.jar!/:3.3.0]
 at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148) ~[camel-base-3.3.0.jar!/:3.3.0]
 at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:60) ~[camel-base-3.3.0.jar!/:3.3.0]
 -
 -
 -
 
 

(尝试过apachecamel.apache.org网站,但是,到目前为止,还找不到一个使用参数的示例“命名查询”示例——就像上面我的一样)

例如。,https://camel.apache.org/components/latest/jpa-component.html)

共有1个答案

左丘成天
2023-03-14

您指定了选项updateTs,这不是JPA组件的已知选项。

 类似资料:
  • 问题内容: 在styles.css中,我正在使用媒体查询,这两个查询都使用以下变体: 当我缩小窗口时,这些网站的大小会调整为我希望在常规浏览器(Safari,Firefox)中使用的布局,但是,手机上的移动布局根本无法显示。相反,我只是看到默认的CSS。 谁能指出我正确的方向? 问题答案: 所有这三个都是有用的提示,但看来我需要添加一个元标记: 现在它似乎可以同时在Android(2.2)和iPh

  • 问题内容: 我在这里有点困惑。如果我将变量传递给json_decode,它将不起作用: 第一个回显正确显示了我传递的JSON字符串,例如 第二个回显显示NULL。因此,我从第一个回显中获取了字符串,并编写了以下代码: 你怎么说,它向我展示了正确解码的数组。字符串绝对相同,我什至保留转义字符。也许是问题所在? 问题答案: 看起来您的服务器已启用。无论是将其禁用或运行通过使用它之前。

  • Stage.close()对我不起作用。 我查看了:JavaFX2.0:关闭一个舞台(窗口) 这是我的代码: 下面是调用消息框类的代码:

  • 所以,我的操作系统是Ubuntu 18.04,我下载了Netbeans 11.0。我还安装了openjdk-11和openjfx-11,所以这些都可以在我的电脑上找到。我的问题是,当我想做一个javafx项目时,我会点击文件

  • 我了解碰撞检测的基础,并开发了我自己的碰撞检测方法(据我所知)。然而,这似乎并不奏效。我所做的不是围绕精灵、形状和其他对象绘制完整的矩形,而是简单地在对象的所有边(左、右、上、下)绘制线条(非常细的矩形)。 在指定子画面的左侧、右侧、顶部和底部绘制细矩形的方法。这可能不是进行碰撞的最佳方式,但这就是我所拥有的,并且对所有想法和不同的解决方案持开放态度! 注:(int)(x-Game.getCame