日本企業が JavaOne 基調講演で数多く登壇
富士通
日立
NEC
損保ジャパン日本興亜
Mazda
:数村様
:村上様
:岸上様
:浦川様
:吉岡様
https://javaee-guardians.io/
火星のお話よりも
不安を払拭するため基調講演で
もう少し Java EE に時間を
掛けるべきでした
ブレークアウト・セッションの参加で
不安は払拭 !! 戦略的には良い方向へ !!
(詳細はのちほど)
でも、べつの不安が !!
September 22, 2016
Hilton San Francisco Financial District
https://microprofile.io/
ベンダー&コミュニティが集結
標準化には時間を要す!!
開発のすすめ方・戦略は
MicroProfile の方が時代に適応 !!
(個人的に支援)
戦略的には良い !!
ここに記載する内容は
あくまでも提案内容(未決定) !!
Cloud
Micro Service
• クラウド化・マイクロサービス化
• マイグレーション・パスを用意
• Java EE の後方互換性を維持
• REST(JAX-RS) は今後重要
Java EE Spec Lead
(Linda DeMichel)
Java EE 9 がメイン
Java EE 9 への準備
クラウド & マイクロサービス
同時に開発を進行
Java EE 8 の提案内容
リアクティブ
プログラミング
(Responsive)
耐障害性(Resilient)
弾力性 (Elastic)
メッセージ駆動 (Message Driven)
• レイテンシ向上のために必要
• 非同期処理
• ノン・ブロッキング I/O
• Java EE 8 は EE 9 への移行パス
• Java EE 9 で最終的に対応
Java EE Spec Lead
(Linda DeMichel)
JAX-RS 2.1 : クライアント側の大幅な更新
• リアクティブ・プログラミング
Service C
Service C
JAX-RS 2.0 の非同期処理(コール・バック地獄)
JAX-RS 2.1 : CompletableFuture<T>を利用
非同期処理をより簡単に
RxJava も利用可
JAX-RS 2.1 : Non-Blocking 対応
待ち状態のリソース消費を防ぐ
ヘルス・チェック : 新JSR
• 生死監視用の REST API を定義 (JSON フォーマット)
• ブートストラップ・エンドポイントを用意
• アノテーションでエンドポント実装可能
• レポート用のヘルパークラスを用意
ヘルス・チェック : 新JSR
• 適用範囲は実装依存
• セキュリティ要件は実装依存
Configuration - 外部設定
• プロパティ, XML, JSON フォーマットをサポート
• 複数の設定ソースをサポート
• 階層化とオーバライドをサポート
• オプションの設定スキーマ
• ポーリングと動的プロパティ
動的設定変更が可能 (Archaius を参考)
Configuration - 外部設定
Configuration 実装例
マルチテナンシー対応
• テナントによる特定のカスタム UI の提供
• テナント毎のデータソース
• テナント毎のセキュリティ
マルチテナンシー対応 - テナント・コンテキスト
• リクエストに対し TenantContext オブジェクトを埋め込む
• TenantContext はテナントを識別する情報を保持
• TenantContext はアプリケーション内で利用可能
• コンテナはテナント毎の処理を実行可能
public interface TenantContext{
public String getTenantID();
public String getTenantName();
public void setProperty(String name,
String value);
public String getProperty(String name);
public Map<String, String> getProperties();
}
マルチテナンシー対応 - インタフェース
マルチテナンシー対応 - データ・アクセス
• @MultiTenant アノテーションを宣言
• テナント毎の DB に接続するため TenantContext を利用
セキュリティ – JSR 375
Java EE 8 で対応
(クラウド対応に必要)
Java EE 9 で対応
(マイクロサービスで利用)
Java EE 9
マイクロ・サービス
マイクロサービス開発の標準にしたい
MicroServices
UI ロジック
UI ロジック
UI
ロジック
UI
ロジック
標準的な実装がない
開発者が選択 -> 標準化
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
• マイクロサービスの主要な技術の一つ
• 全クライアントがアクセスする唯一のエントリポイント
API
Gateway
API
Gateway
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
Service C
10.0.1.1:8080
10.0.1.1:8081
10.0.1.2:8080
10.0.1.2:8083
10.0.1.3:8082
10.0.1.4:8085
Service C
1. 接続先情報を Service Registory に登録
IP アドレス
Port 番号を登録
Service C
Load
Balancer
API
Gateway
2. 接続先の情報を問い合わせ
LB が接続先の
IP アドレス
Port 番号を取得
Service C
Load
Balancer
API
Gateway
3. 取得した情報を元にサービスに接続
取得した情報を元に
LB はサービスに接続
HttpClient.connect(“http://localhost:8081”);
HttpClient.connect(“http://service_dns.example.com”);
//Spring の場合
DiscoveryCllient getInstance(“SERVICE-NAME”);
@InternalService
@Service(name=“userProfiles”,compatibilityVersion=“1.2”)
@Depends(services={“userAvatars:2”,”userAddresses:5”})
public ProfileData getUserProfile(ID userID){
}
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
Service C
Load
Balancer
API
Gateway
public class Foodservice {
@RetryPolicy(delayPeriod=10 unit=SECOND, numRetries=1)
@CircuitBreaker(fallbackMethod=
“getBooksByAuthorFallBack”)
@BulkHeadPolicy(threadCount=5)
public Collection<BooK> getBooksByAuthor(
String authorName){…}
public Collection<Book> getBookdsByAuthorsFallBack(){…}
}
項目 利用する機能(サービス)
設定管理 Spring Cloud Config + Bus
サービスの登録・発見 Netflix Eureka
ロードバランサ Netflix Ribbon
サーキット・ブレーカー Netflix Hystrix + Turbine
Proxy Server Netflix Zuul
認証 Spring Cloud Security
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
Service C
ベンダー依存の API を利用
package javax.persisntece.nosql;
import java.util.Iterator;
public interface CROUDStore<K extends ID,
V extends BaseStore<K,V>{
Iterator<V> findAll();
V find(K key);
V persist(V value);
void remove(K key);
void remove(V value);
}
public interface KVStore<V>
extends CROUDStore<ID<String>, V>{
void persist(ID<String> key, V value);
}
public interface KVCacheStore<V>
extends KVStore<V>{
void persist(ID<String> key, V value, long expires);
void expire(ID<string>key, long expires);
}
public interface UserStore
extends MongoStore<String, User>{
List<User> findBynameStartingWith(String regexp);
List<User> findByLastnameEndingWith(String regexp);
@Query(“{‘age’ : { $gt: ?0 , $lt: ?1}}”)
List<User> findUsersByAgeBetweeen(int ageGT, intageLT);
}
public class UserStoreIntegrationTest{
@Inject UserStore userStore;
public void insertUser(){
final User user = new User();
user.setName(“Jon”);
userStore.persist(user);
List<User> users =
userStore.findUsersByAgeBetween(5,10);
… }
}
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
更新
参照(クエリ)
更新
参照(クエリ)
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
Tolerant Reader : (寛容な読み込み)
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
Chained & Branch Service
Service C
Service C
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
Asynchronous Messaging (メッセージ駆動)
Azure Event Hub
数百万 Req/Sec のイベントを取得しアプリに配信
メッセージ駆動 (Message Driven)
@Inject
EventPublisher(“mytopic”)
publisher;
@Inject
EventConsumer(“mytopic”)
consumer;
@EventListener(“mytopic”)
public void onMyEvent(MyEvent event){
//doSomething;
}
Asynchronous Messaging (メッセージ駆動)
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
メッセージ駆動 (Message Driven)Java EE パッケージ
Java EE
Key API
ホスト 1
メッセージ駆動 (Message Driven)Service Instantiation
ホスト 1/コンテナ
コンテナ2
サービスがどこで稼働しているか
わからない (ホスト・コンテナ)
メッセージ駆動 (Message Driven)Service のプロビジョン方法の提供
メッセージ駆動 (Message Driven)Service のグルーピング方法の提供
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
メッセージ駆動 (Message Driven)Consumer-Driven Contracts
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
メッセージ駆動 (Message Driven)Domain Event (Event Sourcing : Eventual Consistency)
メッセージ駆動 (Message Driven)Domain Event (Event Sourcing : Eventual Consistency)
• API Gateway
• Service Registry / Service Discovery
• Circuit Breaker
• Polyglot Persistence
• Command Query Responsibility Segregation (CQRS)
• Tolerant Reader
• Chained Services
• Asynchronous Messaging
• Service Instantiation
• Consumer-Driven Contracts
• Domain Events
その他
public class MyService{
@EventService()
EventService eventService;
public void foo(){
eventService.subscribe(“StateChanges”);
}
}
クラウド・プロバイダが提供するサービスへ接続可能
@ConfigService(namespace=“Srv”)
ConfigService configService;
Auto Scale
Auto Scale
• リアクティブ用の包括的な API を提供
• Publish/ Subscriber API
• Publisher で既存のデータ構造(Itterable,Arraysなど)を利用可能
• イベントのストリーム処理用の操作APIを提供
• バックプレッシャーをハンドルするための API を提供
• 改良したエラーハンドリング・メカニズムを提供
• イベント・ストリームの相互運用性
• JDK 9 の Flow API を利用
• 他のリアクティブ実装もプラグイン可能
Java SE 9 のリアクティブ対応
参考情報 (私がつけた優先順)
セッション番号 タイトル
CON7976 Java EE 8 Update
CON7975 Enterprise Java for the Cloud
CON8292 Portable Cloud ApplicaHons with Java EE
CON7983 JAX-RS 2.1 for Java EE 8
CON7977 Java EE Next – HTTP/2 and REST
CON7980 Servlet 4.0: Status Update and HTTP/2
CON7979 Configuration for Java EE 8 and the Cloud
CON7978 Security for Java EE 8 and the Cloud
CON1558 What's New in the Java API for JSON Binding
CON4022 CDI 2.0 Is Coming
CON7981 JSF 2.3
BOF7984 Java EE for the Cloud
Java EE 8 の動画
https://www.youtube.com/watch?v=Th9faGLhQoM
Java EE 9 の動画
1. Enterprise Java for the Cloud
https://www.youtube.com/watch?v=t7miysQP7Dg
2. Portable Cloud Applications with Java EE
https://www.youtube.com/watch?v=nCqVSf5v37s
MicroProfile のイベント動画
https://www.youtube.com/watch?v=6emPnRChsEE
発表資料
http://www.slideshare.net/rayploski/microprofile-panel-sept-2016
参考情報
http://glassfish.org/survey
Where to go?
Azure Service Fabric
MS Cognitive Service と JAX-RS で
より良い社会・未来をつくりましょう!!
インフラエンジニア、アーキテクト、IT 戦略立案に関わる皆様を対象に
クラウドを活用したビジネスのデジタルトランスフォーメーションに必要な
マイクロソフトの最新技術情報と実践的ノウハウをご紹介します
2016 年 11 月 1 日 (火) – 11 月 2 日 (水)
ヒルトン東京お台場
http://microsoft-events.jp/mstechsummit/
JavaOne 2016 Report for Java EE

JavaOne 2016 Report for Java EE