java - possibility of passing MyObject to bean routing using Apache camel? -


i consuming messages apache kafka using apache camel java dsls. writing object converting byte[] on kafka. when consume have message byte[], deserialize , gets object. checks if object of myobject need pass bean using java dsl .to(). code below :

public class kafkarouter extends routebuilder {      private messagebean msgbean;      @override     public void configure() throws exception {          from("{{kafka.cons.uri}}").process(new processor() {                @override             public void process(exchange exchange) throws exception {                 object obj = serializationutils.deserialize(exchange.getin().getbody(byte[].class));                //todo cast specific class returned after deserialization.                  if(obj !=null && obj instanceof messagebean){                      msgbean = (messagebean)obj;                  }                 else {                      throw new ptfexception("invalid message read in kafka consumer");                 }              }           }).bean(ptftransformerservice.class,"calltransformerservice(msgbean)"); ;     } 

now issue want myobject in corresponding called method , not want use typeconvertors. not want exchange/body in method process stream in process , throw exception if read invalid messages , not forward bean.

my method on other end :

private void calltransformerservice(messagebean msgobj){     // got object here ;-)         } 

add @body before function argument messagebean msgobj:

import org.apache.camel.body;  private void calltransformerservice(@body messagebean msgobj){  } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -