Apache Camel Tutorial - EIP, Routes, Components | Ultimate Guide to Learn [BEST & NEW]
Apache Camel Tutorial ACTE

Apache Camel Tutorial – EIP, Routes, Components | Ultimate Guide to Learn [BEST & NEW]

Last updated on 18th Jan 2022, Blog, Tutorials

About author

Vidhyawati (Sr Java Developer )

Vidhyawati is a Java developer with 8+ years of experience in a flexible business process management suite that is written in Java. She has skills in JavaScript, HTML, CSS, SQL, Python, BPMN, Red Hat process, Drools software, Jira, and Appian.

(5.0) | 18902 Ratings 1904
    • Introduction to Apache Camel
    • What is Apache Camel?
    • Highlights of Apache Camel
    • Apache Camel – Overview
    • Apache Camel Architecture
    • Center parts of Apache Camel
    • Endeavor Integration Pattern
    • CamelContext
    • Area Specific Language (DSL)
    • How to make another task?
    • How to make another venture utilizing Springs?
    • Conclusion

    Subscribe For Free Demo

    [custom_views_post_title]

      Introduction to Apache Camel :-

    • Apache Camel is the most ordinarily utilized application flexible open-source coordination structure that effectively incorporates different frameworks delivering or consuming information.
    • Along these lines, I thought of this exhaustive Apache Camel Tutorial to momentarily comprehend Apache Camel, EIPs, DSLs, and so forth Nowadays, Data dividing among organizations has expanded massively.
    • Various reconciliation of uses has expanded also. The UI utilizes different advancements, information arrangements, and conventions. However, coordinating such applications is demonstrated in a redid way, concerning proficiency and backing via programmed tests.
    • Introduction to Apache Camel
      Introduction to Apache Camel 
    • For such normalized combination, Enterprise Integration Patterns (EIP) are utilized to archive, carry out, and characterize reconciliation issues. Apache Camel appeared to carry out EIPs and give altered, area explicit language (DSL) to coordinate applications without any problem.
    • Apache Camel is a structure that fundamentally works with settling endeavor incorporation challenges. At its center it very well may be considered as a steering motor developer. Basically it permits you to associate systems(endpoints) through courses.
    • These courses acknowledge messages which can be of any information type. The Apache Camel system additionally contains a total arrangement of EIP(Enterprise reconciliation designs, for example, splitter, aggregators, content put together directing thus with respect to.
    • Since the system can be conveyed in different independent in Java applications, in different application servers like WildFly and Tomcat or on a completely fledged venture administration transport it very well may be viewed as a mix structure.
    • To get everything rolling with the structure you would have to add it to a task utilizing one of the accompanying strategies:


        1. Expert

        2. Gradle

        3. Spring Boot

        4. Regular JAR library reference added to your task.


      Apache Camel
     Apache Camel

      What is Apache Camel?

    • Apache Camel is an open-source mix structure contingent upon Enterprise Integration Patterns.It permits clients to characterize intervention manages and steering in a few explicit dialects, for example, Java-based Spring, Blueprint XML, or Fluent API design records. Apache Camel executes EIPs and gives a normalized, inward Domain-explicit language (DSL) to incorporate applications.

    • Thus, the structure can be sent with a few independent Java applications and servers like Tomcat, Wildfly, or completely fledged undertaking administration.Consider what is happening where a huge web-based supermarket in your town, for example, the Bigbasket in India welcomes you to plan an IT answer for them.

    • The steady and adaptable arrangement will assist them with defeating the product upkeep issues they are confronting today. This web-based store has been maintaining its business for the last ten years. The store acknowledges online orders for various classes of items from their clients and disperses those to the particular providers.

    • For instance, assume you request a few cleansers, oil and milk; these three things will be conveyed to the three separate providers. The three providers will then, at that point, send their provisions to a typical circulation point from where the whole request will be satisfied by the conveyance community. Presently, let us take a gander at the issue they are confronting today.

    • At the point when this store began its business, it was tolerating orders in a comma-isolated plain text document. Throughout some undefined time frame, the store changed to message-driven request position. Afterward, some product engineer proposed a XML based request position. In the long run, the store even adjusted a web administration interface.

    • Presently, here comes the genuine issue. The orders currently come in various organizations. Clearly, every time the organization updated the request acknowledgment design, it would have rather not break the recently sent point of interaction so as not to cause disarrays in the client’s brain.

    • Simultaneously, as the business continued to develop, the store occasionally added new providers to its collection. Each such provider had its own convention for tolerating orders. Yet again we face the mix issue; our application engineering should be versatile to oblige new providers with their one of a kind request position instrument.

    Course Curriculum

    Learn Apache Camel Certification Training Course to Build Your Skills

    Weekday / Weekend BatchesSee Batch Details

      Highlights of Apache Camel :-

      The highlights of Apache Camel are as per the following:

    • Camel offers a broad library of in excess of 80 parts, and these parts permit Camel to associate with transports, information arrangements, and use APIs.
    • It has a secluded design that empowers the part to stack into Camel.
    • Camel upholds the POJO model and permits clients to module Javabeans at a few places.
    • It upholds pluggable dialects to make DSL projects and supports dialects like Python, SQL, XQuery, JavaScript, Ruby, PHP, Groovy, XPath, and so forth
    • It makes testing of nonconcurrent and circulated frameworks utilizing informing.
    • Camel utilizes a simple and natural URI design to arrange endpoints straightforwardly in courses.
    • It has an in-assembled type-converter component that moves in excess of 150 converters. Along these lines, there is no compelling reason to arrange the sort converter from byte clusters.
    • It gives a Test unit that makes it simple to test the camel applications. The pack contains test-explicit parts that can assist with testing the genuine endpoints.

      Apache Camel – Overview :-

      1. Camel is a black box that gets messages from some endpoint and sends it to another. Inside the black box, the messages might be handled or essentially diverted.So why have a structure for this? In commonsense circumstances as found in the presentation contextual investigation, there might be numerous shippers and numerous beneficiaries each after its own convention like ftp, http and jms.


      2. The framework might require numerous perplexing standards, for example, message from source An ought to be conveyed uniquely to B and C. In circumstances, you might need to make an interpretation of the message to another configuration that the collector anticipates. This interpretation might be dependent upon specific conditions in view of the message substance. So basically you might have to decipher between conventions, stick parts together, characterize directing guidelines, and give sifting in view of message substance.


      3. To meet the above necessities and plan an appropriate programming design for some such circumstances, Enterprise Integration Patterns (EIP) were reported by Gregor Hohpe and Bobby Woolf in 2003. Apache Camel gives the execution of these examples and the inspiration of this instructional exercise is to show you how to involve Camel in circumstances like the one portrayed in the presentation.


      4. Apache Camel is an open source structure. It is a message-arranged middleware that gives rule-based steering and intervention motor. You can characterize rules, for example, assuming it is a “milk” request divert it to a milk merchant and on the off chance that it is an “oil” request divert it to an oil seller, etc. Utilizing Camel, you will actually want to carry out these principles and do the steering in a natural Java code.


      5. It implies that you can utilize your recognizable Java IDE to characterize these standards in a kind safe climate. We don’t have to utilize XML arrangement records, which regularly will more often than not be cumbersome. Camel however upholds XML arrangement through Spring structure, in the event that you like to involve XML for designing the guidelines. You might even utilize Blueprint XML Configuration documents and surprisingly a Scala DSL, in the event that you are a Scala sweetheart. It additionally implies that you can utilize your cherished Java, Scala IDE or even a basic XML manager to arrange the principles.


      Apache Camel Architecture :-

    • The Apache Camel engineering incorporates three fundamental capacities as Components, Processor, Integration Engine, and Router.
    • The Camel center incorporates 13 fundamental parts and 80+ parts of minor parts. It helps in keeping up with low reliance where it very well may be sent.
    •  Apache Camel Architecture
      Apache Camel Architecture 
    • The parts offer an Endpoint point of interaction to the timeless world. The Processor is utilized to intercede and control messages between Endpoints.
    • Processor and Endpoints are set up with one another in the Integration Engine and switch utilizing DSLs. EIPs are executed in this module.
    • When wiring, utilize the channels to channel messages relying upon client necessities.
    • The Camel engineering comprises three parts − Integration Engine and Router, Processors, and Components.

      Center parts of Apache Camel :-

      Apache Camel incorporates different

      1. Bean: The Bean part ties beans to Camel message trades. The URI design is bean: beanName, where beanID can be a string used to follow the bean in Registry. The Bean Endpoint can be arranged utilizing URI sentence structure.

      bean: beanName


      2. Control Bus: The Control Bus from the EIP designs permits the joining framework to be checked and overseen inside the system. It offers simple administration of Camel applications relying upon the Control Bus EIP design.

      Controlbus: order

      Where order can be any string to distinguish the sort of order to utilize.


      3. Data Format: The Data design part empowers the utilization of Data Format as a Camel part.

      Dataformat: name: (marshal/unmarshal)

      Where name is the name of the Data Format. It is utilized for designing the Data Format being used.


      4. Direct: The Direct part offers the customer’s simultaneous conjuring in a JVM when the maker communicates something specific consequently. This endpoint can be utilized to interface existing courses in a similar camel setting.

      Direct: someName

      Where someName can be any string to distinguish the endpoint exceptionally.


      5. File: The File part gives admittance to document frameworks, permitting records to be handled by some other Camel Components or messages from different parts to be saved to plate.

      file:directoryName or record://directoryName

      Where directoryName addresses the hidden record index.


      6. Log: The Log part logs message moves to the fundamental logging technique that permits clients to arrange logging through the accompanying:

      log: loggingCategory

      Where the logging classification is the name of the logging classification to utilize.


      7. REST API: A REST API part is utilized for giving Swagger API of the REST administrations, which has been characterized utilizing the rest-DSL in Camel.

      Its endpoint is designed by URI sentence structure:

      rest-programming interface :way/contextIdPattern


      Course Curriculum

      Get JOB Oriented Apache Camel Training for Beginners By MNC Experts

      • Instructor-led Sessions
      • Real-life Case Studies
      • Assignments
      Explore Curriculum

      8. Scheduler: The Scheduler part assists with producing message trades when a scheduler requires. It is pretty much as same as the Timer part, however it offers more capacities as far as booking. Likewise, this part utilizes JDK ScheduledExecutorService. Then, at that point, the clock utilizes a JDK.

      scheduler: name

      Where name is the name of the scheduler that is made and shared over the endpoints.


      9. Validator: The Validation part executes XML approval of the message body by JAXP Validation API, and relying upon any upheld XML dialects, that defaults to the XML Schema.

      validator: someLocalOrRemoteResource

      Where someLocalOrRemoteResource is URL to the neighborhood asset on the classpath or to a far off asset on the document framework that incorporates the XSD to approve.


      10. XSLT: The XSLT part permits you to handle a message utilizing a XSLT layout. This can be ideal when involving Templating to create a reaction for demands.

      xslt:templateName

      The URI design incorporates templateName that can be


      Endeavor Integration Pattern :-

    • Endeavor Integration Patterns (EIP)s can be utilized to break the combination issues into more modest pieces and make them utilizing normalized illustrations.
    • Indeed, even a non-specialized individual can comprehend the models without any problem.
    • With the assistance of EIPs, Apache Camel diminishes the hole among execution and displaying.
    • There is a connection between Apache Camels EIP and the DSL models.

      CamelContext :-

      1. CamelContext offers admittance to any remaining administrations in Apache Camel. The CamelContext is the Apache Camels runtime framework that associates different ideas like endpoints, parts, or courses.The Registry module is a JNDI library that holds the name of a few Java beans of course in the application.


      2. The Type converters incorporate a few stacked sort converters that convert the contribution starting with one arrangement then onto the next. The Components comprise of the parts utilized by the application. Information designs incorporate stacked information designs.


      CamelContext
      CamelContext

      3. The default CamelContext offers a substantial execution of CamelContext.The runtime framework incorporates JVM, OSGi compartment, JEE application server (e.g., IBM WebSphere AS), and a web holder (e.g., Tomcat).Allow us to take a gander at the different administrations. The Registry module naturally is a JNDI library, which holds the name of the different Javabeans that your application employments.


      4. Assuming you use Camel with Spring, this will be the Spring ApplicationContext. In the event that you use Camel in OSGI compartment, this will be OSGI vault. The Type converters as the name recommends contains the different stacked sort converters, which convert your contribution starting with one arrangement then onto the next.


      5. You might utilize the inherent sort converters or give your own instrument of change. The Components module contains the parts utilized by your application. The parts are stacked via auto disclosure on the classpath that you determine. If there should arise an occurrence of the OSGI compartment, these are stacked at whatever point another group is initiated.


      6. We have effectively talked about the Endpoints and Routes in the past sections. The Data designs module contains the stacked information designs lastly the Languages module addresses the stacked dialects.


      Area Specific Language (DSL) :-

    • Area Specific Languages (DSL)s empowers the acknowledgment of the perplexing undertaking utilizing a high reflection level.
    • Camel offers a few DSL models. Scala, Java, and Groovy and use object-situated ideas to give a specific technique to EIPs. Additionally, Spring XML DSL utilizes XML setup and is based on the Spring structure.
    • Java DSL has IDE support. Scala and Groovy DSLs are pretty much as same as Java DSL. Furthermore, they give elements of JVM dialects like terminations or compact code.
    • Spring XML DSL requires XML, and it gives a strong Spring-based reliance infusion procedure and deliberations to fundamental designs (like JMS or JDBC associations).
    • Indeed, even any mix can be made. Numerous engineers use Spring XML to arrange while courses are seen in Groovy, Java, or Scala.

      How to make another task?

      To assemble a Camel project, do the accompanying advances:

      1. Making a New Project

    • To make another venture, determine the accompanying.
    • Select the default area of the venture or determine the index.

    • 2. Adding Dependencies

    • Open pom.xml to add the conditions.

    • 3. Making Java DSL

    • Compose the sifting and directing code in Java DSL. Make another Java class known as DistributeOrderDSL.
    • We make CamelContext by a default execution presented as DefaultCamelContext class.
    • Presently, add a course by making an obscure RouteBuilder.
    • Abrogate the arrange strategy to add a course from the immediate URI DisributeOrderDSL to the framework console.
    • Start the unique circumstance
    • Add the code for making the immediate URI-DistributeOrderDSL.
    • Presently, start the handling.
    • Java DSL code is finished, add the order.xml record to the undertaking, and it is all set for testing.

    • 4. Testing

    • Run the application; you will get the accompanying result.
    • Guarantee that main orders are recorded. To store these outcomes in a nearby document, then, at that point, remark on the stream. out and uncomment the design technique by the accompanying line.
    • This is the means by which we make another Maven project.

      How to make another venture utilizing Springs?

      We reproduce the application utilizing Spring. To make Camel steering in XML rather than DSL, do the accompanying advances.

      1. Making a New Project :

    • Make another venture and determine the accompanying.
    • Select the default area or indicate the catalog.

    • 2. Adding Dependencies :

    • With the center conditions utilized in the prior application, add a couple of more conditions to utilize Spring.
    • Open pom.xml to add more conditions.

    • 3. Making Java DSL for Spring :

    • Make another Java class known as DistributeOrderXML and add the code given beneath.
    • We make an illustration of ApplicationContext that is the focal connection point in the Spring application. Presently indicate the XML record name that incorporates steering and sifting subtleties.
    • Make CamelContext characterizing the ApplicationContext made.
    • Start the CamelContext utilizing the beginning technique. We characterize the Endpoint for stacking the order.xml record and begin handling.

    • 4. Making Application Context :

    • Add another XML document to the undertaking and call for SpringRouteContext.xml. Utilize the code given underneath.
    • Here, we characterize the XPath inquiry. Note that we currently select all orders.
    • The result Endpoints are various. The primary endpoint characterizes the request envelope, and the subsequent endpoint addresses the control center.
    • Presently, run the application.

    • 5. Test Results :

    • In the wake of running the application, you will get the accompanying result on the screen.
    • Check the request organizer in the way determined. You will observe the recently made document that incorporates the above XML code.

    Apache Flume Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

      Conclusion :-

      Apache Camel offers a structure to carry out EIPs to make it simple for incorporating the ventures. It additionally upholds coding in Domain-explicit Languages (DSL) and surprisingly the XML document. Camel upholds every one of the prerequisites utilized in Enterprise tasks like adaptability, checking, exchanges, and mistake taking care of. The main benefit is that similar punctuation and ideas can be utilized whenever, in any event, for programmed tests, anything the advancements must be incorporated.

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free