Camel Custom Component Example

Source: Internet
Author: User
To customize the components in camel, it is necessary to understand the key concepts in camel, to understand the construction process and the initiation process of camel Middle road, and to have the relevant narration in the previous article.

Here is an example of a custom component. This example is also subject to a file poll, which is the specific code below.

Component classes:

[Java] view plain copy package com.xtayfjpk.esb.components.file;      Import Java.util.Map;   Import Org.apache.camel.Endpoint;      Import org.apache.camel.impl.DefaultComponent; public class Myfilecomponent extends Defaultcomponent {@Override protected Endpoint createendpoint (String URI, String remaining, map<string, object> parameters) throws Exception {return new Myfileendpoint (this,       URI); }      }
Endpoint class:

[Java]  View plain copy package com.xtayfjpk.esb.components.file;      import  java.io.file;      import org.apache.camel.consumer;   import  org.apache.camel.exchange;   import org.apache.camel.processor;   import  org.apache.camel.producer;   import org.apache.camel.component.file.filecomponent;   import org.apache.camel.impl.defaultendpoint;   import  org.apache.camel.impl.defaultexchange;      public class myfileendpoint  extends defaultendpoint {          public myfileendpoint ( Myfilecomponent component, string uri)  {            super (uri, component);       }            @Override        puBlic producer createproducer ()  throws Exception {            return new myfileproducer (this);       }            @Override        public consumer  createconsumer (processor processor)  throws Exception {            return new myfileconsumer (this, processor);        }           @Override         public boolean issingleton ()  {            return false;       }         

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.