SlideShare a Scribd company logo
How to use Batch component
28-05-2015
Abstract
• The main motto of this PPT is How to use
Batch component in our applications.
Introduction
• Mule possesses the ability to process messages
in batches. Within an application, you can initiate
a batch job which is a block of code that splits
messages into individual records, performs
actions upon each record, then reports on the
results and potentially pushes the processed
output to other systems or queues. This
functionality is particularly useful when working
with streaming input or when engineering "near
real-time" data integration between SaaS
applications.
Example
.mflow
• <?xml version="1.0" encoding="UTF-8"?>
• <mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
• xmlns:spring="http://www.springframework.org/schema/beans"
• xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
• xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
• http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
• http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
• http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
• http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
• http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
• <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8089" doc:name="HTTP Listener Configuration"/>
• <db:generic-config name="Generic_Database_Configuration" url="jdbc:sqlserver://localhost:1433;databaseName=SOA_VMES_DB;user=****;password=****;"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" doc:name="Generic Database Configuration"/>
• <batch:job name="SampleBatch" max-failed-records="-1">
• <batch:process-records>
• <batch:step name="Batch_Step">
• <logger message="--Batch step--#[payload]--" level="INFO" doc:name="Logger"/>
• <foreach doc:name="For Each">
• <logger message="--for each--batch step--#[payload]" level="INFO" doc:name="Logger"/>
• <choice doc:name="Choice">
• <when expression="#[payload==5]">
• <db:update config-ref="Generic_Database_Configuration" doc:name="Database">
• <db:parameterized-query><![CDATA[update mytable22 set status='successsuccesssuccesssuccesssuccesssuccess' where num=#[payload]]]></db:parameterized-query>
• </db:update>
• </when>
• <otherwise>
• <db:update config-ref="Generic_Database_Configuration" doc:name="Database">
• <db:parameterized-query><![CDATA[update mytable22 set status='Success' where num=#[payload]]]></db:parameterized-query>
• </db:update>
• </otherwise>
• </choice>
• </foreach>
• </batch:step>
• <batch:step name="Batch_Step1" accept-policy="ONLY_FAILURES">
• <logger message="--step1--#[payload]" level="INFO" doc:name="Logger"/>
• <foreach doc:name="For Each">
• <logger message="--for each--batch step1--#[payload]--" level="INFO" doc:name="Logger"/>
• <db:update config-ref="Generic_Database_Configuration" doc:name="Database">
• <db:parameterized-query><![CDATA[update mytable22 set status='batch fail' where num=#[payload]]]></db:parameterized-query>
• </db:update>
• </foreach>
• </batch:step>
• </batch:process-records>
• <batch:on-complete>
• <logger message="--complete--#[message.payload]" level="INFO" doc:name="Logger"/>
• </batch:on-complete>
• </batch:job>
• <flow name="SampleFlow">
• <http:listener config-ref="HTTP_Listener_Configuration" path="/*" doc:name="HTTP"/>
• <logger level="INFO" doc:name="Logger" message="--Hai"/>
• <expression-component doc:name="Expression"><![CDATA[import java.util.List;
• import java.util.Map;
• import java.util.ArrayList;
• import java.util.HashMap;
• List l1 = new ArrayList();
• Map m2 = new HashMap();
• m2.put("b","2");
• m2.put("c","3");
• l1.add(m2);
• Map m1 = new HashMap();
• m1.put("a","1");
• l1.add(m1);
• Map m4 = new HashMap();
• m4.put("e","5");
• l1.add(m4);
• Map m3 = new HashMap();
• m3.put("d","4");
• l1.add(m3);
• payload = l1;
• return payload;]]></expression-component>
• <logger message="--main flow--#[payload]" level="INFO" doc:name="Logger"/>
• <batch:execute name="SampleBatch" doc:name="SampleBatch"/>
• </flow>
• </mule>
• Output:
• Data in DB:
• Before execute:
After execute:
• INFO 2016-05-28 18:51:48,882 [main] org.mule.module.launcher.MuleDeploymentService:
• ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
• + Started app 'Sample' +
• ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
• INFO 2016-05-28 18:51:48,886 [main] org.mule.module.launcher.DeploymentDirectoryWatcher:
• ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
• + Mule is up and kicking (every 5000ms) +
• ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
• INFO 2016-05-28 18:51:49,040 [main] org.mule.module.launcher.StartupSummaryDeploymentListener:
• **********************************************************************
• * - - + DOMAIN + - - * - - + STATUS + - - *
• **********************************************************************
• * default * DEPLOYED *
• **********************************************************************
• *******************************************************************************************************
• * - - + APPLICATION + - - * - - + DOMAIN + - - * - - + STATUS + - - *
• *******************************************************************************************************
• * Sample * default * DEPLOYED *
• *******************************************************************************************************
• INFO 2016-05-28 18:51:53,201 [[Sample].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: --Hai
• INFO 2016-05-28 18:51:53,253 [[Sample].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: --main flow--[{b=2, c=3}, {a=1}, {e=5}, {d=4}]
• INFO 2016-05-28 18:51:53,354 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Created instance dc959d50-24fc-11e6-b3de-
30d420524153 for batch job SampleBatch
• INFO 2016-05-28 18:51:53,359 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Batch job SampleBatch has no input phase.
Creating job instance
• INFO 2016-05-28 18:51:53,383 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.queue.BatchQueueLoader: Starting loading phase for instance
'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch'
• INFO 2016-05-28 18:51:53,548 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.queue.BatchQueueLoader: Finished loading phase for instance
dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch. 4 records were loaded
• INFO 2016-05-28 18:51:53,562 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Started execution of instance 'dc959d50-
24fc-11e6-b3de-30d420524153' of job 'SampleBatch'
• INFO 2016-05-28 18:51:53,711 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{b=2, c=3}--
• INFO 2016-05-28 18:51:53,713 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--2
• INFO 2016-05-28 18:52:00,519 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--3
• INFO 2016-05-28 18:52:00,605 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{a=1}--
• INFO 2016-05-28 18:52:00,605 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--1
• INFO 2016-05-28 18:52:00,617 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{e=5}--
• INFO 2016-05-28 18:52:00,617 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--5
• INFO 2016-05-28 18:52:02,765 [batch-job-SampleBatch-work-manager.01] com.mulesoft.module.batch.DefaultBatchStep: Found exception processing record on step 'Batch_Step' for job
instance 'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch'.
• This is the first record to show this exception on this step for this job instance. Subsequent records with the same failureswill not be logged for performance and log readability reasons:
• ********************************************************************************
• Message : String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String
• Type : org.mule.api.MessagingException
• Code : MULE_ERROR--2
• Payload : 5
• JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
• ********************************************************************************
• Exception stack is:
• 1. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException)
• com.microsoft.sqlserver.jdbc.SQLServerException:216 (null)
• 2. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String (org.mule.api.MessagingException)
• org.mule.module.db.internal.processor.AbstractDbMessageProcessor:93 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
• ********************************************************************************
• Root Exception stack trace:
• com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
• at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
• at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
• at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
• at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
• at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
• at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
• at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
• at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
• at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314)
• at org.mule.module.db.internal.domain.autogeneratedkey.NoAutoGeneratedKeyStrategy.executeUpdate(NoAutoGeneratedKeyStrategy.java:55)
• at org.mule.module.db.internal.domain.executor.UpdateExecutor.doExecuteQuery(UpdateExecutor.java:43)
• at org.mule.module.db.internal.domain.executor.AbstractSingleQueryExecutor.execute(AbstractSingleQueryExecutor.java:48)
• at org.mule.module.db.internal.processor.UpdateMessageProcessor.doExecuteQuery(UpdateMessageProcessor.java:59)
• at org.mule.module.db.internal.processor.AbstractSingleQueryDbMessageProcessor.executeQuery(AbstractSingleQueryDbMessageProcessor.java:42)
• at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:66)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.routing.AbstractSelectiveRouter.processEventWithProcessor(AbstractSelectiveRouter.java:303)
• at org.mule.routing.AbstractSelectiveRouter.routeWithProcessors(AbstractSelectiveRouter.java:293)
• at org.mule.routing.AbstractSelectiveRouter.process(AbstractSelectiveRouter.java:193)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.routing.outbound.AbstractMessageSequenceSplitter.processParts(AbstractMessageSequenceSplitter.java:129)
• at org.mule.routing.outbound.AbstractMessageSequenceSplitter.process(AbstractMessageSequenceSplitter.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule...
• ********************************************************************************
• INFO 2016-05-28 18:52:02,768 [batch-job-SampleBatch-work-manager.01] com.mulesoft.module.batch.DefaultBatchStep: Found exception processing record on step 'Batch_Step' for job
instance 'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch'.
• This is the first record to show this exception on this step for this job instance. Subsequent records with the same failureswill not be logged for performance and log readability reasons:
• ********************************************************************************
• Message : String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String
• Type : org.mule.api.MessagingException
• Code : MULE_ERROR--2
• Payload : 5
• JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
• ********************************************************************************
• Exception stack is:
• 1. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException)
• com.microsoft.sqlserver.jdbc.SQLServerException:216 (null)
• 2. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String (org.mule.api.MessagingException)
• org.mule.module.db.internal.processor.AbstractDbMessageProcessor:93 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
• ********************************************************************************
• Root Exc
• com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.
• at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
• at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
• at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
• at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
• at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) eption stack trace:
• at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
• at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
• at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
• at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314)
• at org.mule.module.db.internal.domain.autogeneratedkey.NoAutoGeneratedKeyStrategy.executeUpdate(NoAutoGeneratedKeyStrategy.java:55)
• at org.mule.module.db.internal.domain.executor.UpdateExecutor.doExecuteQuery(UpdateExecutor.java:43)
• at org.mule.module.db.internal.domain.executor.AbstractSingleQueryExecutor.execute(AbstractSingleQueryExecutor.java:48)
• at org.mule.module.db.internal.processor.UpdateMessageProcessor.doExecuteQuery(UpdateMessageProcessor.java:59)
• at org.mule.module.db.internal.processor.AbstractSingleQueryDbMessageProcessor.executeQuery(AbstractSingleQueryDbMessageProcessor.java:42)
• at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:66)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.routing.AbstractSelectiveRouter.processEventWithProcessor(AbstractSelectiveRouter.java:303)
• at org.mule.routing.AbstractSelectiveRouter.routeWithProcessors(AbstractSelectiveRouter.java:293)
• at org.mule.routing.AbstractSelectiveRouter.process(AbstractSelectiveRouter.java:193)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.routing.outbound.AbstractMessageSequenceSplitter.processParts(AbstractMessageSequenceSplitter.java:129)
• at org.mule.routing.outbound.AbstractMessageSequenceSplitter.process(AbstractMessageSequenceSplitter.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
• at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
• at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
• at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
• at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
• at org.mule...
• ********************************************************************************
• INFO 2016-05-28 18:52:02,769 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{d=4}--
• INFO 2016-05-28 18:52:02,769 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--
4
• INFO 2016-05-28 18:52:03,049 [batch-job-SampleBatch-work-manager.01] com.mulesoft.module.batch.DefaultBatchStep: Step Batch_Step finished
processing all records for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch
• INFO 2016-05-28 18:52:03,095 [batch-job-SampleBatch-work-manager.02] org.mule.api.processor.LoggerMessageProcessor: --step1--{e=5}
• INFO 2016-05-28 18:52:03,096 [batch-job-SampleBatch-work-manager.02] org.mule.api.processor.LoggerMessageProcessor: --for each--batch
step1--5--
• INFO 2016-05-28 18:52:03,488 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine: Starting
execution of onComplete phase for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch
• INFO 2016-05-28 18:52:03,508 [batch-job-SampleBatch-work-manager.02] org.mule.api.processor.LoggerMessageProcessor: --complete--
com.mulesoft.module.batch.ImmutableBatchJobResult@1fa547d1
• INFO 2016-05-28 18:52:03,509 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine: Finished
execution of onComplete phase for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch
• INFO 2016-05-28 18:52:03,509 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine: Finished
execution for instance 'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch'. Total Records processed: 4. Successful records: 3. Failed
Records: 1
• INFO 2016-05-28 18:52:03,511 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine:
• *************************************************************************************************************************
***************************************
• * - - + Exception Type + - - * - - + Step + - - * - - + Count + - - *
• *************************************************************************************************************************
***************************************
• * com.mulesoft.module.batch.exception.BatchException * Batch_Step * 1 *
• *************************************************************************************************************************
***************************************
• INFO 2016-05-28 18:52:03,524 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.DefaultBatchStep: Step Batch_Step1
finished processing all records for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch
• Flow of execution:
1. URL to trigger the service from browser
http://localhost:8089
2. a. Service will update the status to ‘Success’ for
the records whose num is other than 5
b. It will fail while trying to update the status as
‘successsuccesssuccesssuccesssuccesssuccess’ for
the num 5 because the length of the status excides
the size of the column. Hence, the failed map will
process in Batch_Step1 and will update the status
as ‘batch fail’ for the record whose num is 5
References
• https://docs.mulesoft.com/mule-user-
guide/v/3.6/batch-processing

More Related Content

PPTX
Apache Flink Training: DataSet API Basics
PPTX
Flink Batch Processing and Iterations
PPTX
Apache Flink Training: DataStream API Part 2 Advanced
PPTX
Michael Häusler – Everyday flink
PDF
Real time and reliable processing with Apache Storm
PDF
Integrate Solr with real-time stream processing applications
PDF
Building Distributed System with Celery on Docker Swarm
PPTX
Flink 0.10 @ Bay Area Meetup (October 2015)
Apache Flink Training: DataSet API Basics
Flink Batch Processing and Iterations
Apache Flink Training: DataStream API Part 2 Advanced
Michael Häusler – Everyday flink
Real time and reliable processing with Apache Storm
Integrate Solr with real-time stream processing applications
Building Distributed System with Celery on Docker Swarm
Flink 0.10 @ Bay Area Meetup (October 2015)

What's hot (20)

PPTX
Create & Execute First Hadoop MapReduce Project in.pptx
PDF
PythonBrasil[8] - CPython for dummies
PDF
Real-time Stream Processing with Apache Flink @ Hadoop Summit
PDF
Introduction to Twitter Storm
PDF
Distributed real time stream processing- why and how
PPT
Anatomy of classic map reduce in hadoop
PPTX
Rally - Benchmarking_as_a_service - Openstack meetup
PDF
Hadoop Summit Europe 2014: Apache Storm Architecture
PDF
Postgres Vienna DB Meetup 2014
PPTX
BD-zero lecture.pptx
PPTX
EX-6-Implement Matrix Multiplication with Hadoop Map Reduce.pptx
PPTX
Hadoop MapReduce Introduction and Deep Insight
KEY
Testing Hadoop jobs with MRUnit
PDF
An Introduction To PostgreSQL Triggers
PDF
Monitoring InfluxEnterprise
PDF
Moving In: how to port your content from * to Drupal
PPTX
An introduction to Test Driven Development on MapReduce
PDF
MAVRL Workshop 2014 - pymatgen-db & custodian
DOCX
Big data unit iv and v lecture notes qb model exam
PPT
Hive User Meeting August 2009 Facebook
Create & Execute First Hadoop MapReduce Project in.pptx
PythonBrasil[8] - CPython for dummies
Real-time Stream Processing with Apache Flink @ Hadoop Summit
Introduction to Twitter Storm
Distributed real time stream processing- why and how
Anatomy of classic map reduce in hadoop
Rally - Benchmarking_as_a_service - Openstack meetup
Hadoop Summit Europe 2014: Apache Storm Architecture
Postgres Vienna DB Meetup 2014
BD-zero lecture.pptx
EX-6-Implement Matrix Multiplication with Hadoop Map Reduce.pptx
Hadoop MapReduce Introduction and Deep Insight
Testing Hadoop jobs with MRUnit
An Introduction To PostgreSQL Triggers
Monitoring InfluxEnterprise
Moving In: how to port your content from * to Drupal
An introduction to Test Driven Development on MapReduce
MAVRL Workshop 2014 - pymatgen-db & custodian
Big data unit iv and v lecture notes qb model exam
Hive User Meeting August 2009 Facebook
Ad

Viewers also liked (15)

PDF
Душевые кабины Friges – Приложение 5 от Stockist Italy
PPTX
Daniela vrnoga
PDF
Reference Enquiry Form Kim 210568
PDF
Eng Council CEng
PPTX
Mule esb with amazon s3 Integration
PPTX
Integration with dropbox using mule esb
PPTX
Overview of GST
PDF
Laudo de tcnicod e vistoria predial
PPTX
Children’s book
PDF
Apostila engenharia civil concreto armado recomendacoes
PDF
EENA 2016 - Customer service in a PSAP (2/3)
PPTX
Cadbury marketing stratergy
PPTX
7aloulaaaaaaaa projet final
PPTX
Les instruments musicales
Душевые кабины Friges – Приложение 5 от Stockist Italy
Daniela vrnoga
Reference Enquiry Form Kim 210568
Eng Council CEng
Mule esb with amazon s3 Integration
Integration with dropbox using mule esb
Overview of GST
Laudo de tcnicod e vistoria predial
Children’s book
Apostila engenharia civil concreto armado recomendacoes
EENA 2016 - Customer service in a PSAP (2/3)
Cadbury marketing stratergy
7aloulaaaaaaaa projet final
Les instruments musicales
Ad

Similar to How to use batch component (20)

PPTX
How to use database component using stored procedure call
PPTX
Junit in mule
PPTX
Junit in mule
 
PPTX
Junit in mule
PPTX
Junit in mule demo
PDF
Data herding
PDF
Data herding
PPTX
For each component
 
PPTX
For each component
PPTX
For each component in mule
PPTX
For each component
PPTX
For each component in mule
PPTX
Hadoop cluster performance profiler
PPTX
For Each Component
PDF
PaaSTA: Autoscaling at Yelp
PPTX
How to use for each component
PPTX
Reference exception strategy
PDF
TYPO3 Scheduler
PPTX
Enjoy Munit with Mule
How to use database component using stored procedure call
Junit in mule
Junit in mule
 
Junit in mule
Junit in mule demo
Data herding
Data herding
For each component
 
For each component
For each component in mule
For each component
For each component in mule
Hadoop cluster performance profiler
For Each Component
PaaSTA: Autoscaling at Yelp
How to use for each component
Reference exception strategy
TYPO3 Scheduler
Enjoy Munit with Mule

More from sivachandra mandalapu (20)

PPTX
Mock component in munit
PPTX
Jms selector
PPTX
PPTX
Object store
PPTX
How to use SFTP
PPTX
How to use secure property placeholder
PPTX
Specifying a default exception strategy
PPTX
Defining global exception strategies
PPTX
Validate json schema
PPTX
PPTX
Property place holder
PPTX
Collection aggregator
PPTX
Cloud hub deployment
PPTX
Securing api with_o_auth2
PPTX
Deployment options for mule applications
PPTX
Setting up organization with api access
PPTX
API gateway setup
PPTX
PPTX
PPTX
Bean as Datasource
Mock component in munit
Jms selector
Object store
How to use SFTP
How to use secure property placeholder
Specifying a default exception strategy
Defining global exception strategies
Validate json schema
Property place holder
Collection aggregator
Cloud hub deployment
Securing api with_o_auth2
Deployment options for mule applications
Setting up organization with api access
API gateway setup
Bean as Datasource

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Classroom Observation Tools for Teachers
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
advance database management system book.pdf
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Lesson notes of climatology university.
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
1_English_Language_Set_2.pdf probationary
PDF
Empowerment Technology for Senior High School Guide
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Final Presentation General Medicine 03-08-2024.pptx
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Classroom Observation Tools for Teachers
Chinmaya Tiranga quiz Grand Finale.pdf
History, Philosophy and sociology of education (1).pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
advance database management system book.pdf
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Lesson notes of climatology university.
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
1_English_Language_Set_2.pdf probationary
Empowerment Technology for Senior High School Guide
Weekly quiz Compilation Jan -July 25.pdf
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Indian roads congress 037 - 2012 Flexible pavement
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS

How to use batch component

  • 1. How to use Batch component 28-05-2015
  • 2. Abstract • The main motto of this PPT is How to use Batch component in our applications.
  • 3. Introduction • Mule possesses the ability to process messages in batches. Within an application, you can initiate a batch job which is a block of code that splits messages into individual records, performs actions upon each record, then reports on the results and potentially pushes the processed output to other systems or queues. This functionality is particularly useful when working with streaming input or when engineering "near real-time" data integration between SaaS applications.
  • 5. .mflow • <?xml version="1.0" encoding="UTF-8"?> • <mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" • xmlns:spring="http://www.springframework.org/schema/beans" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" • xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd • http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd • http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd • http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd • http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd • http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd"> • <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8089" doc:name="HTTP Listener Configuration"/> • <db:generic-config name="Generic_Database_Configuration" url="jdbc:sqlserver://localhost:1433;databaseName=SOA_VMES_DB;user=****;password=****;" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" doc:name="Generic Database Configuration"/> • <batch:job name="SampleBatch" max-failed-records="-1"> • <batch:process-records> • <batch:step name="Batch_Step"> • <logger message="--Batch step--#[payload]--" level="INFO" doc:name="Logger"/> • <foreach doc:name="For Each"> • <logger message="--for each--batch step--#[payload]" level="INFO" doc:name="Logger"/> • <choice doc:name="Choice"> • <when expression="#[payload==5]"> • <db:update config-ref="Generic_Database_Configuration" doc:name="Database"> • <db:parameterized-query><![CDATA[update mytable22 set status='successsuccesssuccesssuccesssuccesssuccess' where num=#[payload]]]></db:parameterized-query> • </db:update> • </when> • <otherwise> • <db:update config-ref="Generic_Database_Configuration" doc:name="Database"> • <db:parameterized-query><![CDATA[update mytable22 set status='Success' where num=#[payload]]]></db:parameterized-query> • </db:update> • </otherwise> • </choice> • </foreach> • </batch:step>
  • 6. • <batch:step name="Batch_Step1" accept-policy="ONLY_FAILURES"> • <logger message="--step1--#[payload]" level="INFO" doc:name="Logger"/> • <foreach doc:name="For Each"> • <logger message="--for each--batch step1--#[payload]--" level="INFO" doc:name="Logger"/> • <db:update config-ref="Generic_Database_Configuration" doc:name="Database"> • <db:parameterized-query><![CDATA[update mytable22 set status='batch fail' where num=#[payload]]]></db:parameterized-query> • </db:update> • </foreach> • </batch:step> • </batch:process-records> • <batch:on-complete> • <logger message="--complete--#[message.payload]" level="INFO" doc:name="Logger"/> • </batch:on-complete> • </batch:job> • <flow name="SampleFlow"> • <http:listener config-ref="HTTP_Listener_Configuration" path="/*" doc:name="HTTP"/> • <logger level="INFO" doc:name="Logger" message="--Hai"/> • <expression-component doc:name="Expression"><![CDATA[import java.util.List; • import java.util.Map; • import java.util.ArrayList; • import java.util.HashMap; • List l1 = new ArrayList(); • Map m2 = new HashMap(); • m2.put("b","2"); • m2.put("c","3"); • l1.add(m2); • Map m1 = new HashMap(); • m1.put("a","1"); • l1.add(m1); • Map m4 = new HashMap(); • m4.put("e","5"); • l1.add(m4); • Map m3 = new HashMap(); • m3.put("d","4"); • l1.add(m3); • payload = l1; • return payload;]]></expression-component> • <logger message="--main flow--#[payload]" level="INFO" doc:name="Logger"/> • <batch:execute name="SampleBatch" doc:name="SampleBatch"/> • </flow> • </mule>
  • 7. • Output: • Data in DB: • Before execute: After execute:
  • 8. • INFO 2016-05-28 18:51:48,882 [main] org.mule.module.launcher.MuleDeploymentService: • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ • + Started app 'Sample' + • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ • INFO 2016-05-28 18:51:48,886 [main] org.mule.module.launcher.DeploymentDirectoryWatcher: • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ • + Mule is up and kicking (every 5000ms) + • ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ • INFO 2016-05-28 18:51:49,040 [main] org.mule.module.launcher.StartupSummaryDeploymentListener: • ********************************************************************** • * - - + DOMAIN + - - * - - + STATUS + - - * • ********************************************************************** • * default * DEPLOYED * • ********************************************************************** • ******************************************************************************************************* • * - - + APPLICATION + - - * - - + DOMAIN + - - * - - + STATUS + - - * • ******************************************************************************************************* • * Sample * default * DEPLOYED * • ******************************************************************************************************* • INFO 2016-05-28 18:51:53,201 [[Sample].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: --Hai • INFO 2016-05-28 18:51:53,253 [[Sample].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: --main flow--[{b=2, c=3}, {a=1}, {e=5}, {d=4}] • INFO 2016-05-28 18:51:53,354 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Created instance dc959d50-24fc-11e6-b3de- 30d420524153 for batch job SampleBatch • INFO 2016-05-28 18:51:53,359 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Batch job SampleBatch has no input phase. Creating job instance • INFO 2016-05-28 18:51:53,383 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.queue.BatchQueueLoader: Starting loading phase for instance 'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch' • INFO 2016-05-28 18:51:53,548 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.queue.BatchQueueLoader: Finished loading phase for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch. 4 records were loaded • INFO 2016-05-28 18:51:53,562 [[Sample].HTTP_Listener_Configuration.worker.01] com.mulesoft.module.batch.engine.DefaultBatchEngine: Started execution of instance 'dc959d50- 24fc-11e6-b3de-30d420524153' of job 'SampleBatch' • INFO 2016-05-28 18:51:53,711 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{b=2, c=3}-- • INFO 2016-05-28 18:51:53,713 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--2 • INFO 2016-05-28 18:52:00,519 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--3 • INFO 2016-05-28 18:52:00,605 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{a=1}-- • INFO 2016-05-28 18:52:00,605 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--1 • INFO 2016-05-28 18:52:00,617 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{e=5}-- • INFO 2016-05-28 18:52:00,617 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step--5 • INFO 2016-05-28 18:52:02,765 [batch-job-SampleBatch-work-manager.01] com.mulesoft.module.batch.DefaultBatchStep: Found exception processing record on step 'Batch_Step' for job instance 'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch'. • This is the first record to show this exception on this step for this job instance. Subsequent records with the same failureswill not be logged for performance and log readability reasons:
  • 9. • ******************************************************************************** • Message : String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String • Type : org.mule.api.MessagingException • Code : MULE_ERROR--2 • Payload : 5 • JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html • ******************************************************************************** • Exception stack is: • 1. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException) • com.microsoft.sqlserver.jdbc.SQLServerException:216 (null) • 2. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String (org.mule.api.MessagingException) • org.mule.module.db.internal.processor.AbstractDbMessageProcessor:93 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html) • ******************************************************************************** • Root Exception stack trace: • com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated. • at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) • at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) • at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404) • at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350) • at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) • at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) • at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180) • at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155) • at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314) • at org.mule.module.db.internal.domain.autogeneratedkey.NoAutoGeneratedKeyStrategy.executeUpdate(NoAutoGeneratedKeyStrategy.java:55) • at org.mule.module.db.internal.domain.executor.UpdateExecutor.doExecuteQuery(UpdateExecutor.java:43) • at org.mule.module.db.internal.domain.executor.AbstractSingleQueryExecutor.execute(AbstractSingleQueryExecutor.java:48) • at org.mule.module.db.internal.processor.UpdateMessageProcessor.doExecuteQuery(UpdateMessageProcessor.java:59) • at org.mule.module.db.internal.processor.AbstractSingleQueryDbMessageProcessor.executeQuery(AbstractSingleQueryDbMessageProcessor.java:42) • at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:66) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.routing.AbstractSelectiveRouter.processEventWithProcessor(AbstractSelectiveRouter.java:303) • at org.mule.routing.AbstractSelectiveRouter.routeWithProcessors(AbstractSelectiveRouter.java:293)
  • 10. • at org.mule.routing.AbstractSelectiveRouter.process(AbstractSelectiveRouter.java:193) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.routing.outbound.AbstractMessageSequenceSplitter.processParts(AbstractMessageSequenceSplitter.java:129) • at org.mule.routing.outbound.AbstractMessageSequenceSplitter.process(AbstractMessageSequenceSplitter.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule... • ******************************************************************************** • INFO 2016-05-28 18:52:02,768 [batch-job-SampleBatch-work-manager.01] com.mulesoft.module.batch.DefaultBatchStep: Found exception processing record on step 'Batch_Step' for job instance 'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch'. • This is the first record to show this exception on this step for this job instance. Subsequent records with the same failureswill not be logged for performance and log readability reasons: • ******************************************************************************** • Message : String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String • Type : org.mule.api.MessagingException • Code : MULE_ERROR--2 • Payload : 5 • JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html • ******************************************************************************** • Exception stack is: • 1. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException) • com.microsoft.sqlserver.jdbc.SQLServerException:216 (null) • 2. String or binary data would be truncated. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String (org.mule.api.MessagingException) • org.mule.module.db.internal.processor.AbstractDbMessageProcessor:93 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html) • ******************************************************************************** • Root Exc • com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated. • at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) • at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) • at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404) • at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350) • at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) eption stack trace:
  • 11. • at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) • at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180) • at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155) • at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314) • at org.mule.module.db.internal.domain.autogeneratedkey.NoAutoGeneratedKeyStrategy.executeUpdate(NoAutoGeneratedKeyStrategy.java:55) • at org.mule.module.db.internal.domain.executor.UpdateExecutor.doExecuteQuery(UpdateExecutor.java:43) • at org.mule.module.db.internal.domain.executor.AbstractSingleQueryExecutor.execute(AbstractSingleQueryExecutor.java:48) • at org.mule.module.db.internal.processor.UpdateMessageProcessor.doExecuteQuery(UpdateMessageProcessor.java:59) • at org.mule.module.db.internal.processor.AbstractSingleQueryDbMessageProcessor.executeQuery(AbstractSingleQueryDbMessageProcessor.java:42) • at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:66) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.routing.AbstractSelectiveRouter.processEventWithProcessor(AbstractSelectiveRouter.java:303) • at org.mule.routing.AbstractSelectiveRouter.routeWithProcessors(AbstractSelectiveRouter.java:293) • at org.mule.routing.AbstractSelectiveRouter.process(AbstractSelectiveRouter.java:193) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.routing.outbound.AbstractMessageSequenceSplitter.processParts(AbstractMessageSequenceSplitter.java:129) • at org.mule.routing.outbound.AbstractMessageSequenceSplitter.process(AbstractMessageSequenceSplitter.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107) • at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44) • at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88) • at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59) • at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24) • at org.mule... • ********************************************************************************
  • 12. • INFO 2016-05-28 18:52:02,769 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --Batch step--{d=4}-- • INFO 2016-05-28 18:52:02,769 [batch-job-SampleBatch-work-manager.01] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step-- 4 • INFO 2016-05-28 18:52:03,049 [batch-job-SampleBatch-work-manager.01] com.mulesoft.module.batch.DefaultBatchStep: Step Batch_Step finished processing all records for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch • INFO 2016-05-28 18:52:03,095 [batch-job-SampleBatch-work-manager.02] org.mule.api.processor.LoggerMessageProcessor: --step1--{e=5} • INFO 2016-05-28 18:52:03,096 [batch-job-SampleBatch-work-manager.02] org.mule.api.processor.LoggerMessageProcessor: --for each--batch step1--5-- • INFO 2016-05-28 18:52:03,488 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine: Starting execution of onComplete phase for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch • INFO 2016-05-28 18:52:03,508 [batch-job-SampleBatch-work-manager.02] org.mule.api.processor.LoggerMessageProcessor: --complete-- com.mulesoft.module.batch.ImmutableBatchJobResult@1fa547d1 • INFO 2016-05-28 18:52:03,509 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine: Finished execution of onComplete phase for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch • INFO 2016-05-28 18:52:03,509 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine: Finished execution for instance 'dc959d50-24fc-11e6-b3de-30d420524153' of job 'SampleBatch'. Total Records processed: 4. Successful records: 3. Failed Records: 1 • INFO 2016-05-28 18:52:03,511 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.engine.DefaultBatchEngine: • ************************************************************************************************************************* *************************************** • * - - + Exception Type + - - * - - + Step + - - * - - + Count + - - * • ************************************************************************************************************************* *************************************** • * com.mulesoft.module.batch.exception.BatchException * Batch_Step * 1 * • ************************************************************************************************************************* *************************************** • INFO 2016-05-28 18:52:03,524 [batch-job-SampleBatch-work-manager.02] com.mulesoft.module.batch.DefaultBatchStep: Step Batch_Step1 finished processing all records for instance dc959d50-24fc-11e6-b3de-30d420524153 of job SampleBatch
  • 13. • Flow of execution: 1. URL to trigger the service from browser http://localhost:8089 2. a. Service will update the status to ‘Success’ for the records whose num is other than 5 b. It will fail while trying to update the status as ‘successsuccesssuccesssuccesssuccesssuccess’ for the num 5 because the length of the status excides the size of the column. Hence, the failed map will process in Batch_Step1 and will update the status as ‘batch fail’ for the record whose num is 5