Styles of Application Integration    Using Spring    Bruce Snyder, Senior Software Engineer, SpringSource/VMwareFriday, Ju...
Integrations Are About Coupling                                      2Friday, July 15, 2011
Where Coupling Exists, Concerns Arise    • Tight coupling is easy    • Loose coupling can be difficult    • Tight coupling...
What is Coupling?           “... the degree to which each program module relies           on each one of the other modules...
Characteristics Tight Coupling    •    Components are highly dependent upon one another    •    Components are directly li...
Characteristics of Loose Coupling    •    Components have little or no knowledge of one another    •    Components are not...
Tight Coupling is Easy    •    App design with tight coupling is more widely understood    •    App development with tight...
Loose Coupling is Difficult    • App design with loose coupling is not widely understood    • App development with loosely...
Integrations and Coupling    • But it’s easy to write a point-to-point, one-off piece of code      for integration!    • T...
Integrations and Coupling    • But designing integrations to be loosely coupled requires      too much work!    • With the...
Commands vs. Events    • Commands are not natural          – Verify credit card    • Commands are too specific    • Events...
Enterprise Integration Patterns (EIP)                        http://enterpriseintegrationpatterns.com/                    ...
Spring Integration    • Provides both concurrency and messaging          – Message Endpoints                 • Connections...
Spring Integration    • Supports          –    AMQP          –    Email          –    File system          –    Gemfire   ...
Spring Integration                         15Friday, July 15, 2011
Spring Integration                         16Friday, July 15, 2011
Spring Integration                         17Friday, July 15, 2011
Spring Integration                         18Friday, July 15, 2011
Spring Integration                         19Friday, July 15, 2011
Spring Integration                         20Friday, July 15, 2011
Spring Integration                         21Friday, July 15, 2011
Spring Integration                         22Friday, July 15, 2011
Spring Integration                         23Friday, July 15, 2011
Spring Integration                         24Friday, July 15, 2011
Types of Integration    • Intra-application integration    • Inter-application integration    • External system integratio...
Typical Application Layers                                 26Friday, July 15, 2011
Intra-Application Integration                                    27Friday, July 15, 2011
Spring Integration Config   <int:gateway id="sender"     service-interface="org.bsnyder.spring.integration.simple.Sender"/...
Intra-Application Integration                                    29Friday, July 15, 2011
Spring Integration Config   <int:gateway id="sender"     service-interface="org.bsnyder.spring.integration.appa.Sender"/> ...
Spring Integration Config   <amqp:inbound-channel-adapter channel="orderReceived"     queue-names="order.received.queue"  ...
32Friday, July 15, 2011
Inter-Application Integration                                    33Friday, July 15, 2011
Inter-Application Integration                                    34Friday, July 15, 2011
Spring Integration Config   <int:gateway id="sender"     service-interface="org.bsnyder.spring.integration.appa.Sender"/> ...
Spring Integration Config   <amqp:inbound-channel-adapter channel="orderReceived"     queue-names="order.received.queue"  ...
37Friday, July 15, 2011
External System Integration                                  38Friday, July 15, 2011
Spring Integration Config   <int:gateway id="sender"     service-interface="org.bsnyder.spring.integration.appa.Sender"/> ...
Spring Integration Config   <int:channel id="ftpChannel">      <int:queue/>   </int:channel>   <bean id="ftpClientFactory"...
41Friday, July 15, 2011
Combined Integration                           42Friday, July 15, 2011
Thank You!           Q&AFriday, July 15, 2011
Upcoming SlideShare
Loading in …5
×

Styles of Applicaton Integration Using Spring

