Friday, October 26, 2012

Cracking OCMJEA !!!


"Congratulations! You have passed the Oracle Certified Master, Java EE 5 Enterprise Architect certification. You are among the elite 1% of certified Java professionals who have gone on to achieve the Java Enterprise Architect certification. "

I am very excited to read the above mail from Oracle last week, as this certification is very special to me and involves tackling part1 to part-3. Part-2 assignment (Gusher Oil) is quite interesting doing the design , creating UML diagrams, documenting our decision criteria's ++.

This blog aims at providing tips to ocmjea aspirants focusing more on Step2 Assignment. hope it will help ocmjea aspirant's. This blog is not much specific to assignment or its solution due to oracle’s exam policy. 


0. Introduction


OCMJEA (Oracle Certified Master Java Enterprise Architect) formerly known as SCEA (Sun Certified Enterprise architect) is the highest level of certification in Java Stack. This certification is for enterprise architects responsible for architecting and designing Java EE compliant applications. It provides developers with knowledge needed to develop robust architectures for enterprise applications using Java Platform.

This certification involves tackling part1 to part-3 including the part-2 assignment.

Java Enterprise Edition 5 Enterprise Architect Certified Master Exam (Step 1 of 3)
Java Enterprise Edition 5 Enterprise Architect Certified Master Assignment (Step 2 of 3)
Java Enterprise Edition 5 Enterprise Architect Certified Master Essay Exam (Step 3 of 3)

To succeed, OCMJEA candidates must demonstrate a deep understanding of UML’s, Design principles & pattern’s plus current Java EE technologies.

Note : Oracle recently introduced a mandatory training course as part of ocmjea certification.

1. Exam -Part1 (Step 1 of 3)

Part1 involves 120 minutes Objective exam and passing score is 57%. 

For syllabus refer Oracle Certification site, 

http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=41&p_exam_id=1Z0_864

Lots of books are available in the market. Couple of them are mentioned below:

SCEA Certification Guide from Dream-tech Publisher’s.
SCEA for Java EE5 - Mark Cade

Taking mock exam before the actual exam is highly recommended as the objective of the exam is to test how well we can apply the theories to business scenarios. 

Dream-tech provides with mock exam kit which is very helpful to evaluate ourselves. 

Below is another blog with sample exam questions.

http://reddymails.blogspot.com/2011/07/scea-part1-questions.html

2. Exam -Part2 (Step 2 of 3)


Part2 assignment is quite interesting doing the design, creating UML diagrams, documenting our decision criteria's ++.  But most of the time, ocmjea aspirants are confused in terms of where to start and what all we need to do for the assignment

Once the step-1 is passed we can download the assignment via Pearson vue site. Both assignment and essay (step-3) need to be submitted within 6 months of assignment purchase. 

We need to score 72% to pass the step 2 and step3 examinations, evaluated together. Assignment will be provided with system requirements, business domain Model and use cases and we need to come up with the design addressing the functional and non-functional requirements. 

Deliverables includes UML’s diagram’s (Class diagram, Component diagram, Deployment Diagram, Sequence Diagram for each use case)  , design documentation including technical risks involved. 


2.1 Design Tips:

Ø The assignment is slightly vague and one need to make a lot of assumptions and that might affect your design decisions. You might observe a lot of conflicting views about the solution for the same problem.
It’s expected.

Ø Refresh your UML & Design pattern's knowledge.

Ø Finalise on the architecture first before going with the uml’s. This saves lots of re-work on your uml diagrams. Analyse different design options for each layer’s client Tier, Business Tier and Data Tier. 

Ø Creating wire-frame’s (UI) of the system also help in terms of top-down design as one can visualize the views and how the user interaction will be taken care in the architecture.

Ø Document your assumption’s in the design document. Ensure the assumption is logical and makes sense in context to the problem. 

Ø Explain your architecture in your document. For example - Why you have opted for 3-tier architecture? Either load balancing, caching etc is provided ++.

Ø Document on below questions while doing the design itself which helps in part-3 exam also.

ü How we are going to communicate to external Systems?  
ü How we are going to handle security?  
ü How we can achieve Session & Transaction Management?
ü How to achieve non-functional requirements like scalability, performance and availability?
ü Decisions on deployment Infrastructure?

2.2 UML Deliverables:

Ø Once the basic architecture is ready, we can go ahead with UML diagrams.  Below are the points against each UML diagram:
ü Component Diagram(40 points)
ü Class Diagram (40 points)
ü Sequence Diagram (16 points)
ü Deployment Diagram (24 points)
ü Assumptions and Design decisions (Extras)
ü Technical Risks and mitigation (16 points)
Ø UML’s can be developed using Sparx EA Tool or Rational Rose.

o Class Diagram:   

Class Diagram takes more time as compared to other diagrams. We need to identify the different classes, their attributes; operation’s and defines the relationship between the classes. No of classes can vary from person to person. Good to keep the no of classes below 50. 

o Component Diagram:   

Component diagram depicts how the different components are wired together to form larger components. Describes the Structural relationships between the components. 


o Deployment Diagram :  

Deployment diagram is quite easy compared to the other diagrams. Based on your architecture, present your Server’s (Firewall Server, Managed Server, Admin Server, Database ++) here.



o Sequence Diagram :




Create one sequence diagram for each use-case provided in your assignment.





2.3 Design Document:

ü Below are sample table of Content’s for the design document.  
     


It’s good to include UI wire frame, which gives a good understanding to the evaluator what’s there in your mind. Also document Technical risk and mitigation plan. Once done with the UML’s and design document, it’s highly recommended to get it reviewed before submitting the same to Oracle. 

2.4 Assignment Submission :

Once completed with the design document, UML Diagrams ++, we need to create an index.html with your Name, Oracle testing ID, and provide link to UML diagrams and design document.  Build the jar file and the same can be uploaded to Pearson Vue site before the deadline mentioned.


3. Exam Part-3 (Step 3 of 3)

Part 3 is all about defending your architecture solution. It involves 120 minutes essay exam based on the assignment submitted in step2. Assignment must be submitted before we can register for the essay exam. We will be provided with 8-10 Questions’, and we are required to provide explanation on our design decision’s and why we have chosen one framework or technology over the other. If you have documented all your design decision, then step-3 will be quite easy.  



Good luck to all OCMJEA aspirants !!! 

                     “The act of getting certified will make you a better architect.”
                                                                       (Humphrey Sheil, CTO, SCEA, and SCEA examiner)

            
            Last modified @ 01-Nov-2012 11:30 PM  by Shameer Thaha

Spring Batch


SPRING BATCH

1. Introduction

Spring Batch is a lightweight, comprehensive batch framework which enables bulk processing of business Operations. 
A typical batch program generally reads a large number of records from a database, file, or queue, processes the data in some fashion, and then writes back data in a modified form.  
Spring Batch automates this basic batch iteration providing a robust, enterprise-scale solution to batch processing.  

2. Spring Batch Advantage:

ü Provides reusable functions that are essential in processing large volumes of records. 
ü Highly scalable, Easy-to-use & Customizable. 
ü Transaction Management by Spring API’s.  Optimized by committing periodically (chunk)
ü Exception handling Capability - Automatic retry after failure. RetryTemplate, Completion Policy to handle the exception. 
ü Multiple job execution Options - Task Executor, Partition Step, Remote Chunking approach (messagingGateway).
ü Other features includes processing statistics, job restart, skip, and resource management.
ü Spring Batch Admin provides a web-based user interface that features an admin console for Spring Batch applications and systems.

3. Getting Started (Spring-Batch-Core)

The following steps explain how to create a simple Spring Batch Core Module. 

Configure pom with Spring Batch dependencies. 

 <dependency>  
    <groupId>org.springframework.batch</groupId>  
    <artifactId>spring-batch-core</artifactId>  
 </dependency>   
 <dependency>    
    <groupId>org.springframework.batch</groupId> 
    <artifactId>spring-batch-infrastructure</artifactId>  
 </dependency>

3.1. Spring Batch configurations (xml) :

Configure spring batch jobs as below in spring-batch.xml 

<!-- BatchJob1 Configuration --> 

 <job id="batchJob1" job-repository="jobRepository" incrementer="incrementer" xmlns="http://www.springframework.org/schema/batch">
  <step id="step1" >   
  <tasklet transaction-manager="transactionManager" start-limit="100" >   
  <chunk reader="batchReader"  processor="batchProcessor"  writer="batchWriter"  commit-interval="4"/>                            
  </tasklet>
  </step> 
</job>

<bean id="incrementer" class="com.rainbow.batch.util.BatchJobParametersIncrementer"/>


3.2 Configure JobRepository(InMemory Job Repository) and JdbcCursoritemReader (using @Configuration annotation) :

@Bean 
 public AbstractJobRepositoryFactoryBean jobRepository() 
 {  
  AbstractJobRepositoryFactoryBean inMemJobRepository = new MapJobRepositoryFactoryBean();
  inMemJobRepository.setTransactionManager(jdbcTransactionManager());
  inMemJobRepository.setIsolationLevelForCreate(&quot;ISOLATION_DEFAULT&quot;);  
  return inMemJobRepository;   
 }

 @Bean
 public JdbcCursorItemReader jdbcCursorReader() 
{
  JdbcCursorItemReader jdbcCursorItemReader = new JdbcCursorItemReader();
  jdbcCursorItemReader.setDataSource(emiaDataSource());
  jdbcCursorItemReader.setSql(batchReader.SELECT_QUERY);
  jdbcCursorItemReader.setRowMapper(batchTORowMapper());
  return jdbcCursorItemReader;
}
 
3.3. Create Batch Reader :

/**  Read from Source Database using JdbcCursorItemReader and pass the result to Processor defined in batch-context. 

@Component("batchReader")
public class BatchReader implements ItemReader, StepExecutionListener 
{ 
 public static final String SELECT_QUERY = "select * FROM ABC Table ";

 @Override
 public BatchTO read() throws Exception {  
  Object cursor = jdbcCursorReader.read();  
  if ( cursor !=null ) {                
   batchTO = (BatchTO)cursor;   
   log.info("reader():batchTO.getBatch_Type() : " + batchTO getBatch_Type());         
   return batchTO;
  }
  else {
   return null; 
  }   
 } 

3.4. Create Batch Processor :

/** Process data received from Reader and pass the result to Writer.


@Component("batchProcessor")
public class BatchProcessor implements ItemProcessor {

 @Override
 public BatchTO process(BatchTO batchTO) throws Exception
 {
  batchTO.setBatch_Type("{" + batchTO.getBatch_Type() + "}");
  return batchTO      
 }  


3.5. Create Batch Writer :

@Component("batchWriter")
public class BatchWriter implements ItemWriter 
{ 
 
@Override
 public void write(List writerList) throws Exception {     
  for (Iterator iterator = (Iterator) writerList.iterator(); iterator.hasNext();) {
   BatchTO batchTO = iterator.next();
   log.info("write():batchTO.getBatch_Type() : " + batchTO.getBatch_Type());
  }
}

3.6. Trigger the job using JobLauncher  :

@Test
  public void testBatchJob1() throws Exception 
 {
     @Autowired
     private JobLauncher emiaJobLauncher;
 
               jobExec = batchJobLauncher.run(batchJob1, new JobParameters(parametersMap));
}

4. Spring-Batch-Admin :

The following steps explain how to create a simple Spring Batch Admin Module. 
Steps

4.1. Configure Maven pom.xml with Spring Batch Admin dependencies. 


 <dependency>    
   <groupId>org.springframework.batch</groupId>
   <artifactId>spring-batch-admin-manager</artifactId> 
 </dependency>  

 <dependency>    
   <groupId>org.springframework.batch</groupId> 
   <artifactId>spring-batch-admin-resources</artifactId>  
 </dependency>


4.2. Spring Batch configurations (xml) :


<!-- configure Transaction Manager and dataSource--> 

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
 </bean>
  
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">  
  <property name="driverClassName" value="${batch.jdbc.driver}" />
  <property name="url" value="${batch.jdbc.url}" />
  <property name="username" value="${batch.jdbc.user}" />
  <property name="password" value="${batch.jdbc.password}" />
 </bean>


 4.3. Configure JobRepository(JobRepositoryFactoryBean) and JdbcCursoritemReader (using @Configuration annotation) :

@Bean 
 public JobRepositoryFactoryBean jobRepository() 
 {       
  JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
  jobRepositoryFactoryBean.setTransactionManager(transactionManager);   
  jobRepositoryFactoryBean.setDatabaseType("mysql");
  jobRepositoryFactoryBean.setDataSource(dataSource);
  jobRepositoryFactoryBean.setTablePrefix("BATCH_");
  jobRepositoryFactoryBean.setIsolationLevelForCreate("ISOLATION_DEFAULT");
  return jobRepositoryFactoryBean;   
 }

4.4. Create below tables using schema-mysql-create.sql.

    
               
4.5. Build and deploy the war File. Launch the Batch Admin Console to trigger the Jobs. Jobs Screen list all available Jobs.  
  
            


             
4.6. Select the respective jobs, enter required parameters and launch the job. Status of the job can be tracked using Executions tab. Batch Admin Module uses the above created tables to store batch execution details.



  
           
            

5. References : 



                    Last modified @ 01-april-2013 by Shameer Thaha.