• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Syer Monitoring Integration And Batch

  • 3,873 views
Uploaded on

Deploying and Managing Spring Batch and Integration Applications (from SpringOne2GX 2010)

Deploying and Managing Spring Batch and Integration Applications (from SpringOne2GX 2010)

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,873
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
144
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Chicago, October 19 -- 22, 2010 Chicago, October 19 22, 2010 Deploying and Monitoring Spring Integration and Spring Batch Applications Dave Syer - SpringSource
  • 2. Agenda • Spring Batch and Spring Integration • Spring and JMX • Spring Integration – Metrics – Notifications and alerts – Control • Metametrics and Metaoperations: e.g. deployment and provisioning • Spring Batch – Control – Metrics – Notifications and alerts • Using SpringSource Hyperic • More Future Directions SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 3. Spring Batch Application Business logic Batch Core Quality of service, Batch Infrastructure auditability, management information, Job, Step, status Re-usable low level stuff: flat files, XML files, database keys SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 4. Job Configuration <job> <step id="load" next="analyse"/> <step id="analyse"> <next on="COMPLETED" to="summarize"/> <next on="SKIPS" to="logSkips"/> <end on="FAILED"/> </step> <step id="logSkips" next="summarize"/> <step id="summarize" /> </job> SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 5. Quality of Service • Stuff happens: – Item fails – Job fails • Failures can be – Transient – try again and see if you succeed – Skippable – ignore it and maybe come back to it later – Fatal – need manual intervention • Mark a job execution as FAILED • When it restarts, pick up where you left off • Monitor status of running and historic executions • All framework concerns: not business logic SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 6. Batch Domain Diagram JobParameters uses used to identify and manage jobs Batch Operator JobLauncher starts and stops executes JobExecution Job locates configures * executes Application StepExecution Step Developer stored in Infrastructure dependencies JobRepository SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 7. Item-Oriented Processing • Input-output can be grouped together = Item-Oriented Processing Step ItemReader ItemWriter execute() read() item repeat, retry, write(item) etc. ExitStatus SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 8. Demo SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 9. Spring Integration Application Business logic Integration Adapters Integration Core File, JMS, JDBC, JMX, TCP, etc. Enterprise Integration Patterns, message, poller, router, splitter, aggregator, etc. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 10. Message • Payload can be any object • Header values are stored in a Map Headers Payload SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 11. Message Channel • Decouples Producers from Consumers • Provides extension point for interceptors • May be Point-to-Point Producer Consumer • Or Publish/Subscribe SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 12. Low-level Components Message Channel Message Message Source Handler Endpoint • Passive • Poller • Lifecycle SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 13. The Big Picture SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 14. Demo SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 15. Spring Batch and Spring Integration • Message triggers Job • Step wraps gateway (e.g. background processing) • Remote chunking • Partitioning • Automatic retry • Flat file and XML processing • QoS: once only processing, restart • Audit: track status of execution • http://www.springsource.org/spring-batch-admin/spring- batch-integration SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 16. JMX Client Client Connector Connector MBeanServer MBean MBean MBean Application SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 17. JMX • MBeanServer provides services to MBeans and clients (through connectors) – Registration (ObjectName -> MBean) – Attributes – Operations – Notifications – Monitors (thresholds, value changes etc.) SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 18. Spring and JMX @ManagedResource @ManagedResource public class TransferServiceImpl implements TransferService { public class TransferServiceImpl implements TransferService { @ManagedOperation @ManagedOperation public void transfer(String source, String target, double amount) { public void transfer(String source, String target, double amount) { … … } } @ManagedAttribute @ManagedAttribute public double getTotalBalance() { public double getTotalBalance() { … … } } } } SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 19. Spring and JMX <context:mbean-server id="mbeanServer" /> <context:mbean-server id="mbeanServer" /> <context:mbean-export server="mbeanServer" /> <context:mbean-export server="mbeanServer" /> <bean id="transferService" class="com.foo.TransferServiceImpl"/> <bean id="transferService" class="com.foo.TransferServiceImpl"/> Automatically unregistered when MBean ApplicationContext closes ObjectName com.foo:type=TransferServiceImpl,name=transferService SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 20. Spring 3.0 and JMX: Hyperic Metrics @ManagedResource @ManagedResource public class TransferServiceImpl implements TransferService { public class TransferServiceImpl implements TransferService { … … @ManagedMetric(metricType = MetricType.GAUGE) @ManagedMetric(metricType = MetricType.GAUGE) public double getTotalBalance() { public double getTotalBalance() { … … } } } } <context:mbean-export server="mbeanServer" default- <context:mbean-export server="mbeanServer" default- domain="spring.application"/> domain="spring.application"/> SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 21. Spring Integration Metric Use Cases • How many messages have been processed? • How long did it take? • Are things getting any worse? • Were there any errors? • Can I shutdown the system now without losing any messages? SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 22. Spring Integration Metrics • MessageChannel – send count, receive count (if polling) – execution times – error rates and ratios • MessageHandler – handle count – execution times – error rates • MessageSource – message count • Global – active handler count – queued message count SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 23. MessageHandler: Naming Problems • MessageHandler is end user API (usually POJO) and location of interesting metrics • Endpoint is the thing with a name (bean id) • Many endpoints are anonymous • But channels are not widgets SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 24. Spring Integration JMX <int-jmx:mbean-export server="mbeanServer“ <int-jmx:mbean-export server="mbeanServer“ default-domain="spring.application"/> default-domain="spring.application"/> <int:channel id="widgets"/> <int:channel id="widgets"/> <int:service-activator input-channel="widgets" <int:service-activator input-channel="widgets" expression="payload.length()" /> expression="payload.length()" /> MBean MBean spring.application:type=MessageChannel,name=widgets spring.application:type=MessageHandler,name=widgets,bean=anonymous SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 25. Demo SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 26. Spring Integration Metric Types Component Metric Algorithm MessageChannel SendCount Integer MessageChannel QueueSize Integer MessageChannel SendDuration ExponentialMovingAverage MessageChannel SendErrorRate ExponentialMovingAverageRate MessageChannel ErrorRatio ExponentialMovingAverageRatio MessageHandler HandleCount Integer MessageHandler HandleDuration ExponentialMovingAverage SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 27. Spring Integration Control • Alerts on hotspots: slow handling, high error rates • Lifecycle – start, stop, running • Throttle messages on downstream error • Graceful shutdown SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 28. Demo SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 29. Metametrics and Metaoperations • Deployment and provisioning: get me one instance of this application. • What have I got deployed? • Is it working? • Scale and elastic scale: increase the number of workers. • Dynamic load: re-balance thread pools. • Highlight 4 approaches – Command line – Local service – Build and deployment tool – Private or public cloud SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 30. Command Line • Write a Java main() method • Use one off the shelf, e.g. CommandLineJobRunner • Maybe use Maven, Ant, Gradle etc. • Pros: • Lowest common denominator • High granularity: – Tweak JVM parameters (heap size etc.) – Tweak global transaction settings • Cons: • Setting up classpath and dependencies • Inventory: tracing and managing versions SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 31. Local Service: Servlet Container • Write a servlet / web service for the business features • Use one off the shelf, e.g. Spring Batch Admin • Pros: • Readily available container • Standard packaging and dependency management • Tools for monitoring and management, e.g. Hyperic • Cons: • Some overhead creating container instance • Low granularity: module boundaries have to be drawn SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 32. Remote Build and Deployment Tool • Write a remote build and deployment tool • Use one off the shelf, e.g. Capistrano, Hudson • Pros: • Granularity of command line • Can be used to manage remote server as well • Handles versioning • Cons: • New technology for some users • Still quite low level: requires script maintainence SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 33. Private or Public Cloud (PaaS) • Make deployment and provisioning a service • Pros: • Commoditisation / standardisation • Public services easily accessible • Private cloud products emerging (e.g. Napa) • Very efficient once running: “blueprint” applies to all deployments • Elastic and dynamic scale are built in features • Cons: • Extra layer in process and implementation • Some restrictions on application, especially in public clouds SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 34. Spring Batch Control • Basic use cases – Stop a job execution – Abort a job execution – Restart a job execution* – Start new or next execution* • Exposed through Spring Batch Admin and CommandLineJobRunner • SBA can be deployed as a standalone service (just needs a JobRepository) • *WithSBA only for Jobs that are configured inside SBA application SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 35. Spring Batch Metrics • Latest JobExecution status, duration • StepExecution status and history, items processed, skipped, failure analysis • Implementation: Spring Batch Admin – web application – services (REST and Java) – JMX endpoints, e.g. consume with Hyperic SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 36. Notifications and Alerts • Spring Batch SLA: step overrun – When a step execution takes too long, downstream processing can fail – Use MBean Monitor features to send notifications – JMX client can enable and consume the notifications as desired SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 37. Step Execution SLA <bean id="serviceLevel" <bean id="serviceLevel" class="org...admin.jmx.StepExecutionServiceLevelMonitor"> class="org...admin.jmx.StepExecutionServiceLevelMonitor"> <constructor-arg ref="batchMBeanExporter"/> <constructor-arg ref="batchMBeanExporter"/> <property name="timeout" value=“60000" /> <property name="timeout" value=“60000" /> <property name="jobName" value="job1" /> <property name="jobName" value="job1" /> <property name="stepName" value="j1.s1" /> <property name="stepName" value="j1.s1" /> <property name="enabled" value="true" /> <property name="enabled" value="true" /> </bean> </bean> MBean spring.application:type=StepExecutionMonitor/WARN,name=job1/j1.s1 spring.application:type=StepExecutionMonitor/ERROR,name=job1/j1.s1 SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 38. Demo SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 39. JMX Notifications and Spring Integration • Spring Integration provides adapters for JMX notifications: – inbound: notification -> Message – outbound: Message -> notification <jmx:notification-listening-channel-adapter <jmx:notification-listening-channel-adapter channel="input" channel="input" object-name="com.foo:type=TestBean,name=testBean"/> object-name="com.foo:type=TestBean,name=testBean"/> <jmx:notification-publishing-channel-adapter <jmx:notification-publishing-channel-adapter channel="input" channel="input" object-name="com.foo:type=TestBean,name=testBean“ object-name="com.foo:type=TestBean,name=testBean“ default-notification-type="com.foo.test"/> default-notification-type="com.foo.test"/> SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 40. Spring Integration ControlBus • MBean operations on Message* components triggered by Message <jmx:control-bus mbean-exporter="mbeanExporter" <jmx:control-bus mbean-exporter="mbeanExporter" channel="control"/> channel="control"/> <int-jmx:mbean-export server="mbeanServer"/> <int-jmx:mbean-export server="mbeanServer"/> control ControlBus.TARGET_BEAN_NAME=“myEndpoint" JmxHeaders.OPERATION_NAME="stop" SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 41. JMX Notifications and Hyperic • Hyperic can also consume JMX notifications – treated like log files (regex pattern on message) – generate alerts (email, SMS etc.) – trigger control actions (e.g. switch off upstream messages) • Some bugfixes not yet released support auto-detection with no XML (should be in 4.5.x) SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 42. Demo? SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 43. More Future Directions • Tracing and Business Transaction Monitoring • Replay failed transaction • Automated scheduling and restart • Performance summary, test harness SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 44. Q&A Source Code for demos: http://git.springsource.org/s2gx-2010/monitoring-spring-batch-integration SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.