Commits

Marcin Grzejszczak committed ec66957

Added an example of using Camel in order to do routing with enriching

  • Participants
  • Parent commits 5bd09e7

Comments (0)

Files changed (51)

File Camel and Spring/.classpath

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

File Camel and Spring/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>TEST</name>
+	<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.ajdt.ui.ajnature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

File Camel and Spring/.settings/org.eclipse.core.resources.prefs

+#Sat Oct 27 14:43:01 CEST 2012
+eclipse.preferences.version=1
+encoding/<project>=UTF-8

File Camel and Spring/.settings/org.eclipse.jdt.core.prefs

+#Sat Oct 27 14:43:02 CEST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6

File Camel and Spring/.settings/org.eclipse.m2e.core.prefs

+#Sun Oct 07 20:53:44 CEST 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

File Camel and Spring/pom.xml

+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>pl.grzejszczak.marcin</groupId>
+	<artifactId>spring-jms-with-camel</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<maven.compiler.source>1.6</maven.compiler.source>
+		<maven.compiler.target>1.6</maven.compiler.target>
+
+		<spring.version>3.1.1.RELEASE</spring.version>
+		<camel.version>2.9.2</camel.version>
+		<activemq.version>5.6.0</activemq.version>
+	</properties>
+	<repositories>
+		<repository>
+			<id>spring-release</id>
+			<url>http://maven.springframework.org/release</url>
+		</repository>
+		<repository>
+			<id>maven-us-nuxeo</id>
+			<url>https://maven-us.nuxeo.org/nexus/content/groups/public</url>
+		</repository>
+	</repositories>
+
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.10</version>
+		</dependency>
+		<!-- Spring -->
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-oxm</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.5.2</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.6</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.camel</groupId>
+			<artifactId>camel-core</artifactId>
+			<version>${camel.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.camel</groupId>
+			<artifactId>camel-activemq</artifactId>
+			<version>1.1.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-core</artifactId>
+			<version>${activemq.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-jms</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.xml.bind</groupId>
+			<artifactId>jaxb-impl</artifactId>
+			<version>2.2.6</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.camel</groupId>
+			<artifactId>camel-spring</artifactId>
+			<version>${camel.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-camel</artifactId>
+			<version>${activemq.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.camel</groupId>
+			<artifactId>camel-jms</artifactId>
+			<version>${camel.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.camel</groupId>
+			<artifactId>camel-spring-javaconfig</artifactId>
+			<version>${camel.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.activemq</groupId>
+			<artifactId>activemq-pool</artifactId>
+			<version>${activemq.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.camel</groupId>
+			<artifactId>camel-jaxb</artifactId>
+			<version>${camel.version}</version>
+		</dependency>
+	</dependencies>
+
+	<!-- <build> <pluginManagement> <plugins> Allows the routes to be run via 
+		'mvn camel:run' <plugin> <groupId>org.apache.camel</groupId> <artifactId>camel-maven-plugin</artifactId> 
+		<version>${project.version}</version> <configuration> <duration>5s</duration> 
+		<configClasses>org.apache.camel.example.spring.javaconfig.MyRouteConfig</configClasses> 
+		You could set the base package directory and let spring to find the config 
+		classes for you <basedPackages>org.apache.camel.example.spring.javaconfig</basedPackages> 
+		</configuration> </plugin> </plugins> </pluginManagement> </build> -->
+
+</project>

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/CamelRouter.java

+package pl.grzejszczak.marcin.camel;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spring.Main;
+
+public class CamelRouter {
+
+	/**
+	 * @param args
+	 * @throws Exception
+	 */
+	public static void main(String[] args) throws Exception {
+		Main main = new Main();
+		main.setApplicationContextUri("/camel/camelContext.xml");
+		main.run(args);
+		CamelContext context = new DefaultCamelContext();
+		context.start();
+		Thread.sleep(1000);
+		context.stop();
+	}
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/enricher/AgeEnricher.java

+package pl.grzejszczak.marcin.camel.enricher;
+
+import java.util.Random;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+
+@Component("AgeEnricher")
+public class AgeEnricher implements Enrichable<PlayerDetails> {
+	private static final Logger LOGGER = LoggerFactory.getLogger(AgeEnricher.class);
+
+	@Override
+	public void enrich(PlayerDetails inputObject) {
+		LOGGER.debug("Enriching player [{}] with age data", new Object[] { inputObject.getSurname() });
+		// Simulating accessing DB or some other service
+		try {
+			Thread.sleep(2000);
+		} catch (InterruptedException e) {
+			LOGGER.error("Exception while sleeping occured", e);
+		}
+		inputObject.setAge(new Random().nextInt(35));
+	}
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/enricher/ClubEnricher.java

+package pl.grzejszczak.marcin.camel.enricher;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+
+@Component("ClubEnricher")
+public class ClubEnricher implements Enrichable<PlayerDetails> {
+
+	private static final Logger LOGGER = LoggerFactory.getLogger(ClubEnricher.class);
+
+	@Override
+	public void enrich(PlayerDetails inputObject) {
+		LOGGER.debug("Enriching player [{}] with club data", new Object[] { inputObject.getSurname() });
+		// Simulating accessing DB or some other service
+		try {
+			Thread.sleep(2000);
+		} catch (InterruptedException e) {
+			LOGGER.error("Exception while sleeping occured", e);
+		}
+		inputObject.setTeamName("Borussia Dortmund");
+	}
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/enricher/Enrichable.java

+package pl.grzejszczak.marcin.camel.enricher;
+
+public interface Enrichable<T> {
+	void enrich(T inputObject);
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/jaxb/Convertable.java

+package pl.grzejszczak.marcin.camel.jaxb;
+
+public interface Convertable<T> {
+	String marshal(T object);
+
+	T unmarshal(String objectAsString);
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/jaxb/PlayerDetailsConverter.java

+package pl.grzejszczak.marcin.camel.jaxb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.activemq.util.ByteArrayInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+
+@Component("PlayerDetailsConverter")
+public class PlayerDetailsConverter implements Convertable<PlayerDetails> {
+	private static final Logger LOGGER = LoggerFactory.getLogger(PlayerDetailsConverter.class);
+
+	private final JAXBContext jaxbContext;
+	private final Marshaller jaxbMarshaller;
+	private final Unmarshaller jaxbUnmarshaller;
+
+	public PlayerDetailsConverter() throws JAXBException {
+		jaxbContext = JAXBContext.newInstance(PlayerDetails.class);
+		jaxbMarshaller = jaxbContext.createMarshaller();
+		jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+		jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+	}
+
+	@Override
+	public String marshal(PlayerDetails object) {
+		OutputStream stream = new ByteArrayOutputStream();
+		try {
+			jaxbMarshaller.marshal(object, stream);
+		} catch (JAXBException e) {
+			LOGGER.error("Exception occured while marshalling", e);
+		}
+		return stream.toString();
+	}
+
+	@Override
+	public PlayerDetails unmarshal(String objectAsString) {
+		try {
+			return (PlayerDetails) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(objectAsString.getBytes()));
+		} catch (JAXBException e) {
+			LOGGER.error("Exception occured while marshalling", e);
+		}
+		return null;
+	}
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/jaxb/generated/ObjectFactory.java

+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2012.11.05 at 09:23:22 PM CET 
+//
+
+
+package pl.grzejszczak.marcin.camel.jaxb.generated;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+
+/**
+ * This object contains factory methods for each 
+ * Java content interface and Java element interface 
+ * generated in the pl.grzejszczak.marcin.camel.jaxb.generated package. 
+ * <p>An ObjectFactory allows you to programatically 
+ * construct new instances of the Java representation 
+ * for XML content. The Java representation of XML 
+ * content can consist of schema derived interfaces 
+ * and classes representing the binding of schema 
+ * type definitions, element declarations and model 
+ * groups.  Factory methods for each of these are 
+ * provided in this class.
+ * 
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+
+    /**
+     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.grzejszczak.marcin.camel.jaxb.generated
+     * 
+     */
+    public ObjectFactory() {
+    }
+
+    /**
+     * Create an instance of {@link PlayerDetails }
+     * 
+     */
+    public PlayerDetails createPlayerDetails() {
+        return new PlayerDetails();
+    }
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/jaxb/generated/PlayerDetails.java

+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2012.11.05 at 09:23:22 PM CET 
+//
+
+
+package pl.grzejszczak.marcin.camel.jaxb.generated;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType>
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;element name="Surname" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         &lt;element name="Position" type="{}PositionType"/>
+ *         &lt;element name="Age" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         &lt;element name="TeamName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+    "name",
+    "surname",
+    "position",
+    "age",
+    "teamName"
+})
+@XmlRootElement(name = "PlayerDetails")
+public class PlayerDetails {
+
+    @XmlElement(name = "Name", required = true)
+    protected String name;
+    @XmlElement(name = "Surname", required = true)
+    protected String surname;
+    @XmlElement(name = "Position", required = true)
+    protected PositionType position;
+    @XmlElement(name = "Age")
+    protected int age;
+    @XmlElement(name = "TeamName", required = true)
+    protected String teamName;
+
+    /**
+     * Gets the value of the name property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the value of the name property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setName(String value) {
+        this.name = value;
+    }
+
+    /**
+     * Gets the value of the surname property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getSurname() {
+        return surname;
+    }
+
+    /**
+     * Sets the value of the surname property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setSurname(String value) {
+        this.surname = value;
+    }
+
+    /**
+     * Gets the value of the position property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link PositionType }
+     *     
+     */
+    public PositionType getPosition() {
+        return position;
+    }
+
+    /**
+     * Sets the value of the position property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link PositionType }
+     *     
+     */
+    public void setPosition(PositionType value) {
+        this.position = value;
+    }
+
+    /**
+     * Gets the value of the age property.
+     * 
+     */
+    public int getAge() {
+        return age;
+    }
+
+    /**
+     * Sets the value of the age property.
+     * 
+     */
+    public void setAge(int value) {
+        this.age = value;
+    }
+
+    /**
+     * Gets the value of the teamName property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getTeamName() {
+        return teamName;
+    }
+
+    /**
+     * Sets the value of the teamName property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setTeamName(String value) {
+        this.teamName = value;
+    }
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/jaxb/generated/PositionType.java

+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6 
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
+// Any modifications to this file will be lost upon recompilation of the source schema. 
+// Generated on: 2012.11.05 at 09:23:22 PM CET 
+//
+
+
+package pl.grzejszczak.marcin.camel.jaxb.generated;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for PositionType.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * &lt;simpleType name="PositionType">
+ *   &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     &lt;enumeration value="GK"/>
+ *     &lt;enumeration value="DEF"/>
+ *     &lt;enumeration value="MID"/>
+ *     &lt;enumeration value="ATT"/>
+ *   &lt;/restriction>
+ * &lt;/simpleType>
+ * </pre>
+ * 
+ */
+@XmlType(name = "PositionType")
+@XmlEnum
+public enum PositionType {
+
+    GK,
+    DEF,
+    MID,
+    ATT;
+
+    public String value() {
+        return name();
+    }
+
+    public static PositionType fromValue(String v) {
+        return valueOf(v);
+    }
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/manual/ActiveMQRouter.java

+package pl.grzejszczak.marcin.camel.manual;
+
+import java.io.File;
+import java.util.Scanner;
+
+import javax.jms.JMSException;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+import pl.grzejszczak.marcin.camel.jaxb.PlayerDetailsConverter;
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+import pl.grzejszczak.marcin.camel.manual.jms.FinalListenerImpl;
+import pl.grzejszczak.marcin.camel.manual.jms.Sender;
+
+public class ActiveMQRouter {
+
+	/**
+	 * @param args
+	 * @throws JMSException
+	 */
+	public static void main(String[] args) throws Exception {
+		ApplicationContext context = new ClassPathXmlApplicationContext("/camel/jmsApplicationContext.xml");
+		@SuppressWarnings("unchecked")
+		Sender<PlayerDetails> sender = (Sender<PlayerDetails>) context.getBean("originPlayerSender");
+
+		Resource resource = new ClassPathResource("/camel/RobertLewandowski.xml");
+
+		Scanner scanner = new Scanner(new File(resource.getURI())).useDelimiter("\\Z");
+		String contents = scanner.next();
+
+		PlayerDetailsConverter converter = context.getBean(PlayerDetailsConverter.class);
+
+		FinalListenerImpl listener = (FinalListenerImpl) context.getBean("finalListenerImpl");
+
+		sender.sendMessage(converter.unmarshal(contents));
+	}
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/manual/jms/FinalListenerImpl.java

+package pl.grzejszczak.marcin.camel.manual.jms;
+
+import javax.jms.BytesMessage;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.support.converter.MessageConverter;
+import org.springframework.stereotype.Component;
+
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+
+@Component("finalListenerImpl")
+public class FinalListenerImpl implements MessageListener {
+
+	private static final Logger LOG = LoggerFactory.getLogger(FinalListenerImpl.class);
+
+	@Autowired
+	private MessageConverter messageConverter;
+
+	@Override
+	public void onMessage(Message message) {
+		if (!(message instanceof BytesMessage)) {
+			LOG.error("Wrong msg!");
+			return;
+		}
+
+		PlayerDetails playerDetails = null;
+		try {
+			playerDetails = (PlayerDetails) messageConverter.fromMessage(message);
+
+			if (playerDetails.getTeamName() != null) {
+				LOG.debug("Message already enriched! Shutting down the system");
+				System.exit(0);
+			} else {
+				LOG.debug("The message should have been enriched but wasn't");
+				System.exit(1);
+			}
+
+		} catch (Exception e) {
+			LOG.error("Exception occured", e);
+		}
+	}
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/manual/jms/ListenerImpl.java

+package pl.grzejszczak.marcin.camel.manual.jms;
+
+import javax.jms.BytesMessage;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.jms.support.converter.MessageConverter;
+
+import pl.grzejszczak.marcin.camel.enricher.Enrichable;
+import pl.grzejszczak.marcin.camel.jaxb.Convertable;
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+
+public class ListenerImpl implements MessageListener {
+
+	private static final Logger LOG = LoggerFactory.getLogger(ListenerImpl.class);
+
+	public ListenerImpl() {
+		LOG.info("Listener is created");
+	}
+
+	@Autowired
+	private Convertable<PlayerDetails> playerDetailsConverter;
+
+	@Autowired
+	@Qualifier("enrichingService")
+	private Enrichable<PlayerDetails> enrichingService;
+
+	@Autowired
+	private MessageConverter messageConverter;
+
+	@Autowired
+	@Qualifier("destinationPlayerSender")
+	private Sender<PlayerDetails> sender;
+
+	@Override
+	public void onMessage(Message message) {
+		if (!(message instanceof BytesMessage)) {
+			LOG.error("Wrong msg!");
+			return;
+		}
+
+		PlayerDetails playerDetails = null;
+		try {
+			playerDetails = (PlayerDetails) messageConverter.fromMessage(message);
+
+			LOG.debug("Enriching the input message");
+			enrichingService.enrich(playerDetails);
+
+			LOG.debug("Enriched text message: [{}]", new Object[] { playerDetailsConverter.marshal(playerDetails) });
+			sender.sendMessage(playerDetails);
+		} catch (Exception e) {
+			LOG.error("Exception occured", e);
+		}
+
+	}
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/manual/jms/PlayerDetailsSenderImpl.java

+package pl.grzejszczak.marcin.camel.manual.jms;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.stereotype.Component;
+
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+
+@Component
+public class PlayerDetailsSenderImpl implements Sender<PlayerDetails> {
+
+	private static final Logger LOGGER = LoggerFactory.getLogger(PlayerDetailsSenderImpl.class);
+
+	private Destination destination;
+
+	@Autowired
+	private JmsTemplate jmsTemplate;
+
+	@Override
+	public void sendMessage(final PlayerDetails object) throws JMSException {
+		LOGGER.debug("Sending [{}] to topic [{}]", new Object[] { object, destination });
+		jmsTemplate.convertAndSend(destination, object);
+	}
+
+	public Destination getDestination() {
+		return destination;
+	}
+
+	public void setDestination(Destination destination) {
+		this.destination = destination;
+	}
+
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/manual/jms/Sender.java

+package pl.grzejszczak.marcin.camel.manual.jms;
+
+public interface Sender<T> {
+	void sendMessage(T object) throws Exception;
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/service/EnrichingService.java

+package pl.grzejszczak.marcin.camel.service;
+
+public interface EnrichingService {
+	void enrich();
+}

File Camel and Spring/src/main/pl/grzejszczak/marcin/camel/service/EnrichingServiceImpl.java

+package pl.grzejszczak.marcin.camel.service;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import pl.grzejszczak.marcin.camel.enricher.Enrichable;
+import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
+
+public class EnrichingServiceImpl implements Enrichable<PlayerDetails> {
+
+	private static final Logger LOGGER = LoggerFactory.getLogger(EnrichingServiceImpl.class);
+
+	@Autowired
+	private List<Enrichable<PlayerDetails>> listOfEnrichers;
+
+	@Override
+	public void enrich(PlayerDetails playerDetails) {
+		LOGGER.debug("Enriching player details");
+
+		for (Enrichable<PlayerDetails> enrichable : listOfEnrichers) {
+			enrichable.enrich(playerDetails);
+		}
+	}
+
+}

File Camel and Spring/src/resources/camel/Player.xsd

+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+	<xsd:element name="PlayerDetails">
+		<xsd:complexType>
+			<xsd:sequence>
+				<xsd:element name="Name" type="xsd:string" />
+				<xsd:element name="Surname" type="xsd:string" />
+				<xsd:element name="Position" type="PositionType" />
+				<xsd:element name="Age" type="xsd:int" />
+				<xsd:element name="TeamName" type="xsd:string" />
+			</xsd:sequence>
+		</xsd:complexType>
+	</xsd:element>
+
+
+	<xsd:simpleType name="PositionType">
+		<xsd:restriction base="xsd:string">
+			<xsd:enumeration value="GK" />
+			<xsd:enumeration value="DEF" />
+			<xsd:enumeration value="MID" />
+			<xsd:enumeration value="ATT" />
+		</xsd:restriction>
+	</xsd:simpleType>
+
+</xsd:schema>

File Camel and Spring/src/resources/camel/RobertLewandowski.xml

+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<PlayerDetails>
+    <Name>Robert</Name>
+    <Surname>Lewandowski</Surname>
+    <Position>ATT</Position>
+</PlayerDetails>

File Camel and Spring/src/resources/camel/camelContext.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" 
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">
+	
+	<import resource="classpath:/camel/jmsApplicationContext.xml" />
+	
+	<camel:camelContext id="camel" xmlns:camel="http://camel.apache.org/schema/spring">
+		<camel:package>pl.grzejszczak.marcin.camel</camel:package>
+		<camel:dataFormats>
+			<camel:jaxb id="jaxb" prettyPrint="true" contextPath="pl.grzejszczak.marcin.camel.jaxb.generated" />
+		</camel:dataFormats>
+
+		<camel:route>
+			<camel:from uri="activemq:topic:Initial.Topic" />
+			<camel:unmarshal ref="jaxb" />
+			<camel:bean ref="enrichingService" />
+			<camel:marshal ref="jaxb" />
+			<camel:to uri="activemq:topic:Routed.Topic" />
+		</camel:route>
+
+	</camel:camelContext>
+</beans>

File Camel and Spring/src/resources/camel/jms.properties

+jms.origin=Initial.Topic
+jms.destination=Routed.Topic

File Camel and Spring/src/resources/camel/jmsApplicationContext.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:jms="http://www.springframework.org/schema/jms" xmlns:oxm="http://www.springframework.org/schema/oxm"
+	xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">
+
+	<!-- Spring configuration based on annotations -->
+	<context:annotation-config />
+	<!-- Show Spring where to search for the beans (in which packages) -->
+	<context:component-scan base-package="pl.grzejszczak.marcin.camel" />
+	
+	<!-- Show Spring where to search for the properties files -->
+	<context:property-placeholder location="classpath:/camel/jms.properties" />
+
+	<!-- The ActiveMQ connection factory with specification of the server URL -->
+	<bean id="activeMQConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
+		<property name="brokerURL" value="tcp://localhost:61616" />
+	</bean>
+
+	<!-- Spring's jms connection factory -->
+	<bean id="cachingConnectionFactory"
+		class="org.springframework.jms.connection.CachingConnectionFactory">
+		<property name="targetConnectionFactory" ref="activeMQConnectionFactory" />
+		<property name="sessionCacheSize" value="10" />
+	</bean>
+
+	<!-- The name of the queue from which we will take the messages -->
+	<bean id="origin" class="org.apache.activemq.command.ActiveMQTopic">
+		<constructor-arg value="${jms.origin}" />
+	</bean>
+	<!-- The name of the queue to which we will route the messages -->
+	<bean id="destination" class="org.apache.activemq.command.ActiveMQTopic">
+		<constructor-arg value="${jms.destination}" />
+	</bean>
+
+	<!-- Configuration of the JmsTemplate together with the connection factory and the message converter -->
+	<bean id="producerTemplate" class="org.springframework.jms.core.JmsTemplate">
+		<property name="connectionFactory" ref="cachingConnectionFactory" />
+		<property name="messageConverter" ref="oxmMessageConverter" />
+	</bean>
+
+	<!-- Custom message sender sending messages to the initial queue -->
+	<bean id="originPlayerSender" class="pl.grzejszczak.marcin.camel.manual.jms.PlayerDetailsSenderImpl">
+		<property name="destination" ref="origin" />
+	</bean>
+
+	<!-- Custom message listener - listens to the destination queue  -->
+	<bean id="destinationListenerImpl" class="pl.grzejszczak.marcin.camel.manual.jms.FinalListenerImpl"/>
+
+	
+	<!-- Spring's jms message listener container - specified the connection factory, the queue to be listened to and the component that listens to the queue -->
+	<bean id="jmsDestinationContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
+		<property name="connectionFactory" ref="cachingConnectionFactory" />
+		<property name="destination" ref="destination" />
+		<property name="messageListener" ref="destinationListenerImpl" />
+	</bean>
+	
+	<!-- Message converter - automatically marshalls and unmarshalls messages using the provided marshaller / unmarshaller-->
+	<bean id="oxmMessageConverter" class="org.springframework.jms.support.converter.MarshallingMessageConverter">
+          <property name="marshaller" ref="marshaller" />
+          <property name="unmarshaller" ref="marshaller" />
+     </bean>
+
+	<bean id="enrichingService" class="pl.grzejszczak.marcin.camel.service.EnrichingServiceImpl"/>
+
+	<!-- Spring's JAXB implementation of marshaller - provided a class the JAXB generated class -->
+     <oxm:jaxb2-marshaller id="marshaller">
+          <oxm:class-to-be-bound name="pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails" />
+     </oxm:jaxb2-marshaller>
+
+</beans>

File Camel and Spring/src/resources/log4j.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+	<!-- Appenders -->
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
+		<param name="Target" value="System.out" />
+		<layout class="org.apache.log4j.PatternLayout">
+			<param name="ConversionPattern" value="%d %-5p [%t] %c:%L %m%n" />
+		</layout>
+	</appender>
+	
+	<!-- Application Loggers -->
+	<logger name="pl.grzejszczak.marcin">
+		<level value="DEBUG" />
+	</logger>
+	
+	<!-- 3rdparty Loggers -->
+	<logger name="org.springframework.core">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.beans">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.context">
+		<level value="INFO" />
+	</logger>
+
+	<logger name="org.springframework.web">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="org.springframework.security">
+		<level value="INFO" />
+	</logger>
+	
+	<logger name="com.juancavallotti.jdto">
+		<level value="WARN" />
+	</logger>
+
+
+	<!-- Root Logger -->
+	<root>
+		<priority value="INFO" />
+		<appender-ref ref="console" />
+	</root>
+	
+</log4j:configuration>

File Spring JMS/.classpath

-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" path="src/resources"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
-	<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
-	<classpathentry kind="output" path="target/classes"/>
-</classpath>

File Spring JMS/.settings/org.eclipse.core.resources.prefs

-#Sat Oct 27 14:43:01 CEST 2012
-eclipse.preferences.version=1
-encoding/<project>=UTF-8

File Spring JMS/.settings/org.eclipse.jdt.core.prefs

-#Sat Oct 27 14:43:02 CEST 2012
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.6

File Spring JMS/.settings/org.eclipse.m2e.core.prefs

-#Sun Oct 07 20:53:44 CEST 2012
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1

File Spring JMS/pom.xml

-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	<groupId>pl.grzejszczak.marcin</groupId>
-	<artifactId>spring-jms</artifactId>
-	<version>0.0.1-SNAPSHOT</version>
-
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<maven.compiler.source>1.6</maven.compiler.source>
-		<maven.compiler.target>1.6</maven.compiler.target>
-
-		<spring.version>3.1.1.RELEASE</spring.version>
-	</properties>
-	<repositories>
-		<repository>
-			<id>spring-release</id>
-			<url>http://maven.springframework.org/release</url>
-		</repository>
-		<repository>
-            <id>maven-us-nuxeo</id>
-            <url>https://maven-us.nuxeo.org/nexus/content/groups/public</url>
-        </repository>
-	</repositories>
-
-	<dependencies>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.10</version>
-		</dependency>
-		<!-- Spring -->
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-core</artifactId>
-			<version>${spring.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-beans</artifactId>
-			<version>${spring.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-context</artifactId>
-			<version>${spring.version}</version>
-		</dependency>
-		<dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-oxm</artifactId>
-            <version>${spring.version}</version>
-        </dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-log4j12</artifactId>
-			<version>1.5.2</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-lang</groupId>
-			<artifactId>commons-lang</artifactId>
-			<version>2.6</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.camel</groupId>
-			<artifactId>camel-core</artifactId>
-			<version>2.9.2</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.camel</groupId>
-			<artifactId>camel-activemq</artifactId>
-			<version>1.1.0</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.activemq</groupId>
-			<artifactId>activemq-core</artifactId>
-			<version>5.7.0</version>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-jms</artifactId>
-			<version>3.1.1.RELEASE</version>
-		</dependency>
-		<dependency>
-			<groupId>com.sun.xml.bind</groupId>
-			<artifactId>jaxb-impl</artifactId>
-			<version>2.2.6</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.camel</groupId>
-			<artifactId>camel-spring</artifactId>
-			<version>2.9.2</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.activemq</groupId>
-			<artifactId>activemq-camel</artifactId>
-			<version>5.6.0</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.camel</groupId>
-			<artifactId>camel-jms</artifactId>
-			<version>2.9.2</version>
-		</dependency>
-	</dependencies>
-</project>

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/enricher/AgeEnricher.java

-package pl.grzejszczak.marcin.camel.enricher;
-
-import java.util.Random;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
-
-@Component("AgeEnricher")
-public class AgeEnricher implements Enrichable<PlayerDetails> {
-	private static final Logger LOGGER = LoggerFactory.getLogger(AgeEnricher.class);
-
-	@Override
-	public void enrich(PlayerDetails inputObject) {
-		LOGGER.debug("Enriching player [{}] with age data", new Object[] { inputObject.getSurname() });
-		// Simulating accessing DB or some other service
-		try {
-			Thread.sleep(2000);
-		} catch (InterruptedException e) {
-			LOGGER.error("Exception while sleeping occured", e);
-		}
-		inputObject.setAge(new Random().nextInt(35));
-	}
-
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/enricher/ClubEnricher.java

-package pl.grzejszczak.marcin.camel.enricher;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
-
-@Component("ClubEnricher")
-public class ClubEnricher implements Enrichable<PlayerDetails> {
-
-	private static final Logger LOGGER = LoggerFactory.getLogger(ClubEnricher.class);
-
-	@Override
-	public void enrich(PlayerDetails inputObject) {
-		LOGGER.debug("Enriching player [{}] with club data", new Object[] { inputObject.getSurname() });
-		// Simulating accessing DB or some other service
-		try {
-			Thread.sleep(2000);
-		} catch (InterruptedException e) {
-			LOGGER.error("Exception while sleeping occured", e);
-		}
-		inputObject.setTeamName("Borussia Dortmund");
-	}
-
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/enricher/Enrichable.java

-package pl.grzejszczak.marcin.camel.enricher;
-
-public interface Enrichable<T> {
-	void enrich(T inputObject);
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/jaxb/Convertable.java

-package pl.grzejszczak.marcin.camel.jaxb;
-
-public interface Convertable<T> {
-	String marshal(T object);
-
-	T unmarshal(String objectAsString);
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/jaxb/PlayerDetailsConverter.java

-package pl.grzejszczak.marcin.camel.jaxb;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.activemq.util.ByteArrayInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
-
-@Component("PlayerDetailsConverter")
-public class PlayerDetailsConverter implements Convertable<PlayerDetails> {
-	private static final Logger LOGGER = LoggerFactory.getLogger(PlayerDetailsConverter.class);
-
-	private final JAXBContext jaxbContext;
-	private final Marshaller jaxbMarshaller;
-	private final Unmarshaller jaxbUnmarshaller;
-
-	public PlayerDetailsConverter() throws JAXBException {
-		jaxbContext = JAXBContext.newInstance(PlayerDetails.class);
-		jaxbMarshaller = jaxbContext.createMarshaller();
-		jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-		jaxbUnmarshaller = jaxbContext.createUnmarshaller();
-	}
-
-	@Override
-	public String marshal(PlayerDetails object) {
-		OutputStream stream = new ByteArrayOutputStream();
-		try {
-			jaxbMarshaller.marshal(object, stream);
-		} catch (JAXBException e) {
-			LOGGER.error("Exception occured while marshalling", e);
-		}
-		return stream.toString();
-	}
-
-	@Override
-	public PlayerDetails unmarshal(String objectAsString) {
-		try {
-			return (PlayerDetails) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(objectAsString.getBytes()));
-		} catch (JAXBException e) {
-			LOGGER.error("Exception occured while marshalling", e);
-		}
-		return null;
-	}
-
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/jaxb/generated/ObjectFactory.java

-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6 
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
-// Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2012.11.05 at 09:23:22 PM CET 
-//
-
-
-package pl.grzejszczak.marcin.camel.jaxb.generated;
-
-import javax.xml.bind.annotation.XmlRegistry;
-
-
-/**
- * This object contains factory methods for each 
- * Java content interface and Java element interface 
- * generated in the pl.grzejszczak.marcin.camel.jaxb.generated package. 
- * <p>An ObjectFactory allows you to programatically 
- * construct new instances of the Java representation 
- * for XML content. The Java representation of XML 
- * content can consist of schema derived interfaces 
- * and classes representing the binding of schema 
- * type definitions, element declarations and model 
- * groups.  Factory methods for each of these are 
- * provided in this class.
- * 
- */
-@XmlRegistry
-public class ObjectFactory {
-
-
-    /**
-     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.grzejszczak.marcin.camel.jaxb.generated
-     * 
-     */
-    public ObjectFactory() {
-    }
-
-    /**
-     * Create an instance of {@link PlayerDetails }
-     * 
-     */
-    public PlayerDetails createPlayerDetails() {
-        return new PlayerDetails();
-    }
-
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/jaxb/generated/PlayerDetails.java

-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6 
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
-// Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2012.11.05 at 09:23:22 PM CET 
-//
-
-
-package pl.grzejszczak.marcin.camel.jaxb.generated;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for anonymous complex type.
- * 
- * <p>The following schema fragment specifies the expected content contained within this class.
- * 
- * <pre>
- * &lt;complexType>
- *   &lt;complexContent>
- *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       &lt;sequence>
- *         &lt;element name="Name" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         &lt;element name="Surname" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         &lt;element name="Position" type="{}PositionType"/>
- *         &lt;element name="Age" type="{http://www.w3.org/2001/XMLSchema}int"/>
- *         &lt;element name="TeamName" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       &lt;/sequence>
- *     &lt;/restriction>
- *   &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- * 
- * 
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {
-    "name",
-    "surname",
-    "position",
-    "age",
-    "teamName"
-})
-@XmlRootElement(name = "PlayerDetails")
-public class PlayerDetails {
-
-    @XmlElement(name = "Name", required = true)
-    protected String name;
-    @XmlElement(name = "Surname", required = true)
-    protected String surname;
-    @XmlElement(name = "Position", required = true)
-    protected PositionType position;
-    @XmlElement(name = "Age")
-    protected int age;
-    @XmlElement(name = "TeamName", required = true)
-    protected String teamName;
-
-    /**
-     * Gets the value of the name property.
-     * 
-     * @return
-     *     possible object is
-     *     {@link String }
-     *     
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Sets the value of the name property.
-     * 
-     * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
-     */
-    public void setName(String value) {
-        this.name = value;
-    }
-
-    /**
-     * Gets the value of the surname property.
-     * 
-     * @return
-     *     possible object is
-     *     {@link String }
-     *     
-     */
-    public String getSurname() {
-        return surname;
-    }
-
-    /**
-     * Sets the value of the surname property.
-     * 
-     * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
-     */
-    public void setSurname(String value) {
-        this.surname = value;
-    }
-
-    /**
-     * Gets the value of the position property.
-     * 
-     * @return
-     *     possible object is
-     *     {@link PositionType }
-     *     
-     */
-    public PositionType getPosition() {
-        return position;
-    }
-
-    /**
-     * Sets the value of the position property.
-     * 
-     * @param value
-     *     allowed object is
-     *     {@link PositionType }
-     *     
-     */
-    public void setPosition(PositionType value) {
-        this.position = value;
-    }
-
-    /**
-     * Gets the value of the age property.
-     * 
-     */
-    public int getAge() {
-        return age;
-    }
-
-    /**
-     * Sets the value of the age property.
-     * 
-     */
-    public void setAge(int value) {
-        this.age = value;
-    }
-
-    /**
-     * Gets the value of the teamName property.
-     * 
-     * @return
-     *     possible object is
-     *     {@link String }
-     *     
-     */
-    public String getTeamName() {
-        return teamName;
-    }
-
-    /**
-     * Sets the value of the teamName property.
-     * 
-     * @param value
-     *     allowed object is
-     *     {@link String }
-     *     
-     */
-    public void setTeamName(String value) {
-        this.teamName = value;
-    }
-
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/jaxb/generated/PositionType.java

-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6 
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
-// Any modifications to this file will be lost upon recompilation of the source schema. 
-// Generated on: 2012.11.05 at 09:23:22 PM CET 
-//
-
-
-package pl.grzejszczak.marcin.camel.jaxb.generated;
-
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for PositionType.
- * 
- * <p>The following schema fragment specifies the expected content contained within this class.
- * <p>
- * <pre>
- * &lt;simpleType name="PositionType">
- *   &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     &lt;enumeration value="GK"/>
- *     &lt;enumeration value="DEF"/>
- *     &lt;enumeration value="MID"/>
- *     &lt;enumeration value="ATT"/>
- *   &lt;/restriction>
- * &lt;/simpleType>
- * </pre>
- * 
- */
-@XmlType(name = "PositionType")
-@XmlEnum
-public enum PositionType {
-
-    GK,
-    DEF,
-    MID,
-    ATT;
-
-    public String value() {
-        return name();
-    }
-
-    public static PositionType fromValue(String v) {
-        return valueOf(v);
-    }
-
-}

File Spring JMS/src/main/pl/grzejszczak/marcin/camel/manual/ActiveMQRouter.java

-package pl.grzejszczak.marcin.camel.manual;
-
-import java.io.File;
-import java.util.Scanner;
-
-import javax.jms.JMSException;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-
-import pl.grzejszczak.marcin.camel.jaxb.PlayerDetailsConverter;
-import pl.grzejszczak.marcin.camel.jaxb.generated.PlayerDetails;
-import pl.grzejszczak.marcin.camel.manual.jms.Sender;
-
-public class ActiveMQRouter {
-
-	/**
-	 * @param args
-	 * @throws JMSException
-	 */
-	public static void main(String[] args) throws Exception {
-		ApplicationContext context = new ClassPathXmlApplicationContext("/camel/jmsApplicationContext.xml");
-		@SuppressWarnings("unchecked")
-		Sender<PlayerDetails> sender = (Sender<PlayerDetails>) context.getBean("originPlayerSender");
-
-		Resource resource = new ClassPathResource("/camel/RobertLewandowski.xml");
-
-		Scanner scanner = new Scanner(new File(resource.getURI())).useDelimiter("\\Z");
-		String contents = scanner.next();
-
-		PlayerDetailsConverter converter = context.getBean(PlayerDetailsConverter.class);
-
-		sender.sendMessage(converter.unmarshal(contents));