LoginSignup
11
11

More than 5 years have passed since last update.

2016/9/3 SpringOne Platform 2016 報告会 参加メモ

Last updated at Posted at 2016-09-03

2016/9/3 SpringOne Platform 2016 報告会 参加メモ

イベント全体・キーノート

  • 主催がSpringコミュニティからPivotal社に変わった
    • Pivotal Cloud Foundryのセッションが増えた
    • 参加者2,000人超(昨年の倍)
    • 日本からも約30名が参加(日本人発表者も)
  • スポンサーの顔ぶれが大幅に変化
    • Accenture, Google, EMC, Microsoftなど大企業が肩を並べた
    • NTT Dataもシルバースポンサー
  • Case Studyが増えた
  • 基調講演
    • ツールだけでなくソフトウェア開発サイクルを回すCultureが重要(Pivotal Labsの紹介)
    • Springの歩み
      • 2002 DI/AOP
      • 2007 Annotation Config
      • 2009 Boot/Cloud
    • Spring 5.0
      • Reactive対応が目玉
      • 2017 Q1にリリース予定、Java SE9対応は5.1で
    • Spring 4.xは2019年までサポート
  • Spring 5.0は来春リリース! クラウドネイティブ開発、マイクロサービス化など最新技術・事例にあふれた4日間

Spring Core

"Modern Java Component Design with Spring Framework 4.3", "Spring MVC 4 Web Apps"

Spring Framework ふりかえりと4.3新機能

  • 4.2
    • コンストラクタインジェクション:フィールドをfinalにしてimmutableにできる
    • Lazy Injection Point
    • 合成アノテーション 
      • public @interface MyCustomeService{}
      • 上書きしたい属性だけ公開できる
  • 4.3
    • 4系のラストリリース、2019年までサポート、SpringBoot1.4のデフォルト
    • Core Container
      • コンストラクタが1つなら@Autowiredは省略可能に
      • JavaConfigクラスでコンストラクタインジェクションできるように
      • InjectionPoint like CDI:インジェクション先のメタ情報を取れる
      • ちなみにlombokだと、@Slf3jでLogger logが定義される
    • Web Improvements
      • 合成アノテーションの追加、@GetMapping @RequestScope
      • GET付与でHEADとOPTIONが自動サポート
      • 引数に@RequestAttribute("param1") String param1 => servlet APIに依存せずに取れる

Reactive

"From Imperative To Reactive Web Apps", "Reactor 3.0a JVM Foundation for Java 8 and Reactive Streams"

  • Reactive Streams
    • Stream processing, Asynchronus, Non-blocking, Back pressure
    • 処理しきれなくなったらインスタンスを増やす⇒リソースを効率的に活用
    • Publisher:無限にご飯を出してくる田舎の親戚、Subscriber:帰省した青年
  • Reactor 2.x:正直言ってクソだった(やろうとしていることが多すぎる、多すぎて分からない)
  • Reactor 3.0
    • Publisher
      • Mono[0|1]とFlux[n]
      • Reactive Streamsのpublisherの実装
      • RxJava(Netflix製)はReactive Streams準拠を重視していない(ユーザの多くがAndroid)
    • Spring 5はReactor Coreに依存している、Springの歴史の中で何かに依存するのははじめて

"A Lite Rx API for the JVM"

