spring - Trouble filtering in Camel -


i attempting filter out null bodies route. route polls function every half second or so. so, error in console every half-second. here stack trace:

message history --------------------------------------------------------------------------------------------------------------------------------------- routeid              processorid          processor                                                                            elapsed (ms) [route1            ] [route1            ] [browserbean                                                                       ] [         0] [route1            ] [filter1           ] [filter[simple{(${body} == null)}]                                             ] [         0]  exchange ---------------------------------------------------------------------------------------   ------------------------------------------------ exchange[ id                  id-co183ltcs06-54352-1403798372606-0-1058 exchangepattern     inonly headers             {breadcrumbid=id-co183ltcs06-54352-1403798372606-0-1057,     camelredelivered=false, camelredeliverycounter=0} bodytype            null body                [body null] ]  stacktrace ---------------------------------------------------------------------------------------------------------------------------------------  java.lang.nullpointerexception: null @ com.hello.integration.greetingcontroller.greeting(greetingcontroller.java:15) @ sun.reflect.generatedmethodaccessor22.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.apache.camel.component.bean.methodinfo.invoke(methodinfo.java:407) @ org.apache.camel.component.bean.methodinfo$1.doproceed(methodinfo.java:278) @ org.apache.camel.component.bean.methodinfo$1.proceed(methodinfo.java:251) @ org.apache.camel.component.bean.beanprocessor.process(beanprocessor.java:166) @     org.apache.camel.util.asyncprocessorhelper.process(asyncprocessorhelper.java:105) @ org.apache.camel.component.bean.beanprocessor.process(beanprocessor.java:67) @     org.apache.camel.impl.processorpollingconsumer.receive(processorpollingconsumer.java:58) @     org.apache.camel.impl.processorpollingconsumer.receivenowait(processorpollingconsumer.java:    66) @ org.apache.camel.impl.defaultscheduledpollconsumer.poll(defaultscheduledpollconsumer.java:48) @ org.apache.camel.impl.scheduledpollconsumer.dorun(scheduledpollconsumer.java:187) @ org.apache.camel.impl.scheduledpollconsumer.run(scheduledpollconsumer.java:114) @ java.util.concurrent.executors$runnableadapter.call(unknown source) @ java.util.concurrent.futuretask.runandreset(unknown source) @     java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.access$301(unknown     source) @ java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(unknown     source) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) 

any ideas? feel it's simple i've been looking on web solutions , can't find solves problem.

<?xml version="1.0" encoding="utf-8"?>  <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans.xsd      http://camel.apache.org/schema/osgi     http://camel.apache.org/schema/osgi/camel-osgi.xsd      http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context.xsd      http://camel.apache.org/schema/spring     http://camel.apache.org/schema/spring/camel-spring.xsd">  <camelcontext xmlns="http://camel.apache.org/schema/spring"> <route>     <from uri="browserbean"/>         <filter>             <simple>${body} == null</simple>             <stop/>         </filter>     <to uri="jms:queue:testqsource"/>     <to uri="mybean"/>     <log message="routing message testqsource testqdestination queue data ${body}"/>     <to uri="jms:queue:testqdestination"/>     <to uri="finalbean"/>     <log message="message: ${body}"/> </route> </camelcontext>  <camel:camelcontext id="camel-client"> <camel:template id="cameltemplate" /> </camel:camelcontext>  <bean id="jms" class="org.apache.activemq.camel.component.activemqcomponent">     <property name="brokerurl" value="tcp://localhost:61616" /> </bean>\  <bean id="mybean" class="com.example.integration.modifier"/> <bean id="finalbean" class="com.example.integration.actionapp"/> <bean id="browserbean" class="com.hello.integration.greetingcontroller"/>  </beans> 

edit: null body coming following function:

package com.hello.integration;  import org.springframework.messaging.handler.annotation.messagemapping; import org.springframework.messaging.handler.annotation.sendto; import org.springframework.stereotype.controller;  @controller public class greetingcontroller {       @messagemapping("/hello")     @sendto("/topic/greetings")     public greeting greeting(hellomessage message) throws exception {         //thread.sleep(3000); // simulated delay         return new greeting("hello, " + message.getname() + "!");     }  } 

even though attempt filter out null bodies, still getting error. filtering them out late?

you cannot put filter inside of tag. below route should work :)

<camelcontext xmlns="http://camel.apache.org/schema/spring"> <route>     <from uri="browserbean"/>          <filter>             <simple>${body} == null</simple>             <stop/>         </filter>      <to uri="jms:queue:testqsource"/>     <to uri="mybean"/>     <log message="routing message testqsource testqdestination queue data ${body}"/>     <to uri="jms:queue:testqdestination"/>     <to uri="finalbean"/>     <log message="message: ${body}"/> </route> 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -