Açıklaması şöyle
Processors handles things in between endpoints like routing, transformation, validation, enrichment, etc.
Örnek
Şu satırı dahil ederiz
<dependency><groupId>org.apache.camel.springboot</groupId><artifactId>camel-activemq-starter</artifactId><version>3.8.0</version></dependency><dependency><groupId>org.apache.camel.springboot</groupId><artifactId>camel-jackson-starter</artifactId><version>3.8.0</version></dependency>
Elimizde ActiveMQ'dan okuyup processor'a gönderen şöyle bir kod olsun. Burada Processor olan GetEmployee .bean() metodu ile belirtiliyor. GetEmployee sınıfının tek metodu olduğu için hangi metodunun çağrılacağını belirtmeye gerek yok.
import org.apache.camel.builder.RouteBuilder;import org.apache.camel.model.dataformat.JsonLibrary; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class ActiveMQReceiverRoute extends RouteBuilder { @Autowired GetEmployee getEmployee; @Override public void configure() throws Exception { from("activemq:myqueue") .unmarshal().json(JsonLibrary.Jackson, Employee.class) .bean(getEmployee) .to("log:myloggingqueue"); } } @Component class GetEmployee{ Logger logger= LoggerFactory.getLogger(GetEmployee.class); public void getData(Employee employee){ logger.info("Emp data: "+employee.getId()); } }
Hiç yorum yok:
Yorum Gönder