SpringOne Platform 2016 報告会 (A Lite Rx API for the JVM)

  • [元セッション]A lite Rx API for the JVM
  • [元セッション]lite-rx-api-hands-on

  • Reactive

    • 広義にはnon-blockingでevent-drivenなシステムを形容する言葉
    • ユースケース:スケール、安定的に動作、キャパシティプランニング容易性
    • BigData processing、外部サービスに依存するwebapp、データ生成側と利用側の処理速度に非対称性があるシステム、大量のクライアントを捌く必要のあるシステム
  • Reactive Streams

    • 非同期ストリーム処理の標準仕様
    • j.u.c.FlowとしてJava9にも組み込まれる予定
    • Subscriberが受け取るデータの個数を、自身でコントロール可能(backpressure)
    • Publisher, Subscriber, Subscription, Processor
    • Component A -> T1 -> Processor -> T2 -> Component B
  • Reactive API Library

    • RxJava 2.0
    • Akka-Stream
    • Reactor Core
  • Reactor

    • リソースの効率性に強くフォーカス
    • debug, logging, testを容易に行える
  • Mono

    • 1個(または0個)の値を放出するPublisher
    • subscribeにcallableを渡すと裏側でsubscriptionを生成してフローが流れる
  • Flux

    • 複数の値をemitするPublisher
  • Scheduller

    • publish/subscribeを行うスレッドのスレッドプールのfactory
    • single(), parallel(), elastic()
  • RxJavaとの相互運用

    • Rxjava1Adapter
  • Reactor and Spring 5

    • Flux/Monoを受け取り、返却可能なController
    • Flux/Monoを返却可能なHttpClient実装
    • Spring Initializrで手軽に試すことができる:Reactive Web(Spring Bootは1.4.1 SNAPSHOTを選ぶこと)
  • Reactor API Hands-on

  • 銀の弾丸ではない

    • 安定的な動作、予測可能なキャパシティと引き換えに、オーバーヘッドはある
      • 例:データベースのquery数は増える
    • 非同期処理特有の複雑さ、デバッグのしづらさはある

"Designing, Implementing, and Using Reactive APIs"

  • [元セッション]Designing, Implementing, and Using Reactive APIs
  • 実用経験に基づいたReactive APIの設計、実装、使用法を紹介
  • 戻り値をvoidにしてはいけない
    • subscribeするまではただの「設計書」にすぎない
    • 作った設計書を戻り値として返してやる必要がある
    • Mono delete(String id)
  • Functional Styleの推奨
    • 副作用のない、単純で小さなメソッドをつくり、組み合わせて大きな処理を行う
    • 組み合わせの道具:高階関数(関数を引数に取る、map/flatmapなど)
    • メソッド参照による組み立て(複数引数を取る関数には、補助関数とtupleで)
    • Pointfree Styleの推奨
    • f = (+1)
  • 条件分岐
    • エラーによる条件分岐(otherwise)
    • Emptyによる条件分岐(defaultWithEmptyなど)
    • 値による条件分岐は、if文を使って命令的に書けばよい(Mono/Fluxのメソッドでは直観的に理解しづらくなる)
  • テスト辛い問題
    • 非同期処理なので、仕事を頼んだ時点で、メインスレッドは終了してしまう
    • 他のスレッドの終了を待つ:java.util.concurrent.CountDownLatch
    • TestSubscriber⇒同期させるためのコードを自分で書かなくてよくなる
      • Reactorでは準備中、3.0.0.RELEASEでは除かれた、Clound Foundry Java Clientでは独自に実装したものを利用

Tracing

"How to Properly Blame Things for Causing Latency: An Introduction to Distributed Tracing and Zipkin", "Implementing Microservices Tracing with Spring Cloud and Zipkin", "Let's Visualize Your Spring Boot Applications"

[SpringOne2016] Distributed Tracing using Sleuth and Zipkin

  • 分散システムを組む時に必ず直面する問題
    • どこで問題が起きたか、どこがボトルネックか
  • 問題発生個所をログから調べる
    • リクエストに対してIDを発行してそれを共有
    • Spring Clound Sleuth
    • リクエスト全体:Trace、個別リクエスト:Span
    • HTTP/AMQPヘッダにIDを埋める、受け取ってThreadLocalに入れる、次に渡す・・・の繰り返し
  • サービスの構造を可視化する
    • Sleuthで集めた情報を使って、遅いところを探したりサービスの関連を見たい
    • Zipkin
      • Find Trace
      • Dependencies(サービスの関連が可視化される)
  • sleuthとzipkinの始め方
    • Spring Initializrで"sleuth" and "zipkin"を探す
    • zipkin側が落ちていた場合でも漏れなくtraceするには、間にRabbitMQ(かKafka)を挟む
  • Netflix VIZCERAL

Spring Cloud DataFlow

"Data Microservices in the Cloud"

[元セッション]Data Microservices in the Cloud

  • ETLに代わるもの
  • Spring XD Streams/ ZooKeeper
    • stream1 = http | cassandra
    • 課題:scale up / down、upgrade
  • Refactoring to MSA
    • コンテナに組み込まれた複数モジュールから、単体で実行されるスタンドアロンアプリへ
    • 独自ランタイムからプラットフォーム委任へ
  • Spring Cloud Stream
    • Spring Boot based event-driven microservice framework
    • kafka inspired
    • Message Brokerと会話できる
    • XD-Containerはなくなり、RuntimeはClound Foundryなどに任せる
  • Spring Cloud Task
    • Spring Batchとの親和性が高い

New Functional Web API in Spring 5

  • Annotation Hell -> Lambda
    • Spark, Ratpack, vert.x
  • Lambda-oriented HTTP routing & processing

Micorservices

"Consumer Driven Contracts and Your Microservice Architecture"

  • Consumer Drivern Contract
    • ConsumerがProducerに期待する機能をContractとして共有し、Producerの全Consumerに対する責務をまとめたもの
    • ProducerとCounsumer間で合意したAPIの利用方法
    • アーキテクチャレベルのTDD
    • spring cloud contract
  • consumer側でcontractを作成(Consumer Driven)してAPIの変更を促す
    • groovy DSL -> jsonにしてwiremockでstub化してテストを通す(spring cloud contract wiremock)
    • producerに対してcontractのPRを出す -> producer側はPRを受け入れるとテストコードが自動生成される

"Developing Microservices with Aggregates"

[SpringOne2016] Developing Microservices with Aggregates
[元セッション]Developing Microservices with Aggregates

  • SpringOne 2016 谷本さん的ベストセッション
  • マイクロサービスでトランザクション管理をどうするのか
    • 2 phase commitはこの先 生き残る選択肢ではない
  • 1回のマイクロサービスコール = トランザクション範囲 = NoSQLトランザクションにしていく
  • Event drivenを用いた結果整合性
    • データ更新/イベント発行 ⇒ event sourcing(DBを更新するのではなくイベントを発行する)
    • 履歴の積み重ね ⇒ 順番は関係なく結果整合性ベースで考える
    • どう集約するかはポリシー次第、ショッピングカードであれば最終的な状態をユーザに確認させる
    • ACID性を担保したければRDBMSでロックしてやるしかないが、そのACID性は本当に必要か?
    • 状態を更新しない、状態はイベントの蓄積から判断する(CQRSとも親和性が高い)

Spring Projects

"What's new in Spring Data"

[元セッション]What's New in Spring Data?

  • Hopper
    • Spring Framework 4.2ベース
    • query by example
      • ExampleにEntity例と一致条件(ExampleMatcher)を渡す
      • repo.findAll(Example)
    • Open Projection
      • findAllProjectedBy()
  • Spring Data 2.0
    • Spring Framework 5.0 / JDK 8ベース
    • reactive(Mongo DB, Redis, Couchbase)

"To Spring Security 4.1 and Beyond"

Spring Security 4.1 の新機能

  • @formatter.off
  • CookieCsrfTokenRepository
    • withHttpOnlyFalse()をつけるとJSから取得可能
    • デフォルトでXSRF-TOKENに格納される
  • Contents Security Policy
    • 許可するリソース取得元を定義
  • @AuthenticationPrinciple
    • Controllerの引数で取得できるようになった
  • Path Variable in Web Security Expressions
  • mvcMatcher
    • AntMatcherだと、末尾に"/"を負荷するとアクセスできてしまう

CaseStudy

  • アプリケーションのヘルスチェックと監視 -> Spring Boot Acturator + extention endpoint
  • Cloud Configで、デプロイなしでアプリケーションの挙動を変更
  • Spring Initializerをforkしてカスタマイズ
  • Microscerviecesは目的にするものではなく、大きいアプリケーションを徐々に分割していった結果

SPRING DAY 2016

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11