如何在Java Spring中使Camel PgEvent组件正确使用DataSource。

huangapple go评论70阅读模式
英文:

How to get Camel PgEvent component to use DataSource properly in Java Spring

问题

我正在使用基于Spring Boot的Apache Camel,希望创建一个路由来监听PostgreSQL的通知调用。

  • Camel版本:3.4.4
  • Spring Boot版本:2.3.3

我尝试使用Camel中的PgEvent组件,但发现文档在想要使用DataSource对象填充数据库具体信息(如url、用户名、密码)时相当不足。在stackoverflow上,我既没有找到任何可行的解决方案示例,也没有在其他网站上找到。

以下是我找到的一些有用的来源:

最终,我之前使用的"normal" jdbc:postgresql:/... url并不起作用。因此,我遵循了链接中的stackoverflow答案,建议使用pgjdbc-ng驱动程序(我的同事也提出了同样的建议)。根据第二个链接中的文档,我发现我的Camel路由开始正常工作了。我所需做的就是将之前的DataSource url更改为jdbc:pgsql:/...

希望这能帮助其他遇到类似问题的人。我在解决这个小问题上浪费了太多时间。

英文:

I am using Apache Camel on Spring Boot and want a route to listen to PostgreSQL notify calls.

  • Camel version: 3.4.4
  • Spring Boot version: 2.3.3

I have tried using the PgEvent component from Camel, but have found the documentation quite lacking when you want to use a DataSource object to fill in the database specifics (i.e. url, username, password). I have neither found any examples of working solutions in stackoverflow, nor around the web.

Below are some sources I found helpful:

In the end, the "normal" jdbc:postgresql:/... url I was using did not work. So I followed the linked SO-answer, suggesting using the pgjdbc-ng driver (my colleague suggested the same). Following the documentation of the second link I found that my Camel route started working. All I needed to do was change the previous DataSource url to jdbc:pgsql:/....

Hope this helps other people with similar problems. Wasted all too many hours on this little problem.

答案1

得分: 1

我将自己在问题部分的解决方案复制到答案部分,因为这可能会在问题被标记为已解决时帮助其他人找到解决方案。以下是最终解决方案的副本:

> 最后,“正常”的jdbc:postgresql:/... url在我使用时没有起作用。因此,我遵循了链接的Stack Overflow答案,建议使用pgjdbc-ng驱动器(我的同事也提出了同样的建议)。根据第二个链接的文档,我发现我的Camel路线开始工作了。我所需要做的就是将先前的DataSource url更改为jdbc:pgsql:/...。

英文:

I'm copying my own solution from the question into the answer section, as it may help others find the solution when the question is marked solved. Below is the copy of the final solution:

> In the end, the "normal" jdbc:postgresql:/... url I was using did not
> work. So I followed the linked SO-answer, suggesting using the
> pgjdbc-ng driver (my colleague suggested the same). Following the
> documentation of the second link I found that my Camel route started
> working. All I needed to do was change the previous DataSource url to
> jdbc:pgsql:/....

huangapple
  • 本文由 发表于 2020年10月20日 20:19:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/64445026.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定