Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

49
Service oriented architecture mixing Ruby and Java Maurício Linhares

description

Presentation done at RubyConf Brazil 2012.

Transcript of Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Page 1: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Service oriented architecture mixing

Ruby and JavaMaurício Linhares

Page 2: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

WHO?

Software Developer da OfficeDrop.com

@mauriciojr

https://github.com/mauricio

Page 3: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop
Page 4: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

SOA isn’t bad, the implementations we

get from hungry consultants are

Page 5: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

SOA is building independent apps

that do one thing well and leave everything

else to othersFeels like something you have heard before?

Page 6: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Write programs that do one thing and do

it well. Write programs to work together. Write

programs to handle text streams because

it is an universal interface.

Doug Mcllroy – The UNIX philosophy

Page 7: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Blame the messenger, not the

message

Page 8: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop
Page 9: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Old Rails app (2.x), large, with a growing team working on it

Page 10: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Running all tests took too long…

Page 11: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

We used the database as a queue

Page 12: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

We had long QA periods

Page 13: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Everything happens in a single app, where

everyone change code

Why?

Page 14: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

How can we solve this?

Page 15: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Ah, the divorce!

Page 16: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Two zones

Documents management

Documents processing

Page 17: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Documents management stays

on the webapp, processing

documents migrates to a new app

Page 18: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

If it’s a new app, can we change

technology? How do we integrate both?

Page 19: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

resque as our work queue

our jesque fork is at - https://github.com/mauricio/jesque

Page 20: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

API REST with JSON for communication

Page 21: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

S3 to store the results

Page 22: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Client sends a file to the app server

Processing message is sent to the queue

A worker accepts the job

Worker signals that it has finished the job

Page 23: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Did it work?

Page 24: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

The two apps started evolving in separate

Page 25: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

The backend system started to have smaller cycles,

independent of the webapp, with many

deploys a day

Page 26: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Less code meant that there were less tests

to be runThe backend didn’t have to run webapp tests, the webapp

didn’t have to run the backend tests

Page 27: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

There were no direct dependencies

between the apps, they didn’t have to

be deployed together anymore

Page 28: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Auto-contained messages – the backend had all

information needed at the message level

Page 29: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

WHERE DID WE

Page 30: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Separate applications caused

communication problems between

the teamsWe’re all on the same boat, open the discussion of stuff

that affects both ends

Page 31: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Not everyone did run all apps and the documentation

wasn’t always up to date

Page 32: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Jesque’s code isn’t as simple as it could be

and most of the resque plugins are of

no use

Page 33: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Public and private API’s should not be mixed. Make sure they’re completely

separate.

Page 34: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Many apps in different

environments will complicate your deployment and team building

Page 35: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

What did we learn?

Page 36: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Build small, focused apps

Page 37: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

All communication should be done over

the API and from nowhere else

Page 38: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Define clearly what each application

should do

Page 39: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Create a minimal communication

interface with that you need today. It will

change.

Page 40: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Don’t mix model representation with

your model codeLook for solutions like Roar - https://github.com/apotonick/

roar

Page 41: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Separe fontes/bancos de Separate

databases/datasources for the different

apps

Page 42: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Plan and build stuff expecting failure

Page 43: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Build to fail

Page 44: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Rails Engines? Maybe?

Page 45: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Where are we today?

Page 46: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

HTML5 front end independent of the current webapp, all

API based

Page 47: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

Auto-scaling cluster and independent of the environment for

the backend is on the way

Page 48: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

THEY SAID SOA WAS BAD

THEY DON’T SAY IT ANYMORE

Page 49: Mixing Ruby and Java in a Service Oriented Architecture at OfficeDrop

THE ENDThank You