spring integration done boot-ifully
DESCRIPTION
With the increase in the number of devices that emit information it has become ever more important to be able to retrieve this data and process accordingly. In response to this need, MQTT has become the defacto lightweight transport for connecting an "Internet of things". With that being said, how do your applications support for eventing, messaging, and scheduling? Utilizing Spring Boot and Spring Integration you will see how to create an application with a scheduler that will retrieve data from a web service, cleanse and emit the data via MQTT. Then show how to create an application also written using Spring Boot and Spring Integration, that will capture the MQTT events and record the results. From this discussion you can see how to use these tools and take advantage of them for your own big data projects as soon as you return to the office.TRANSCRIPT
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/
Spring Integration
Done Bootifully By Glenn Renfro
@cppwfs
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 2
Takes an opinionated view of building production-ready Spring
applications. Spring Boot favors convention over configuration and is
designed to get you up and running as quickly as possible.
Spring Boot
• Create stand-alone Spring applications
• Embed Tomcat or Jetty directly (no need to deploy WAR files)
• Opinionated 'starter' POMs
• Automatically configure Spring whenever possible
• Absolutely no code generation and no requirement for XML configuration
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 3
Spring Integration
Extends the Spring programming model to support the well-known Enterprise
Integration Patterns.
• Spring Integration enables lightweight messaging and supports integration with
external systems.
• Adapters provide a higher-level of abstraction over Spring's support for remoting,
messaging, and scheduling. • ReST/HTTP
• SFTP/FTP
• RabbitMQ
• JMS
• TCP/UDP
• Spring Integration's primary goal is to provide a simple model for building enterprise
integration solutions while maintaining the separation of concerns that is essential
for producing maintainable, testable code.
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 4
Agenda
• Create a SI application
– that gathers bid data from various bitcoin banks and markets.
– Translate data
– Send data MQTT Client
• Create MQTT Client
– Create a basic application to receive MQTT messages
– Report to console what was received
– Count total messages received.
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 5
Data Flow
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 6
The Tools • Your Favorite Editor
• Gradlew
• Git (Optional)
• RabbitMQ Need port 1883 • rabbitmq-plugins enable rabbitmq_mqtt
The Libraries • Spring Boot
• Spring Integration
• Jackson
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 7
Lets setup our integration to write to a file.
• Setup the CoinBase http outbound gateway.
• Setup our Main application
• Setup the Transform
• Setup the BitStamp http outbound gateway
• Setup the MQTT outbound-channel-adapter
4.0
4.1
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 8
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 9
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 10
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 11
• Async Sends
• HA Omit the url and use the serverURIs from
theDefaultMqttPahoClientFactory
• Supports QoS for each subscription
• Programmatically subscribe and unsubscribe from topics at
runtime.
4.1 MQTT Features
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 12
Security
• Does MQTT support security?
– MQTT supports Authentication
• Pass a user name and password with an MQTT packet as of
version 3.1
– Independently setup SSL
• But that can be heavy
– Application encrypts/decrypts the data
• Authorization?
• World Peace?
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 13
Now lets setup the MQTT Listener
• Setup build.gradle
• Setup Integation.xml
• Setup the Main
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 14
The Gradle File
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-snapshot" } mavenLocal() }
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.5.RELEASE”) }
}
…
apply plugin: 'spring-boot'
…
dependencies {
compile("org.springframework.boot:spring-boot-starter-integration")
compile("com.fasterxml.jackson.core:jackson-databind")
compile "org.springframework.integration:spring-integration-mqtt:4.0.3.RELEASE"
testCompile("junit:junit")
}
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 15
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 16
Just a little bit more
• Profiles
• Actuator
• JMX
Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial l icense: http://creativecommons.org/licenses/by-nc/3.0/ 17
Learn More. Stay Connected
[email protected] [email protected]:cppwfs/webcastbitcoin.git
[email protected]:cppwfs/webcastmqtt.git
@springcentral | spring.io/video