开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
4.x
分支 (1)
标签 (12)
4.x
3.6.0
3.4.2
3.4.1
3.4.0
3.3.3
3.3.2
3.3.0
3.2.1
3.2.0
3.0.0
3.0.0-milestone4
3.0.0-milestone3
4.x
分支 (1)
标签 (12)
4.x
3.6.0
3.4.2
3.4.1
3.4.0
3.3.3
3.3.2
3.3.0
3.2.1
3.2.0
3.0.0
3.0.0-milestone4
3.0.0-milestone3
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
4.x
分支 (1)
标签 (12)
4.x
3.6.0
3.4.2
3.4.1
3.4.0
3.3.3
3.3.2
3.3.0
3.2.1
3.2.0
3.0.0
3.0.0-milestone4
3.0.0-milestone3
vertx-examples
/
rxjava-2-examples
贡献代码
同步代码
对比差异 通过 Pull Request 同步
同步更新到分支
通过 Pull Request 同步
将会在向当前分支创建一个 Pull
Request,合入后将完成同步
File empty ...
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Vert.x RxJava2 extension examples

IMPORTANT: These examples use the RX Java 2 API. If you are interested by RX Java 1, check the rxjava-1-examples module.

Here you will find examples demonstrating Vert.x RxJava2 extension in action.

Vert.x RxJava 2 extension provides Rxified version of the Vert.x APIs. Please consult the Vert.x RxJava manual for detailed documentation on Vert.x core.

RxJava Web client examples

These examples shows the Rxified HTTP api.

Simple

A simple web client.

The client creates an Single<HttpRequest<String>> and then subscribe multiple times to the single to send the request.

Zip

A variation of the simple example with two client requests mapped to an Single<JsonObject> and then zipped in a single json object.

The main interest is to get the final result when the two responses are delivered.

Unmarshalling

The web client json response is unmarshalled to a Java object using the web client unmarshalling features.

RxJava Web examples

Real-time

This example demonstrates how an RxJava Flowable source can be sent real-time to the browser via a SockJSSocket.

SocksJS gives a WebSocket-like API in client side JavaScript even if the browser or network doesn’t support WebSockets.

This is ideal for so-called real-time web applications where you want quick, responsive communication between server and client and you’re probably rendering the user interface on the client side.

Run the server either in your IDE or on the command line, then open your browser and hit link:http://localhost:8080

This serves the index page which contains some JavaScript which opens an event bus connection to the server.

When the connection is open, a SockJS connection is opened on the /news-feed uri. When data arrives in the handler the script just uses some simple JQuery to write the message to the page.

On the server side, in the server when a SockJS connection arrives, we subscribe to an Flowable<String> (that is created from the EventBus, but it would be another source of data) and send to the browser the observed items.

When you get the index page in your browser you should see it update every second as it receives a message.

RxJava 2 Http examples

These examples shows the Rxified HTTP api.

Simple

A simple http server and client.

The server uses an Flowable<HttpServerRequest> to serve request:

The client uses an Flowable<HttpClientRequest and applies flatMap to get a Flowable<Buffer>

Reduce

Same as simple example however the client applies several operations on this flowable to end with the http client response:

  • flatMap transforms the Flowable<HttpClientResponse>Flowable<Buffer>

  • reduce merge all response buffers in a single buffer

  • map transform the buffer to a string

  • subscribe delivers the response content

Zip

A variation of the simple example with two client requests mapped to an Flowable<JsonObject> and then zipped in a single json object.

The main interest is to get the final result when the two responses are delivered.

Unmarshalling

The http client json response is unmarshalled to a Java object: the RxHelper.unmarshaller static method creates an Rx operator applied to the response via the lift.

Backpressure

The http server which uses Vert.x-Web router and defines a "drop" strategy when the server is overloaded (backpressure).

RxJava event bus examples

The event bus provides a natural fit with the Rx api.

Publish / Subscribe

A reinterpreation of the core publish / subscribe example with the subscriber using the Rx api.

Ping / Pong

An example of sending, receiving and replying to messages using the Rx api.

Zip replies

The example Sender sends two messages over the event bus and wait for replies, the zip operation is applied to deliver a single reply when the two replies are received.

RxJava 2 Database examples

SQL client example

An example showing the SQL client Rxified api, after the client connected to the database, it chains operations via the flatMap operation and then subscribes to the result.

SQL client Transaction Handling

An example showing an Rxified SQL client api to handle simplified transaction that commits if all succeeded or rollback with exception propagation to the caller in case of anyone failed.

Mongo example

An example showing the Mongo Service Rxified api, after the client connected to Mongo, it chains createCollection and insert via flatMap and then subscribes to the result to do a query in the onComplete.

Scheduler examples

Vertx for RxJava provides schedulers for performing delayed, periodic actions.

Periodic events

RxJava timer can use Vertx scheduler for scheduling actions on the event loop, this example shows a 1 second periodic flowable scheduled on Vertx event loop.

Blocking action example

When an Flowable operation is blocking, a blocking Vertx scheduler can be used to perform the action, this examples shows how blocking operation can be scheduled on Vert.x

Scheduler examples

These examples demonstrate usage of Vert.x net servers and clients with RxJava2

Greeter

This example combines RecordParser and RxJava2 for a TCP client/server exchange. When the client sends a name to the server, it replies with a greeting. Names and greetings are line-separated.

Services examples

Rxified Vert.x Services examples

Service Proxy example

This example shows you how to make your service proxy Rxified with RxJava2.

举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

vertx 官方样例-4.x版本
暂无标签
README
Apache-2.0
使用 Apache-2.0 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/githubsync/vertx-examples.git
git@gitee.com:githubsync/vertx-examples.git
githubsync
vertx-examples
vertx-examples
4.x
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /