Upload
spring-io
View
4.025
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Speakers: Durai Arasan, ETrade Monish Unni, Etrade Data / Integration Track Extending from last year's conversation in SpringOne2GX on real world use of RabbitMQ and Spring Integration, this talk will be centered around REST service as first class citizen in Spring Integration with RabbitMQ. How do you build REST services and integrate with Spring Integration and RabbitMQ? What kind of role Node.JS can play in your architecture to simplify complex problems? We will address all of these questions and provide insight into design and architecture challenges to bring enterprise services to support modern client applications that expect REST Services.
Citation preview
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
REST Services with RabbitMQ, Spring Integration and Node.JS
Durai Arasan & Monish Unni
About Us
2
Durai Arasan, Director, Architecture Monish Unni, Sr. Principal, Architecture
Contents
• Background • Why Queues? • Why RabbitMQ? • Spring Integration + Services • Why JAX-RS or REST? • Demo
3
• What do web clients need? • Why Node.js? • Handling routes • Node transformations • Node aggregation • Demo
Background
• Speed • Multiple languages • Platform for legacy Services • Large number of Services • Mixed payload formats • Mixed protocols • Fault isolations • Logging • Usage reporting
4
5
Architecture
DLX + AEProcess Python ProcessSI + CXF
Java ProcessC Process
Rabbit MQMessage Bus
SIJava Process Python Process
Client
AMQP
X
CP
C Process
Proc
ess
Man
ager
PC PCPCDLX + AEConsumer Process
Adm
in &
M
onito
rs
Security
Why Queues?
• Single queue makes every request at the mercy of previous requests.
• Traffic shaping or Quality of Service (QoS) • Valid response when server can’t handle requests
• Avoid “503 - Server too busy” • Monitoring pending requests • Administration of consumers based on load • Requests, response & fault isolation
6
Why RabbitMQ?
• AMQP Compliant • RabbitMQ Extensions for enterprise
• Alternate exchange (AE) • Dead letter exchange (DLX) • Extended properties for Queues & Messages
• Built-in monitoring • Security (amqps) • Large number of connections • Binding for many languages • Built-in Spring support
7
Spring Integration + Services
• Many great things in Spring Integration
• Custom service activators for • First class support of JAX-WS/RS services • Exception handling
• Custom namespace for • Simplified spring integration configuration • Gateways & Transformers • CXF Bridge
8
Custom Service Activators
• IntegrationConversionService for CXF message • Inbound gateways lazy bind CXF Service Activators • CXF destination instead of local conduit • Provides JAX-WS and JAX-RS endpoints • Error handlers
9
What is REST on AMQP?
basic.get and basic.publish
10
Why JAX-RS on AMQP?
• Is JAX-RS about building HTTP based Restful services? • Is Transport Independence a bug or a feature?
• REST is not about using HTTP • Allows to leverage JAX-RS eco-system for AMQP
11
JAX-RS Interfaces
12
JAX-RS Configuration for AMQP
13
Custom Spring Integration Gateway and namespace
14
Demo
15
What do web clients need?
16
http:// webservices
Our Choice
17
Why Node.js?
• Shines in I/O • Networking
• Naturally asynchronous • Javascript callback support
• Transformations • Choose your batteries
18
19
Architecture
DLX + AEProcess Python ProcessSI + CXF
Java ProcessC Process
Rabbit MQMessage Bus
SIJava Process Python Process
Client
AMQP
X
CP
C Process
Proc
ess
Man
ager
PC PCPCDLX + AEConsumer Process
Adm
in &
M
onito
rs
Security
Node.js
AMQP
HTTPWeb
Handling routes
• RabbitMQ • Routes with exchange name and routing key • Backed by queues with binding key
• Node.js • Uses binding key list from RabbitMQ • url-template library matches incoming requests • Routes matching requests to RabbitMQ with headers
20
Handling Routes
21
Node.js RabbitMQ
GET/account/{id}
GET /account/120001
AMQP Headers - Routing Key - CXF Request URI - HTTP Method
AccountService
Route alias & Vanity URLs
• Advertising public APIs • Protecting internal service routes • HTTP attributes based methods need special mapping
22
Node transformations
• Protocol conversion • Payload conversion • Declarative routes • Aggregation • Avoids boilerplate code
23
Aggregation w/ async
• Composing control flow • series • parallel
24
Other usage
• APIs • Expose services as APIs
• Testers • Can be used as test clients to different endpoints
• Mock Services • Virtualize any service without much effort
• Benchmarks • Built-in support for reporting
25
Demo
26
Calling legacy services API Routes Aggregation
Node - Things to watch out
• Primitive stack trace • vague errors “EADDRINFO”
• EventLoop • 2 line stack-trace : debug
• Debug with strace, dtrace • V8 Engine
• Generational GC • may need a deep dive
27
Node - New and Good parts
• V8 native support for generators and yield! • looks very promising (no pun) • can remove crustified callback code
• function (err, callback) • forced to think about error and what to do
28
Node libraries
• amqp • async • elementtree • soap • loopback • swagger
29
Summary
• RabbitMQ • Scales to large number of connections • Fast & Secure • Binding for many languages
• Spring Integration • Easy to extend • Plugin service activators • In JVM orchestration
• Node.JS • Async I/O • Javascript support 30
Learn More. Stay Connected
We are Hiring! career.etrade.com
twitter.com/duraiarasan
linkedin.com/in/duraiarasan, linkedin.com/in/monishunni
31
Q & A
32