background preloader

Camel

Facebook Twitter

Simple Spring Memcached – Spring Caching Abstraction and Memcached. Caching remains the one of the most basic performance enhancing mechanism in any read heavy database application.

Simple Spring Memcached – Spring Caching Abstraction and Memcached

Spring 3.1 release came up with a cool new feature called Cache Abstraction. Spring Cache Abstraction provides the application developers an easy, transparent and decoupled way to implement any caching solution. Memcached is one of the most popular distributed caching system used across apps. In this post we will focus on how to integrate memcached with a Spring enabled applications. Since Spring directly supports only Ehcache and ConcurrentHashMap so we will fall down to a third party library Simple Spring Memcache to leverage power of spring caching abstraction. Getting The Code. Dozer Type Conversion. Dozer is a fast and flexible framework for mapping back and forth between Java Beans.

Dozer Type Conversion

Coupled with Camel's automatic type conversion, it's a formidable tool for dealing object to object mapping headaches that crop up in enterprise integration projects. To explain how Dozer can be uses within Camel we'll use the following example of a simple Customer Support Service. The initial version of the Service defined a 'Customer' object used with a very flat structure. In the next version it was decided to structure the data better in the model by moving the address data into its own type, with the resultin domain object ending up looking like Much nicer! Facebook Integration using Apache Camel - Aaron Mulder, CTO Chariot Solutions. Solr Tutorial. Camel, CXF and JMS by example. While working on a typical customer SOA/ESB integration project we ran into some complex communication issues.

Camel, CXF and JMS by example

It’s required that all communication between the different services and ESB is done using SOAP over JMS. CXF already has embedded support for JMS, but apart from a complex setup, this also caused that our services were no longer available using plain HTTP (used for our FitNesse functional tests). As it took quite some time to figure out how to properly hookup CXF and Camel, and exposing them via various protocols (even email if you’d like to) I wanted to share with you how we implemented this via an example project.

ToolBits: Quick RESTful web services with the Camel cxfbean component. Trying to create a REST web service using the old Camel cxfrs component was somewhat a pain and not very intuitive in my opinion.

ToolBits: Quick RESTful web services with the Camel cxfbean component

It was such a pain I didn't even want to write an example post for it. I really wanted something more automated like Jersey. Luckly the Apache Camel cxfbean component makes putting together a REST web service much easier. Just annotate your service class and use it as the resource for the cxfbean component. If you want to produce and consume a data format like JSON, you simply pass the necessary processor to the list of cxfbean processors.

Since I was using Groovy I ran into an issue where Groovy automatically adds a getMetaClass method that returns an Interface and the CXF JSON processor didn't like that. Open Source Integration with Apache Camel and How Fuse IDE Can Help. Take any integration project and you have multiple applications talking over multiple transports on multiple platforms.

Open Source Integration with Apache Camel and How Fuse IDE Can Help

As you can imagine, in large enterprise applications this can get complex very fast. Much of the complexity stems from two issues: Smooks Data Integration. I did a little playing with Camel over the weekend… had a go at integrating Smooks.

Smooks Data Integration

I think those using Camel may find it interesting as another option. The integration was simple enough and can be seen in this svn workspace (including tests etc). Using Jackson with Apache CXF. Whilst working on my Javascript, ExtJS 4 and Apache CXF skills I came across a solution to a problem I encountered getting ExtJS to talk to Apache CXF using JSON.

Using Jackson with Apache CXF

The basis for this issue revolves around “wrapping” in JSON and two different schools on what is correct way to encode it. As far as I can see there is the more verbose version which Jettison, the default JSON serialiser in Apache CXF produces, then there is the “unwrapped” version which the alternate serialiser Jackson produces. In my case I chose Jackson the more terse version, this is good for a couple of reasons: It is compatible with ExtJS without any modifications It is smaller and therefore produces less data on the wire. Also I like the annotations that Jackson comes with, and find it a bit easier to work with than Jettison. So to enable Jackson I modify my projects Maven pom file I add the following dependency.

In addition to this some changes are required in the spring configuration which houses our RESTful services. Camel: Bean Binding. Bean Binding in Camel defines both which methods are invoked and also how the Message is converted into the parameters of the method when it is invoked.

Camel: Bean Binding

Choosing the method to invoke The binding of a Camel Message to a bean method call can occur in different ways, in the following order of importance: In cases where Camel cannot choose a method to invoke, an AmbiguousMethodCallException is thrown. By default the return value is set on the outbound message body. Parameter binding. When to use Apache Camel? Apache Camel is one of my favorite open source frameworks in the JVM / Java environment.

When to use Apache Camel?

It enables easy integration of different applications which use several protocols and technologies. This article shows when to use Apache Camel and when to use other alternatives. The Problem: Enterprise Application Integration (EAI) Enterprise application integration is necessary in almost every company due to new products and applications. Integrating these applications creates several problems. Besides, different interfaces, protocols and technologies emerge. Enterprise Integration Patterns (EIP) Of course, you could reinvent the wheel for each problem, write some spaghetti code and let the applications work together. Spring vs Java EE Web Dev: Using Camel with Jackson JSON Serialization. Camel: Components. Components Included Camel includes the following Component implementations via URIs.

Camel: Components

External Components. JAX-RS Data Bindings. JAX-RS : Data Bindings The request and response can be marshalled and unmarshalled to/from Java object using JAXB. There's a number of ways to tell to the JAXB provider how objects can be serialized. Camel: NotifyBuilder. Available as of Camel 2.2 The NotifyBuilder is a builder from the org.apache.camel.builder package which allows you to build expressions and then test or wait for that condition to occur. The expressions is based around notifications about Exchange being routed. So what does that mean? It means that you can build an expressions which can tell you when Camel is finished with routing 5 messages etc. You may want to use this when testing a route which you cannot or will not use Mocks. Suppose we have a very simple route: Now you want to test this route without using mocks or the likes. Camel: Camel Maven Archetypes.

Camel is distributed with the following archetypes for Maven end users. Archetype Supported The maven coordinates for these archetypes is the following: Icon.