java - Apache Camel - JMS Remoting: Exception not thrown back to the producer -
i'm looking solution make exception thrown on consumer side returned producer side when using apache camel - jms remoting.
i found there similar question asked @ apache camel jms - exceptions not returned caller request/reply.
so, followed answer there , turned on transferexception option claus suggested camel still gives me error - different error, invalidpayloadexception caused org.apache.camel.notypeconversionavailableexception - no type converter available convert type: org.apache.camel.runtimecamelexception required type: long value org.apache.camel.runtimecamelexception: com.x.y.z.serviceexception: test].
so, seems exception on producer side claus suggested (the original exception's wrapped in runtimecalmelexception). problem camel tried convert exception return type long.
is there way let exception bubbled way without being getting converted?
here detail:
interface: pricingservice.java
public long getprice(string id);
consumer side: pricingserviceimpl.java
@service("pricingservice") public class pricingserviceimpl { public long getprice(string id) { //only throw exception here simplicity. //assuming serviceexception serializable. throw new serviceexception("test"); } }
routebuilder:
public class myroutes extends routebuilder { public void configure() throws exception { getcontext().settracing(true); from("jms:queue:pricingservice concurrentconsumers=25&transferexception=true&transferexchange=true").to("pricingservice"); } }
producer side:
<camel:camelcontext id="producer"> <camel:proxy id="pricingservice" serviceinterface="com.x.y.z.pricingservice" serviceurl="jms:queue:pricingservice?transferexchange=true"/> </camel:camelcontext>
so, on producer side, when call pricingservice.getprice("abc")
, got exception follows:
org.apache.camel.invalidpayloadexception: no body available of type: long has value: org.apache.camel.runtimecamelexception: com.x.y.z.serviceexception: err_not_found of type: org.apache.camel.runtimecamelexception on: jmsmessage[jmsmessageid: id:localhost.localdomain-35812-1368034706262-11:1:1:1:1]. caused by: no type converter available convert type: org.apache.camel.runtimecamelexception required type: long value org.apache.camel.runtimecamelexception: com.x.y.z.serviceexception: err_not_found. exchange[jmsmessage[jmsmessageid: id:localhost.localdomain-35812-1368034706262-11:1:1:1:1]]. caused by: [org.apache.camel.notypeconversionavailableexception - no type converter available convert type: org.apache.camel.runtimecamelexception required type: long value org.apache.camel.runtimecamelexception: com.x.y.z.serviceexception: err_not_found] @ org.apache.camel.impl.messagesupport.getmandatorybody(messagesupport.java:101) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.getbody(abstractcamelinvocationhandler.java:66) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.afterinvoke(abstractcamelinvocationhandler.java:175) @ org.apache.camel.component.bean.abstractcamelinvocationhandler$1.call(abstractcamelinvocationhandler.java:112) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:303) @ java.util.concurrent.futuretask.run(futuretask.java:138) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.invokewithbody(abstractcamelinvocationhandler.java:128) @ org.apache.camel.component.bean.camelinvocationhandler.doinvokeproxy(camelinvocationhandler.java:45) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.invoke(abstractcamelinvocationhandler.java:82) ... 103 more caused by: org.apache.camel.notypeconversionavailableexception: no type converter available convert type: org.apache.camel.runtimecamelexception required type: long value org.apache.camel.runtimecamelexception: com.x.y.z.serviceexception: err_not_found @ org.apache.camel.impl.converter.basetypeconverterregistry.mandatoryconvertto(basetypeconverterregistry.java:169) @ org.apache.camel.impl.messagesupport.getmandatorybody(messagesupport.java:99) ... 111 more
thanks!
update:
after adding transferexception on producer side, exception got changed following. not make out of this. still tried conversion... please help. thanks.
caused by: org.apache.camel.invalidpayloadexception: no body available of type: long has value: beaninvocation public abstract long com.x.y.z.pricingservice.getprice(java.lang.string) throws com.x.y.z.serviceexception [test]] of type: org.apache.camel.component.bean.beaninvocation on: message: test. caused by: error during type conversion type: org.apache.camel.component.bean.beaninvocation required type: long value beaninvocation public abstract long com.x.y.z.service.billing.pricingservice.getprice(java.lang.string) throws com.x.y.z.serviceexception [test]] due java.lang.numberformatexception: input string: "test". exchange[message: test]. caused by: [org.apache.camel.typeconversionexception - error during type conversion type: org.apache.camel.component.bean.beaninvocation required type: long value beaninvocation public abstract long com.x.y.z.pricingservice.getprice(java.lang.string) throws com.x.y.z.serviceexception [test]] due java.lang.numberformatexception: input string: "test"] @ org.apache.camel.impl.messagesupport.getmandatorybody(messagesupport.java:101) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.getbody(abstractcamelinvocationhandler.java:72) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.afterinvoke(abstractcamelinvocationhandler.java:175) @ org.apache.camel.component.bean.abstractcamelinvocationhandler$1.call(abstractcamelinvocationhandler.java:112) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:303) @ java.util.concurrent.futuretask.run(futuretask.java:138) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.invokewithbody(abstractcamelinvocationhandler.java:128) @ org.apache.camel.component.bean.camelinvocationhandler.doinvokeproxy(camelinvocationhandler.java:45) @ org.apache.camel.component.bean.abstractcamelinvocationhandler.invoke(abstractcamelinvocationhandler.java:82) ... 104 more caused by: org.apache.camel.typeconversionexception: error during type conversion type: org.apache.camel.component.bean.beaninvocation required type: long value beaninvocation public abstract long com.x.y.z.pricingservice.getprice(java.lang.string) throws com.x.y.z.serviceexception [test]] due java.lang.numberformatexception: input string: "test" @ org.apache.camel.impl.converter.basetypeconverterregistry.mandatoryconvertto(basetypeconverterregistry.java:162) @ org.apache.camel.impl.messagesupport.getmandatorybody(messagesupport.java:99) ... 112 more caused by: org.apache.camel.runtimecamelexception: java.lang.numberformatexception: input string: "test" @ org.apache.camel.util.objecthelper.wrapruntimecamelexception(objecthelper.java:1316) @ org.apache.camel.util.objecthelper.invokemethod(objecthelper.java:962) @ org.apache.camel.impl.converter.staticmethodtypeconverter.convertto(staticmethodtypeconverter.java:47) @ org.apache.camel.component.bean.beanconverter.convertto(beanconverter.java:57) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25)
you should set transferexception=true on producer side well.
Comments
Post a Comment