camel <to uri> 发送字符串

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

camel <to uri> sending string

问题

I would like to send string which presents column name and after there is sql to get data then send all on csv.
我的目标是在CSV上有列标题。

I know that there is camel csv option to output column header but any of option worked for me so i try to send string before the data written on CSV.
我知道有骆驼CSV选项可以输出列标题,但其中任何选项都对我不起作用,所以我尝试在将数据写入CSV之前发送字符串。

I would like to know if i can send String to camel csv ? if yes, could you please advise me how ?
我想知道是否可以将字符串发送到骆驼CSV?如果可以,你能告诉我如何做吗?

XML

<to uri="bean:testImpl?method=columnHeader()" />
<to uri="sql:{{order.query}}?dataSource=orderDataSource" />
<marshal>
    <csv delimiter=";" />
</marshal>

Java testImpl.class

public String columnHeader() {
    return "header1;header2;header3;header4;header5;header6;header7";
}

I tried like this but the program doesn't recognize the method columnHeader in testImpl.class

error: org.apache.camel.component.bean.MethodNotFoundException: Method with name: columnHeader() not found on bean

Thank you for your help.感谢你的帮助。

英文:

I would like to send string which presents column name and after there is sql to get data then send all on csv.
My goal is to have column header on csv.

I know that there is camel csv option to output column header but any of option worked for me so i try to send string before the data written on CSV.

I would like to know if i can send String to camel csv ? if yes, could you please advise me how ?

XML

&lt;to uri=&quot;bean:testImpl?method=columnHeader()&quot; /&gt;
&lt;to uri=&quot;sql:{{order.query}}?dataSource=orderDataSource&quot; /&gt;
&lt;marshal&gt;
	&lt;csv delimiter=&quot;;&quot; /&gt;
&lt;/marshal&gt;

Java testImpl.class

public String columnHeader() {
	return &quot;header1;header2;header3;header4;header5;header6;header7&quot;;
}

I tried like this but the programe doesn't recognize the method columnHeader in testImpl.class

error : org.apache.camel.component.bean.MethodNotFoundException: Method with name: columnHeader() not found on bean

Thank you for you help

答案1

得分: 0

你的Java类真的是一个Camel(或Spring)Bean吗?对于在Camel路由中使用Bean,它们必须在上下文中注册为Bean。

在Spring中,可以通过@Component注解或通过Java或XML配置Bean来实现这一点。

英文:

Is your Java class really a Camel (or Spring) Bean? For the use of Beans in a Camel Route, they must be registered Beans in the Context.

In Spring this can be achieved with the @Component annotation or by configuring the Bean with Java or XML.

huangapple
  • 本文由 发表于 2020年8月12日 19:59:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/63376078.html
匿名

发表评论

匿名网友

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

确定