Welcome!

Microservices Expo Authors: Jason Bloomberg, Elizabeth White, Liz McMillan, Pat Romanski, Kevin Jackson

Related Topics: Microservices Expo, Linux Containers, Open Source Cloud, Apache

Microservices Expo: Article

SOA Made Easy with Open Source Apache Camel

XML/REST/Web Services/SOA revolution has driven engineers and software firms to create an abundance of protocols

So after starting the CamelContext, we can fire some objects into Camel.

In normal use, an external system would be firing messages or events directly into Camel through one if its components but we're going to use the CamelTemplate, which is a really easy way to test your configuration:

    CamelTemplate template = new CamelTemplate(context);

We can now send some test messages over JMS using the CamelTemplate:

for (int i = 0; i < 10; i++) {
    template.sendBody("test-jms:queue:test.queue", "Test Message: " + i);
}

From the CamelTemplate we send objects (in this case text) into the CamelContext to the Component test-jms:queue:test.queue. These text objects will be converted automatically into JMS Messages and posted to a JMS queue named test.queue. When we set up the route, we configured the FileComponent to listen of the test.queue.

The file FileComponent will take messages from the queue and save them to a directory named test. Every message will be saved in a file that corresponds to its destination and message ID.

Finally, we configured our own listener in the route to take notifications from the FileComponent and print them out as text.

Spring XML Configuration
This example will use Spring XML configuration to transform files from a directory using XQuery and send the results to a JMS queue. It parsers some files from a directory, transforms them using XQuery then sends them to a message queue. To make it easy to look at the generated files, we also have another route that consumes from the JMS queue and writes them to an output directory.

Running the Example
To run the example we use the Camel Maven Plugin. For example, from the source or binary distribution the following should work:

cd examples/camel-example-spring-xquery
mvn camel:run

You should now see the generated files in the target/outputFiles directory, which are the transformed messages read from the JMS queue.

Code Walkthrough
What this does is boot up the Spring ApplicationContext defined in the file META-INF/spring/camelContext.xml on the classpath. This is a regular Spring XML document that uses the Camel XML configuration to configure a CamelContext.

Note that at the end of this XML example file we explicitly configure the ActiveMQ component with details on how to connect to the broker.

The main part of the Spring XML file is here:

<camelContext useJmx="true" xmlns="http://activemq.apache.org/camel/schema/spring">

   <!-- lets parse files, transform them with XQuery and send them to JMS -->
   <route>
     <from uri="file:src/data?noop=true"/>
     <to uri="xquery:myTransform.xquery"/>
     <to uri="jms:MyQueue"/>
   </route>

   <!-- now lets write messages from the queue to a directory -->
   <route>
     <from uri="jms:MyQueue"/>
     <to uri="file:target/outputFiles"/>
   </route>

</camelContext>

<!-- lets configure the default ActiveMQ broker URL -->
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
   <property name="connectionFactory">
     <bean class="org.apache.activemq.ActiveMQConnectionFactory">
       <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
     </bean>
   </property>
</bean>

This hopefully has given you a flavor of how easy it is to do enterprise integration using Apache Camel. For more information see the Web site at http://activemq.apache.org/camel/.

Resources
www.enterpriseintegrationpatterns.com/

More Stories By Robert Davies

Rob Davies is chief technology officer at FuseSource. One of the original members of the team, he co-founded LogicBlaze which was purchased by IONA and is now FuseSource. Prior to working for Logicblaze, he was a founder and the CTO of SpiritSoft which was purchased by Sun Microsystems. Rob has over 20 years experience of developing high performance distributed enterprise systems and products for telcos and finance, and is best known for his work at the Apache Software Foundation where he co-founded the ServiceMix, ActiveMQ, and Camel projects. He is now the PMC chair of ServiceMix and continues to be an active committer on all three projects. You can read his blog, On Open Source Integration, or follow him on twitter.

More Stories By James Strachan

James Strachan, technical director at IONA, is responsible for helping the Company provide open source offerings for organizations requiring secure, high-performance distributed systems and integration solutions. He is heavily involved in the open source community, and has co-founded several Apache projects, including ActiveMQ, Camel, Geronimo and ServiceMix. He also created the "Groovy" scripting language and additional open source projects such as dom4j, jaxen and Jelly. Prior to joining IONA, James spent more than 20 years in enterprise software development. Previously, James co-founded LogicBlaze, Inc., an enterprise open source company acquired by IONA. Prior to that, he founded SpiritSoft, Inc., a company providing enterprise Java middleware services.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@MicroservicesExpo Stories
If you cannot explicitly articulate how investing in a new technology, changing the approach or re-engineering the business process will help you achieve your customer-centric vision of the future in direct and measurable ways, you probably shouldn’t be doing it. At Intellyx, we spend a lot of time talking to technology vendors. In our conversations, we explore emerging new technologies that are either disrupting the way enterprise organizations work or that help enable those organizations to ...
In 2014, Amazon announced a new form of compute called Lambda. We didn't know it at the time, but this represented a fundamental shift in what we expect from cloud computing. Now, all of the major cloud computing vendors want to take part in this disruptive technology. In his session at 20th Cloud Expo, Doug Vanderweide, an instructor at Linux Academy, discussed why major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform are all trying to sidestep VMs and containers wit...
The taxi industry never saw Uber coming. Startups are a threat to incumbents like never before, and a major enabler for startups is that they are instantly “cloud ready.” If innovation moves at the pace of IT, then your company is in trouble. Why? Because your data center will not keep up with frenetic pace AWS, Microsoft and Google are rolling out new capabilities. In his session at 20th Cloud Expo, Don Browning, VP of Cloud Architecture at Turner, posited that disruption is inevitable for comp...
For organizations that have amassed large sums of software complexity, taking a microservices approach is the first step toward DevOps and continuous improvement / development. Integrating system-level analysis with microservices makes it easier to change and add functionality to applications at any time without the increase of risk. Before you start big transformation projects or a cloud migration, make sure these changes won’t take down your entire organization.
There's a lot to gain from cloud computing, but success requires a thoughtful and enterprise focused approach. Cloud computing decouples data and information from the infrastructure on which it lies. A process that is a LOT more involved than dragging some folders from your desktop to a shared drive. Cloud computing as a mission transformation activity, not a technological one. As an organization moves from local information hosting to the cloud, one of the most important challenges is addressi...
"We are a monitoring company. We work with Salesforce, BBC, and quite a few other big logos. We basically provide monitoring for them, structure for their cloud services and we fit into the DevOps world" explained David Gildeh, Co-founder and CEO of Outlyer, in this SYS-CON.tv interview at DevOps Summit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
"When we talk about cloud without compromise what we're talking about is that when people think about 'I need the flexibility of the cloud' - it's the ability to create applications and run them in a cloud environment that's far more flexible,” explained Matthew Finnie, CTO of Interoute, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
What's the role of an IT self-service portal when you get to continuous delivery and Infrastructure as Code? This general session showed how to create the continuous delivery culture and eight accelerators for leading the change. Don Demcsak is a DevOps and Cloud Native Modernization Principal for Dell EMC based out of New Jersey. He is a former, long time, Microsoft Most Valuable Professional, specializing in building and architecting Application Delivery Pipelines for hybrid legacy, and cloud ...
For most organizations, the move to hybrid cloud is now a question of when, not if. Fully 82% of enterprises plan to have a hybrid cloud strategy this year, according to Infoholic Research. The worldwide hybrid cloud computing market is expected to grow about 34% annually over the next five years, reaching $241.13 billion by 2022. Companies are embracing hybrid cloud because of the many advantages it offers compared to relying on a single provider for all of their cloud needs. Hybrid offers bala...
21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Me...
Companies have always been concerned that traditional enterprise software is slow and complex to install, often disrupting critical and time-sensitive operations during roll-out. With the growing need to integrate new digital technologies into the enterprise to transform business processes, this concern has become even more pressing. A 2016 Panorama Consulting Solutions study revealed that enterprise resource planning (ERP) projects took an average of 21 months to install, with 57 percent of t...
Microservices are increasingly used in the development world as developers work to create larger, more complex applications that are better developed and managed as a combination of smaller services that work cohesively together for larger, application-wide functionality. Tools such as Service Fabric are rising to meet the need to think about and build apps using a piece-by-piece methodology that is, frankly, less mind-boggling than considering the whole of the application at once. Today, we'll ...
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
Hybrid IT is today’s reality, and while its implementation may seem daunting at times, more and more organizations are migrating to the cloud. In fact, according to SolarWinds 2017 IT Trends Index: Portrait of a Hybrid IT Organization 95 percent of organizations have migrated crucial applications to the cloud in the past year. As such, it’s in every IT professional’s best interest to know what to expect.
Both SaaS vendors and SaaS buyers are going “all-in” to hyperscale IaaS platforms such as AWS, which is disrupting the SaaS value proposition. Why should the enterprise SaaS consumer pay for the SaaS service if their data is resident in adjacent AWS S3 buckets? If both SaaS sellers and buyers are using the same cloud tools, automation and pay-per-transaction model offered by IaaS platforms, then why not host the “shrink-wrapped” software in the customers’ cloud? Further, serverless computing, cl...
Containers, microservices and DevOps are all the rage lately. You can read about how great they are and how they’ll change your life and the industry everywhere. So naturally when we started a new company and were deciding how to architect our app, we went with microservices, containers and DevOps. About now you’re expecting a story of how everything went so smoothly, we’re now pushing out code ten times a day, but the reality is quite different.
In the decade following his article, cloud computing further cemented Carr’s perspective. Compute, storage, and network resources have become simple utilities, available at the proverbial turn of the faucet. The value they provide is immense, but the cloud playing field is amazingly level. Carr’s quote above presaged the cloud to a T. Today, however, we’re in the digital era. Mark Andreesen’s ‘software is eating the world’ prognostication is coming to pass, as enterprises realize they must be...
A common misconception about the cloud is that one size fits all. Companies expecting to run all of their operations using one cloud solution or service must realize that doing so is akin to forcing the totality of their business functionality into a straightjacket. Unlocking the full potential of the cloud means embracing the multi-cloud future where businesses use their own cloud, and/or clouds from different vendors, to support separate functions or product groups. There is no single cloud so...
Colocation is a central pillar of modern enterprise infrastructure planning because it provides greater control, insight, and performance than managed platforms. In spite of the inexorable rise of the cloud, most businesses with extensive IT hardware requirements choose to host their infrastructure in colocation data centers. According to a recent IDC survey, more than half of the businesses questioned use colocation services, and the number is even higher among established businesses and busin...
When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...