Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
非同期ツールキット「Vert.x」のご紹介
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Masatoshi Itoh
November 18, 2023
Programming
430
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
非同期ツールキット「Vert.x」のご紹介
JavaDoでしょう#23 Java21リリース記念イベント@札幌 で使用したLT資料です。
Vert.xの「非同期」以外のおすすめポイントを紹介します!
Masatoshi Itoh
November 18, 2023
More Decks by Masatoshi Itoh
See All by Masatoshi Itoh
Hello - 本を書く- World !!
masatoshiitoh
0
110
TPI NEXTを読みました
masatoshiitoh
0
260
サーバーサイド開発にありがたい GitHub Copilot / ChatGPT
masatoshiitoh
1
1.1k
コードを書いたら負けなのか?
masatoshiitoh
0
500
1999年 最新バックアップ事情
masatoshiitoh
0
220
Google I/O 報告 (Google Assistant)
masatoshiitoh
0
520
GDC報告会資料 海外に見る「生産性改善」動向
masatoshiitoh
0
1.3k
イケメンシリーズでのORMとスロークエリ対策について
masatoshiitoh
0
2.8k
Erlangご紹介 websocket編
masatoshiitoh
0
2.9k
Other Decks in Programming
See All in Programming
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.4k
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.7k
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
670
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
260
今さら聞けない .NET CLI
htkym
0
200
SlackアプリとLambdaの 連携を構築した話
pawn_4_s
1
130
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
160
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
160
Cloudflare is Agents
chimame
0
170
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
160
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
240
AIが無かった頃の素敵な出会いの話
codmoninc
1
470
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.4k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
480
BBQ
matthewcrist
89
10k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
580
Optimising Largest Contentful Paint
csswizardry
37
3.9k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
300
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
480
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
900
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Transcript
非同期ツールキット 「Vert.x」のご紹介 2023/11/18 JavaDoでしょう#23 Java21リリース記念イベント@札幌 @masatoshiitoh (twitter/X)
自己紹介 いとうまさとし(Twitter: @masatoshiitoh) 株式会社セガ札幌スタジオ 今回の発表はセガサミーグループの技術スタックや開発・運 営中のタイトルとは全く関係ありません
過去作品 Speed.rbbtoday.com(IRI-CT、現イード在籍当時に開発) 最近のGist Camel から Camel Vert.x component 経由でVert.xクラス タのイベントバスを読み書きする とにかくApache Camelを動かしてみるための最初の手順
今回は Vert.xが楽しい、というお話をします
今回は Vert.xが楽しい、というお話をします 非同期の話はしません(え 今回の発表はセガサミーグループの技術スタックや開発・運 営中のタイトルとは全く関係ありません
Vert.x について 1. Vert.x は、 Eclipse Foundation のプロジェクトのひとつ 2. JVM
(Java Virtual Machine) で動作します 3. 非同期プログラミングをサポートするツールキットです
Vert.x について 非同期アプリケーションの何がうれしいか? 1. OSスレッドを節約できる 2. CPUリソースを比較的有効に使える … このあたりはグリーンスレッドで解消!(しょんぼり
PROS v.s. CONS Pros 1. アプリケーション内のサブプロセス的に使えるVerticleが便利 2. イベントバス経由のメッセージ交換が便利 3. アプリケーションレベルのクラスタが組みやすい
Cons 1. Spring Boot+グリーンスレッドが、ほとんどのケースで楽
Verticleとは Vert.xアプリケーションの内部で動作する、アクターモデル のように利用できるクラスです AbstractVerticleを継承します Verticle用途例 ひとかたまりの機能を担当(例:ウェブサーバー機能)
イベントバスとだけやりとりして動作するアクター “Character.player.123456” “Character.npc.shop01”
Verticleとは 定義: public class QueryApiVerticle extends AbstractVerticle { @Override public
void start() throws Exception { vertx.eventBus().consumer("query", message -> { System.out.println(“MSG:" + message.body()); message.reply("Query received!"); }); } 起動: vertx.deployVerticle(new QueryApiVerticle());
イベントバス とは Vert.x上で使用できるメッセージング機構です データの送受信モデルとして、どちらも使用可能です Publish – Consume
Publish – Subscribe 送受信のキーは文字列で指定可能です
イベントバス とは 送信側: vertx.eventBus().request("query", params, reply -> { if (reply.succeeded())
{ routingContext.response() .putHeader("content-type", "text/plain") .end((String) reply.result().body()); } else { routingContext.response() .putHeader("content-type", "text/plain") .end("Failed to send query!"); } }); 受信側: vertx.eventBus().consumer("query", message -> { System.out.println(“MSG:" + message.body()); message.reply("Query received!"); });
クラスタを 組む、とは Vert.xは、Vert.x同士のクラスタを構築してHA環境を実現 できます HazelcastやZookeeper、Apache Igniteなどを使ってクラ スタマネージャを実現しています
クラスタ内はイベントバスを使ってメッセージングできるほ か、Key-Valueストア、ロック、カウンターがクラスタマ ネージャによって提供されます
クラスタを 組む、とは クラスタマネージャーの追加(pom.xml): <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-hazelcast</artifactId> <version>4.4.0</version> </dependency> クラスタを有効にする(pom.xml): <plugin>
<artifactId>exec-maven-plugin</artifactId> : <configuration> <mainClass>io.vertx.core.Launcher</mainClass> <arguments> <argument>run</argument> <argument>${main.verticle}</argument> <argument>-cluster</argument> :
クラスタを 組む、とは Hazelcast クラスタマネージャであれば、同じサブネット上 で起動すれば自動でつながる 外部連携、たとえばCamelのVert.xコンポーネントも、クラ スタ経由で接続するみたい(調査資料↓) Camel
から Camel Vert.x component 経由でVert.xクラ スタのイベントバスを読み書きする (github.com) https://gist.github.com/masatoshiitoh/9aeb0e00a3e177f080cff4a0130a576b
というわけで Vert.xって楽しそうかも? と思っていただけたら幸いです
ご清聴 ありがとう ございました (セガ札幌スタジオ、中途採用絶賛おこなってます)