Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Enterprise Integration Patterns with Java EE

Enterprise Integration Patterns with Java EE

Alexander Heusingfeld

September 23, 2013
Tweet

More Decks by Alexander Heusingfeld

Other Decks in Programming

Transcript

  1. We take care of it - personally! © 2013 innoQ

    Deutschland GmbH Enterprise Integration Patterns Enterprise Application Integration with Java EE Alexander Heusingfeld, @goldstift, #j1eai
  2. © 2013 innoQ Deutschland GmbH Patterns for EAI Design Patterns

    (Gamma et al), 1994 Proven solutions for common problems
  3. © 2013 innoQ Deutschland GmbH Patterns for EAI Design Patterns

    (Gamma et al), 1994 Proven solutions for common problems Enterprise Integration Patterns (Hohpe & Woolf), 2003
  4. © 2013 innoQ Deutschland GmbH Patterns for EAI Design Patterns

    (Gamma et al), 1994 Proven solutions for common problems Enterprise Integration Patterns (Hohpe & Woolf), 2003 Swiss-army knife for asynchronous messaging
  5. © 2013 innoQ Deutschland GmbH Patterns for EAI Design Patterns

    (Gamma et al), 1994 Proven solutions for common problems Enterprise Integration Patterns (Hohpe & Woolf), 2003 Swiss-army knife for asynchronous messaging www.eaipatterns.com
  6. © 2013 innoQ Deutschland GmbH “We all believe that asynchronous

    messaging carries the greatest promise.” - Martin Fowler (Enterprise Integration Patterns, 2003)
  7. © 2013 innoQ Deutschland GmbH Benefits of async. Messaging decoupled

    integrated platforms/ languages reliable communication
  8. © 2013 innoQ Deutschland GmbH Benefits of async. Messaging decoupled

    integrated platforms/ languages reliable communication disconnected
  9. © 2013 innoQ Deutschland GmbH Benefits of async. Messaging decoupled

    integrated platforms/ languages reliable communication disconnected throttled
  10. We take care of it - personally! © 2013 innoQ

    Deutschland GmbH But why those Patterns?
  11. © 2013 innoQ Deutschland GmbH Thoughts on EAI patterns not

    invented, but observed don’t solve everything
  12. © 2013 innoQ Deutschland GmbH Thoughts on EAI patterns not

    invented, but observed don’t solve everything provide ideas
  13. © 2013 innoQ Deutschland GmbH Thoughts on EAI patterns not

    invented, but observed don’t solve everything provide ideas good ones evolve
  14. © 2013 innoQ Deutschland GmbH Thoughts on EAI patterns not

    invented, but observed don’t solve everything provide ideas good ones evolve changes are incorporated at eaipatterns.com
  15. © 2013 innoQ Deutschland GmbH Simple order management system (CRUD)

    Real Life Scenario order management system • basic Java EE
  16. © 2013 innoQ Deutschland GmbH Simple order management system (CRUD)

    Real Life Scenario order management system • basic Java EE • Just CRUD operations
  17. © 2013 innoQ Deutschland GmbH Simple order management system (CRUD)

    Real Life Scenario order management system • basic Java EE • Just CRUD operations • “information silo”
  18. © 2013 innoQ Deutschland GmbH Simple order management system (CRUD)

    Real Life Scenario order management system • basic Java EE • Just CRUD operations • “information silo”
  19. © 2013 innoQ Deutschland GmbH Enhance the system with an

    importer! Simple Change order management system
  20. © 2013 innoQ Deutschland GmbH Enhance the system with an

    importer! Simple Change • Receive CSV-data via HTTP POST order management system
  21. © 2013 innoQ Deutschland GmbH Enhance the system with an

    importer! Simple Change • Receive CSV-data via HTTP POST • CSV contains header and detail records order management system
  22. © 2013 innoQ Deutschland GmbH Enhance the system with an

    importer! Simple Change • Receive CSV-data via HTTP POST • CSV contains header and detail records • Import data into database order management system
  23. © 2013 innoQ Deutschland GmbH A Simple Java EE sample

    @WebServlet(urlPatterns = {"/order/import"}) public class ImporterServlet extends HttpServlet { @Inject OrderBean bean; @Inject CsvDataParser parser; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("csvdata"); List<Order> orders = parser.transform(data); for (Order order : orders) { bean.persist(order); } } }
  24. © 2013 innoQ Deutschland GmbH Enhanced the system with an

    importer! System Simple Change done order management system HTTP csv Transform Business Partner
  25. © 2013 innoQ Deutschland GmbH Integrate the system of a

    forwarder System Change happens order management system HTTP csv Transform Business Partner forwarder system FTP SMTP SOAP WSSE REST
  26. © 2013 innoQ Deutschland GmbH Build an easy and maintainable

    solution for multiple integration challenges?
  27. © 2013 innoQ Deutschland GmbH Something wrong here? @WebServlet(urlPatterns =

    {"/order/import"}) public class ImporterServlet extends HttpServlet { @Inject OrderBean bean; @Inject CsvDataParser parser; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("csvdata"); List<Order> orders = parser.transform(data); for (Order order : orders) { bean.persist(order); } } }
  28. © 2013 innoQ Deutschland GmbH Something wrong here? @WebServlet(urlPatterns =

    {"/order/import"}) public class ImporterServlet extends HttpServlet { @Inject OrderBean bean; @Inject CsvDataParser parser; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("csvdata"); List<Order> orders = parser.transform(data); for (Order order : orders) { bean.persist(order); } } } testable?
  29. © 2013 innoQ Deutschland GmbH Something wrong here? @WebServlet(urlPatterns =

    {"/order/import"}) public class ImporterServlet extends HttpServlet { @Inject OrderBean bean; @Inject CsvDataParser parser; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("csvdata"); List<Order> orders = parser.transform(data); for (Order order : orders) { bean.persist(order); } } } testable? reusable?
  30. © 2013 innoQ Deutschland GmbH Something wrong here? @WebServlet(urlPatterns =

    {"/order/import"}) public class ImporterServlet extends HttpServlet { @Inject OrderBean bean; @Inject CsvDataParser parser; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("csvdata"); List<Order> orders = parser.transform(data); for (Order order : orders) { bean.persist(order); } } } testable? reusable? extensible?
  31. © 2013 innoQ Deutschland GmbH Pipes and Filters divide your

    task into small steps http://www.enterpriseintegrationpatterns.com/PipesAndFilters.html
  32. © 2013 innoQ Deutschland GmbH Route Pipe Apply pipes &

    filters pattern Pipe outbound transform inbound
  33. © 2013 innoQ Deutschland GmbH Route Pipe Apply pipes &

    filters pattern Pipe outbound transform inbound Servlet
  34. © 2013 innoQ Deutschland GmbH Route Pipe Apply pipes &

    filters pattern Pipe outbound transform inbound Servlet Custom
  35. © 2013 innoQ Deutschland GmbH Route Pipe Apply pipes &

    filters pattern Pipe outbound transform inbound Servlet Custom JPA
  36. © 2013 innoQ Deutschland GmbH A simple camel route from("jetty:http://localhost:9080/order/import")

    .routeId(“orderimport”) .process(new PostParameterProcessor(“csvdata”)) .process(new StringRemover(new String[]{"\""})) .unmarshal().csv() .split(body(List.class)) .aggregate(header("orderId"), new StringAggregationStrategy()).completionTimeout(3000) .to("seda:singlepartsroute");
  37. © 2013 innoQ Deutschland GmbH Spring Integration sample <int-http:inbound-channel-adapter !

    id="orderImportHttpAdapter" ! path="/order/import” supported-methods="POST" ! channel="ordersIn"/> <int:channel="ordersIn"/> <int:splitter input-channel="ordersIn" ref="orderSplitter" method="split" output-channel="ordersToDB" /> <bean id="orderSplitter" class="com.innoq.samples.eai.OrderSplitter"/> <int:channel="ordersToDB"/> <int-jpa:updating-outbound-gateway request-channel="ordersToDB" entity-class="com.innoq.samples.eai.domain.Order" entity-manager="em"/>
  38. © 2013 innoQ Deutschland GmbH Further tips considering EAI small

    building blocks no shared mutable state use immutable DTOs
  39. © 2013 innoQ Deutschland GmbH Further tips considering EAI small

    building blocks no shared mutable state use immutable DTOs => increased scalability
  40. © 2013 innoQ Deutschland GmbH Further tips considering EAI small

    building blocks no shared mutable state use immutable DTOs => increased scalability advanced: see “SEDA” & “actor model”
  41. We take care of it - personally! © 2013 innoQ

    Deutschland GmbH Thanks for your attention! Alexander Heusingfeld, @goldstift [email protected] http://www.innoq.com/de/talks twitter #j1eai - speakerdeck