2,711 views

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,711
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
33
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Styles of Applicaton Integration Using Spring

  1. 1. Styles of Application Integration Using Spring Bruce Snyder, Senior Software Engineer, SpringSource/VMwareFriday, July 15, 2011
  2. 2. Integrations Are About Coupling 2Friday, July 15, 2011
  3. 3. Where Coupling Exists, Concerns Arise • Tight coupling is easy • Loose coupling can be difficult • Tight coupling causes issues in the long run • Loose coupling pays off in the long run • Integrations are usually tightly coupled • Integrations should be loosely coupled • Integrations are commonly addressed using commands • Integrations should be addressed using eventsFriday, July 15, 2011
  4. 4. What is Coupling? “... the degree to which each program module relies on each one of the other modules” (Wikipedia.com) • Given two lines of code, A and B, they are coupled when B must change behavior only because A changed 4Friday, July 15, 2011
  5. 5. Characteristics Tight Coupling • Components are highly dependent upon one another • Components are directly linked • Changes in one component cause a ripple effect • Less reusability • More difficult to maintain • Does not handle unforeseen change well • Examples – Clients designed to interact only with specific systems – Use of proprietary APIs or commands for interaction – Components designed to work specifically with other components 5Friday, July 15, 2011
  6. 6. Characteristics of Loose Coupling • Components have little or no knowledge of one another • Components are not directly linked to one another • Changes in one component do not affect other components • Increased reusability • Easier to maintain • More easily handles unforeseen changes • Examples – Dependence upon interfaces instead of concrete classes – Use of DI encourages looser coupling – A design using a level of indirection 6Friday, July 15, 2011
  7. 7. Tight Coupling is Easy • App design with tight coupling is more widely understood • App development with tight coupling requires less time • Debugging a tightly coupled app is easier • Benefits of tight coupling are seen immediately • Tightly coupled prototypes commonly live on 7Friday, July 15, 2011
  8. 8. Loose Coupling is Difficult • App design with loose coupling is not widely understood • App development with loosely coupling requires more thought and more time • Debugging loosely coupled apps is different • Benefits of loose coupling are only seen over time 8Friday, July 15, 2011
  9. 9. Integrations and Coupling • But it’s easy to write a point-to-point, one-off piece of code for integration! • Too many disadvantages – Difficult to maintain – No reusability – Every integration is unique – Bites you over time 9Friday, July 15, 2011
  10. 10. Integrations and Coupling • But designing integrations to be loosely coupled requires too much work! • With the right knowledge and preparation, it doesn’t need to be this way 10Friday, July 15, 2011
  11. 11. Commands vs. Events • Commands are not natural – Verify credit card • Commands are too specific • Events are natural – Order received • Events are more broad • Events are what happen in the real world 11Friday, July 15, 2011
  12. 12. Enterprise Integration Patterns (EIP) http://enterpriseintegrationpatterns.com/ 12Friday, July 15, 2011
  13. 13. Spring Integration • Provides both concurrency and messaging – Message Endpoints • Connections between services – Channel Adapters • Adapter between application and message broker – Messaging Gateways • Provides uni-directional or bi-directional messaging – Service Activators • Invokes a services based on an incoming message – Routers • Determines where to dispatch a message – Splitters and Aggregators • Breaks up a message and reassembles it after processing 13Friday, July 15, 2011
  14. 14. Spring Integration • Supports – AMQP – Email – File system – Gemfire – JMS – JMX – MongoDB – Redis – Spring Batch – Testing – Web Services 14Friday, July 15, 2011
  15. 15. Spring Integration 15Friday, July 15, 2011
  16. 16. Spring Integration 16Friday, July 15, 2011
  17. 17. Spring Integration 17Friday, July 15, 2011
  18. 18. Spring Integration 18Friday, July 15, 2011
  19. 19. Spring Integration 19Friday, July 15, 2011
  20. 20. Spring Integration 20Friday, July 15, 2011
  21. 21. Spring Integration 21Friday, July 15, 2011
  22. 22. Spring Integration 22Friday, July 15, 2011
  23. 23. Spring Integration 23Friday, July 15, 2011
  24. 24. Spring Integration 24Friday, July 15, 2011
  25. 25. Types of Integration • Intra-application integration • Inter-application integration • External system integration 25Friday, July 15, 2011
  26. 26. Typical Application Layers 26Friday, July 15, 2011
  27. 27. Intra-Application Integration 27Friday, July 15, 2011
  28. 28. Spring Integration Config <int:gateway id="sender" service-interface="org.bsnyder.spring.integration.simple.Sender"/> <int:channel id="orderReceived"/> <int:service-activator input-channel="orderReceived" ref="receiver" method="receive" /> <bean id="receiver" class="org.bsnyder.spring.integration.simple.Receiver"/> 28Friday, July 15, 2011
  29. 29. Intra-Application Integration 29Friday, July 15, 2011
  30. 30. Spring Integration Config <int:gateway id="sender" service-interface="org.bsnyder.spring.integration.appa.Sender"/> <channel id="orderReceived" /> <amqp:outbound-channel-adapter channel="orderReceived" exchange-name="order.received.exchange" routing-key="order.received.binding" amqp-template="amqpTemplate" /> <rabbit:connection-factory id="connectionFactory" /> <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /> <rabbit:admin connection-factory="connectionFactory" /> <rabbit:queue name="order.received.queue" /> <rabbit:direct-exchange name="order.received.exchange"> <rabbit:bindings> <rabbit:binding queue="order.received.queue" key="order.received.binding" /> </rabbit:bindings> </rabbit:direct-exchange> 30Friday, July 15, 2011
  31. 31. Spring Integration Config <amqp:inbound-channel-adapter channel="orderReceived" queue-names="order.received.queue" connection-factory="connectionFactory" /> <int:service-activator input-channel="orderReceived" ref="receiver" method="receive" /> <bean id="receiver" class="org.bsnyder.spring.integration.appa.Receiver"/> <rabbit:connection-factory id="connectionFactory" /> <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /> <rabbit:admin connection-factory="connectionFactory" /> <rabbit:queue name="order.received.queue" /> <rabbit:direct-exchange name="order.received.exchange"> <rabbit:bindings> <rabbit:binding queue="order.received.queue" key="order.received.binding" /> </rabbit:bindings> </rabbit:direct-exchange> 31Friday, July 15, 2011
  32. 32. 32Friday, July 15, 2011
  33. 33. Inter-Application Integration 33Friday, July 15, 2011
  34. 34. Inter-Application Integration 34Friday, July 15, 2011
  35. 35. Spring Integration Config <int:gateway id="sender" service-interface="org.bsnyder.spring.integration.appa.Sender"/> <channel id="orderReceived" /> <amqp:outbound-channel-adapter channel="orderReceived" exchange-name="order.received.exchange" routing-key="order.received.binding" amqp-template="amqpTemplate" /> <rabbit:connection-factory id="connectionFactory" /> <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /> <rabbit:admin connection-factory="connectionFactory" /> <rabbit:queue name="order.received.queue" /> <rabbit:direct-exchange name="order.received.exchange"> <rabbit:bindings> <rabbit:binding queue="order.received.queue" key="order.received.binding" /> </rabbit:bindings> </rabbit:direct-exchange> 35Friday, July 15, 2011
  36. 36. Spring Integration Config <amqp:inbound-channel-adapter channel="orderReceived" queue-names="order.received.queue" connection-factory="connectionFactory" /> <int:service-activator input-channel="orderReceived" ref="receiver" method="receive" /> <bean id="receiver" class="org.bsnyder.spring.integration.appb.Receiver"/> <rabbit:connection-factory id="connectionFactory" /> <rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /> <rabbit:admin connection-factory="connectionFactory" /> <rabbit:queue name="order.received.queue" /> <rabbit:direct-exchange name="order.received.exchange"> <rabbit:bindings> <rabbit:binding queue="order.received.queue" key="order.received.binding" /> </rabbit:bindings> </rabbit:direct-exchange> 36Friday, July 15, 2011
  37. 37. 37Friday, July 15, 2011
  38. 38. External System Integration 38Friday, July 15, 2011
  39. 39. Spring Integration Config <int:gateway id="sender" service-interface="org.bsnyder.spring.integration.appa.Sender"/> <bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory" p:host" value="localhost" p:username" value="${user}" p:password="$ {password}"/> ! <int:channel id="ftpChannel"/> <int-ftp:outbound-channel-adapter id="ftpOutbound" channel="ftpChannel" remote-directory="/foo/bar/baz/" client-factory="ftpClientFactory"/> 39Friday, July 15, 2011
  40. 40. Spring Integration Config <int:channel id="ftpChannel"> <int:queue/> </int:channel> <bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory" p:host="localhost" p:username="${user}" p:password="${password}"/> ! <int-ftp:inbound-channel-adapter id="ftpInbound" channel="ftpChannel" session-factory="ftpClientFactory" filename-regex=".*.txt$" auto-create-local-directory="true" delete-remote-files="false" remote-directory="/foo/bar/baz/" local-directory="file:local-target-dir"> <int:poller fixed-rate="1000"/> </int-ftp:inbound-channel-adapter> <int:service-activator input-channel="ftpChannel" ref="receiver" method="receive" /> <bean id="receiver" class="org.bsnyder.spring.integration.appb.Receiver"/> 40Friday, July 15, 2011
  41. 41. 41Friday, July 15, 2011
  42. 42. Combined Integration 42Friday, July 15, 2011
  43. 43. Thank You! Q&AFriday, July 15, 2011

×