integration session print -...

40
2012 © Trivadis BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN Java Lounge Integration Solutions made Easy – Comparison of Java Integration Frameworks Mario Goller 28.05.2013 31.05.2013 Integration Solutions made Easy 1

Transcript of integration session print -...

2012 © Trivadis

BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN

Java Lounge Integration Solutions made Easy –

Comparison of Java Integration Frameworks

Mario Goller

28.05.2013

31.05.2013Integration Solutions made Easy

1

2012 © Trivadis

AGENDA

1. Enterprise Integration (Patterns)

2. Spring Integration

3. Apache Camel

4. Mule ESB

5. Conclusion

31.05.2013Integration Solutions made Easy

2

2012 © Trivadis

Enterprise Integration

� Everybody communicates to everybody

31.05.2013Integration Solutions made Easy

3

2012 © Trivadis

Enterprise Integration

� Only for specialists?

31.05.2013Integration Solutions made Easy

4

2012 © Trivadis

Enterprise Integration Patterns

Goals

� Standardized Modeling

� Efficient Realization

� Automatic Testing

http://enterpriseintegrationpatterns.com

31.05.2013Integration Solutions made Easy

5

2012 © Trivadis

Enterprise Integration Patterns

31.05.2013Integration Solutions made Easy

6

2012 © Trivadis

Why Enterprise Integration Frameworks?

31.05.2013Integration Solutions made Easy

7

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");

Connection connection = connectionFactory.createConnection();

connection.start();

int autoAck = Session.AUTO_ACKNOWLEDGE;

Session session = connection.createSession(false, autoAck);

Destination queue = new ActiveMQQueue("siia.queue.order");

MessageProducer producer = session.createProducer(queue);

MessageConsumer consumer = session.createConsumer(queue);

Message messageToSend = session.createTextMessage(orderFileContent.toString());

producer.send(messageToSend);

Message receivedMessage = consumer.receive(5000);

if (!(receivedMessage instanceof TextMessage)) {

throw new RuntimeException("expected a TextMessage");

}

String text = ((TextMessage) receivedMessage).getText();

connection.close();

Writing Glue Code?

2012 © Trivadis

Why Enterprise Integration Frameworks?

31.05.2013Integration Solutions made Easy

8

Keep it simple with DSL

from("file://inbox/order").to("jms:queue:order?jmsMessageType=Text");

<from uri="file:inbox/order?noop=true« />

<to uri="jms:queue:order?jmsMessageType=Text "/>

2012 © Trivadis

Enterprise Integration Frameworks

� Why do we need Integration?� Your apps are build using different tech stacks� Critical for your business to integrate

� Why Integration Frameworks?� Framework do the heavy lifting� Focus on business problem� Not "reinventing the wheel"

31.05.2013Integration Solutions made Easy

9

2012 © Trivadis

Why Enterprise Integration Frameworks?

31.05.2013Integration Solutions made Easy

10

Making integration easier and more accessible to developers

2012 © Trivadis

AGENDA

1. Enterprise Integration (Patterns)

2. Spring Integration

3. Apache Camel

4. Mule ESB

5. Conclusion

31.05.2013Integration Solutions made Easy

11

2012 © Trivadis

Spring Integration Framework

� Is a “routing” and “mediation” framework

� Can be used from within an existing application.

� Lightweight (like any Spring application):� run from JUnit test� run within webapp

� Focussed on messaging and integration

� Not an ESB

� Based on Java Business Integration Spec.� (Mediated Message Exchange Model)

� Apache License

31.05.2013Integration Solutions made Easy

12

2012 © Trivadis

Goals of Spring Integration

� Provide a simple model for implementing complex enterprise integration solutions

� Facilitate asynchronous, message-driven behavior within a Spring-based application

31.05.2013Integration Solutions made Easy

13

2012 © Trivadis

Spring Integration Building Blocks

The Spring Integration framework is built on a few basic building blocks:

� Messages

� represents a container for information data

� Channels (Message Channels)� represents the location where message is being sent� Out of the box: QueueChannel, PriorityChannel, RendezvousChannel, …

31.05.2013Integration Solutions made Easy

14

2012 © Trivadis

Spring Integration Building Blocks

� Endpoints

� Endpoints are basically components that consume messages from an input channel and deliver to an output channel

� several out-of-the-box endpoints� Transformer / Filter� Splitter / Aggregator� Router� Service Activator

31.05.2013Integration Solutions made Easy

15

2012 © Trivadis

Spring Integration

Channel Adapters

� Endpoint that connects a Message Channel to some other system or transport

� Lot of build-in Integration Adapters� AMQP, Feed, File, FTP(S), SFTP, HTTP, TCP, UDP, JDBC, JMS, JPA, Mail, MongoDB,

RMI, Stream, Twitter, Web Service, XML, XMPP

� There is also a Spring Integration Extensions project:� Repo: https://github.com/SpringSource/spring-integration-extensions� XQuery Adapter, AWS Adapter, SMB Adapter, …

31.05.2013Integration Solutions made Easy

16

2012 © Trivadis

Spring Integration – XML DSL

31.05.2013Integration Solutions made Easy

17

<int-file:outbound-channel-adapter

id="otherFilesOut" directory="file:target/output/other« delete-source-files="true" />

<int-file:outbound-channel-adapter

id="xmlFilesOut" directory="file:target/output/xml« delete-source-files="true" />

<int-file:outbound-channel-adapter

id="csvFilesOut" directory="file:target/output/csv« delete-source-files="true" />

<int:logging-channel-adapter id="loggingChannel"

level="INFO" expression="'Processing file: ' + payload " />

<int:channel id="xmlFilesTemp">

<int:interceptors>

<int:wire-tap channel="loggingChannel" />

</int:interceptors>

</int:channel>

2012 © Trivadis

Spring Integration IDE – STS

31.05.2013Integration Solutions made Easy

18

2012 © Trivadis

AGENDA

1. Enterprise Integration (Patterns)

2. Spring Integration

3. Apache Camel

4. Mule ESB

5. Conclusion

31.05.2013Integration Solutions made Easy

19

2012 © Trivadis

Camel - Feature Overview

� Integration framework� Lightweight� Set of jar files

� Deployment� JVM, Tomcat, JBoss, Websphere,

Weblogic

� Feature rich� Enterprise Integration Patterns� 70+ technology adapters

� Simple programming� Java DSL, Spring XML, Scala, Groovy

31.05.2013Integration Solutions made Easy

20

� Add ons, data formats� Twitter, FIX, HL7,…

� Scalability primitives

� Apache License

2012 © Trivadis

Camel - Connectivity

31.05.2013Integration Solutions made Easy

21

2012 © Trivadis

Apache Camel - Concepts

� CamelContext (collection of Components)

� Components provide an Endpoint interface

� A Component is essentially a factory of Endpoint instances� only 12 essential components. There are over 60 components outside the core

� By using URIs, you can send or receive messages on Endpoints in a uniform way. By specifying a endpoint URI, you can identify the component you want to use and how that component is configured

31.05.2013Integration Solutions made Easy

22

2012 © Trivadis

Apache Camel - Concepts

31.05.2013Integration Solutions made Easy

23

2012 © Trivadis

Apache Camel - IDE

31.05.2013Integration Solutions made Easy

24

2012 © Trivadis

Camel Route DSL

31.05.2013Integration Solutions made Easy

25

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

<route>

<from uri="file:src/data?noop=true"/>

<choice>

<when>

<xpath>/destination/country = 'CH'</xpath>

<log message="CH order"/>

<to uri="file:target/orders/ch"/>

</when>

<otherwise>

<log message="Other order"/>

<to uri="file:target/orders/others"/>

</otherwise>

</choice>

</route>

</camelContext>

from("file:src/data?noop=true")

.choice()

.when(xpath("/destination/country = 'CH'"))

.to("file:target/orders/ch")

.otherwise()

.to("file:target/orders/others");

XML

Java DSL

2012 © Trivadis

Automatic Unit and Integration Tests

Test Kit

� camel-test.jar

� JUnit based (3.x and 4.x)

� Supports Spring

� Quick prototyping

31.05.2013Integration Solutions made Easy

26

extendsextendsCamelTestSupport

Right Click ->Right Click ->RunDebug

Inline RouteBuilder

2012 © Trivadis

AGENDA

1. Enterprise Integration (Patterns)

2. Spring Integration

3. Apache Camel

4. Mule ESB

5. Conclusion

31.05.2013Integration Solutions made Easy

27

2012 © Trivadis

Mule ESB

� Mule is a Java-based enterprise service bus (ESB) and integration platform that allows developers to quickly and easily connect applications to exchange data

� Open Source Project

� MuleSoft (www.mulesoft.org)� Mule Forge� Mule Enterprise� Mule MQ� Tcat Server

� lightweight integration platform and service container

� Common Public Attribution License (CPAL)

31.05.2013Integration Solutions made Easy

28

2012 © Trivadis

Mule ESB – Big Picture

31.05.2013Integration Solutions made Easy

29

www.mulesoft.org

2012 © Trivadis

Mule Application Achitecture

� Message Source

� Message Processor

� Endpoints� Transformers� Filters� Flow Controls� Components� Connectors

� Endpoints (Inbound / Outbound)

� Connectors provide an abstraction layer over data transport mechanisms. Connectors exist for things such as files, email messages, databases, JMS, …

31.05.2013Integration Solutions made Easy

30

2012 © Trivadis

Mule Application Achitecture

Flow

� Mule applications accept and process messages through several Lego-block-like message processors plugged together in what we call a flow

31.05.2013Integration Solutions made Easy

31

Inbound

EndpointTransformer Filters Routers Anything…

2012 © Trivadis

Mule Application Achitecture

Flow Example

31.05.2013Integration Solutions made Easy

32

2012 © Trivadis

Mule Features

� No prescribed message format� XML, CSV, Binary, Streams, Record, Java Objects� Mix and match

� Existing objects can be managed� POJOs, IoC Objects, EJB Session Beans, Remote

Objects� REST & Web Services

� Easy to test� Mule can be run easily from a JUnit test case� Framework provides a Test

31.05.2013Integration Solutions made Easy

33

2012 © Trivadis

Mule Flow - Example

31.05.2013Integration Solutions made Easy

34

<flow name="fulfillment" doc:name="fulfillment">

<file:inbound-endpoint path="src/data"/>

<choice doc:name="Choice">

<when expression="#[xpath('/destination/country').text] == 'CH']">

<file:outbound-endpoint path="target/orders/ch" doc:name="CH Order"/>

</when>

<otherwise>

<file:outbound-endpoint path="target/orders/others" doc:name="Other Order"/>

</otherwise>

</choice>

</flow>

<flow name="fulfillment" doc:name="fulfillment">

<file:inbound-endpoint path="src/data"/>

<choice doc:name="Choice">

<when expression="#[xpath('/destination/country').text] == 'CH']">

<file:outbound-endpoint path="target/orders/ch" doc:name="CH Order"/>

</when>

<otherwise>

<file:outbound-endpoint path="target/orders/others" doc:name="Other Order"/>

</otherwise>

</choice>

</flow>

2012 © Trivadis

Mule - Connectivity

31.05.2013Integration Solutions made Easy

35

2012 © Trivadis

Mule Studio IDE

31.05.2013Integration Solutions made Easy

36

2012 © Trivadis

AGENDA

1. Enterprise Integration (Patterns)

2. Spring Integration

3. Apache Camel

4. Mule ESB

5. Conclusion

31.05.2013Integration Solutions made Easy

37

2012 © Trivadis

Which Framework should I use?

� Spring Project

� „Typical“ JVM Technologies

� No additional Framework

� One of the available proprietaryConnectors is required (more restrictive commercial license)

� In all other Cases

31.05.2013Integration Solutions made Easy

38

2012 © Trivadis

Questions?

31.05.2013Integration Solutions made Easy

39

2012 © Trivadis

BASEL BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MÜNCHEN STUTTGART WIEN

THANK YOU.Trivadis AG

Mario Goller

Europastrasse 5CH-8152 Glattbrugg (ZH)

Tel. +41-44-808 70 20Fax +41-44-808 70 21

[email protected]

27.04.2012Java Web Services

40