You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by haykz <hz...@gmail.com> on 2010/12/27 16:18:31 UTC
Problem with setting message
Hi everyone.
I am dealing with issue tracing route and got some problems.
My Camel routing is done by spring configuration.
The idea is the following. I need to be able to trace some route – saying to
write down in DB when has message last time passed through this route.
I have created processor which has private “Date lastMessageDate” field.
And saving the last date
public void process(Exchange exchange) throws Exception {
this.lastMessageDate = new Date();
}
In the route which I need to be traced I add processor
<process ref="routeTracer "/>
Added this bean to my Sping Context
<bean id="routeTracer" class=" util.MessageDateProcessor">
<property name="routeName" value="route1"/>
</bean>
And I started route with timer which periodically send message to my
routeTracer bean method retrieve the lastMessageDate data and send it to sql
endpoint
<route>
<from ref="timer://foo?fixedRate=true&period=5000"/>
<to uri="bean:routeTracer?method=setLastMessageDate"/>
<to uri="sql:insert into RouteTrace (route_name,
last_passing_date) values (#,#)?dataSourceRef=myDS"/>
</route>
The problem is that I get error
, BodyType:null
, Body:Message: [Body is null]
, CaughtExceptionType:org.springframework.jdbc.UncategorizedSQLException,
CaughtExceptionMessage:PreparedStatementCallback; uncategorized SQLException
for SQL [
insert into RouteTrace (route_name, last_passing_date) values (?, ?)]; SQL
state [null]; error code [0]; Number of parameters mismatch. Expected: 2,
was:0; nested exception is java.sql.SQLException: Number of parameters
mismatch. Expected: 2, was:0] {logger}
It seems the message isn’t sent to the bean:routeTracer(<to
uri="bean:routeTracer?method=setLastMessageDate"/> )
Can someone help me to understand what I am doing wrong?
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-setting-message-tp3319402p3319402.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problem with setting message
Posted by haykz <hz...@gmail.com>.
Sure William
here is my entire class
public class MessageDateProcessor implements Processor{
private Date lastMessageDate;
private String routeName;
public String getRouteName() {
return routeName;
}
public void setRouteName(String routeName) {
this.routeName = routeName;
}
public void process(Exchange exchange) throws Exception {
this.lastMessageDate = new Date();
}
public void processLastMessageDate(Exchange exchange) throws Exception{
List messageList = new ArrayList();
messageList.add(this.routeName);
messageList.add(this.lastMessageDate);
exchange.getOut().setBody(messageList);
}
}
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-setting-message-tp3319402p3320048.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problem with setting message
Posted by Willem Jiang <wi...@gmail.com>.
Can I have a look at the method of setLastMessageData ?
Willem
On 12/27/10 11:18 PM, haykz wrote:
>
> Hi everyone.
>
> I am dealing with issue tracing route and got some problems.
> My Camel routing is done by spring configuration.
> The idea is the following. I need to be able to trace some route – saying to
> write down in DB when has message last time passed through this route.
> I have created processor which has private “Date lastMessageDate” field.
> And saving the last date
> public void process(Exchange exchange) throws Exception {
> this.lastMessageDate = new Date();
> }
> In the route which I need to be traced I add processor
> <process ref="routeTracer "/>
> Added this bean to my Sping Context
> <bean id="routeTracer" class=" util.MessageDateProcessor">
> <property name="routeName" value="route1"/>
> </bean>
>
> And I started route with timer which periodically send message to my
> routeTracer bean method retrieve the lastMessageDate data and send it to sql
> endpoint
> <route>
> <from ref="timer://foo?fixedRate=true&period=5000"/>
> <to uri="bean:routeTracer?method=setLastMessageDate"/>
> <to uri="sql:insert into RouteTrace (route_name,
> last_passing_date) values (#,#)?dataSourceRef=myDS"/>
> </route>
>
> The problem is that I get error
> , BodyType:null
> , Body:Message: [Body is null]
> , CaughtExceptionType:org.springframework.jdbc.UncategorizedSQLException,
> CaughtExceptionMessage:PreparedStatementCallback; uncategorized SQLException
> for SQL [
> insert into RouteTrace (route_name, last_passing_date) values (?, ?)]; SQL
> state [null]; error code [0]; Number of parameters mismatch. Expected: 2,
> was:0; nested exception is java.sql.SQLException: Number of parameters
> mismatch. Expected: 2, was:0] {logger}
> It seems the message isn’t sent to the bean:routeTracer(<to
> uri="bean:routeTracer?method=setLastMessageDate"/> )
>
> Can someone help me to understand what I am doing wrong?
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang