java - Use a method as producer in camel route -


i have method every , generates string. register method uri , produce exchange method used input route.

the method call different class

sampleclass sc = new sampleclass(); sc.samplemethod("hello"); 

eg:

public class sampleclass{     @produce(uri = "direct:consumermethod")     producertemplate producer;     public samplemethod(object obj){           producer.sendbody(object);     } } 

the route defined below:

@override     public void configure() {         from("direct:consumermethod").process(new generated());     } 

but route doesnt call generated class when produce using samplemethod. not feasible or doing wrong?

finally worked use case.

starting camelcontext below:

camelcontext camelcontext = new defaultcamelcontext(); camelcontext.addroutes(new sampleroute()); camelcontext.start(); 

my routebuilder class :

    class sampleroute extends routebuilder {      @override     public void configure() {         try         {             from("direct:consumermethod").process(new ddt());         }catch(exception e)         {             e.printstacktrace();         }      } } 

i create interface has sendmessage method.

public interface ddtconsumer {      public string sendmessage(object object);  } 

now implement method create endpoint of interface , send message endpoint.

ddtconsumer ddt; try {     ddt = new proxybuilder(camelcontext).endpoint("direct:consumermethod").build(ddtconsumer.class);     ddt.sendmessage(msg.getvalue());     } catch (exception e) {         e.printstacktrace();     } 

this solved problem , route working fine now. hope helps others well.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -