Vert.x-tcp-eventbus-bridge Java代码示例

本文档介绍了如何使用Java实现Vert.x-tcp-eventbus-bridge的示例,包括pom配置、MainVerticle、TcpServerVerticle和TcpClientVerticle四个关键文件的详细说明。在理解官方文档的基础上,通过重写Groovy示例转为Java代码,阐述了如何不依赖Vert.x库直接利用Java TCP进行通信的方法。
摘要由CSDN通过智能技术生成

关于 Vert.x-tcp-eventbus-bridge 的详细用法,Vert.x 的官方文档(官方文档1官方文档2)都写得很简单,简单得还是让人搞不懂如何使用。

从网上找到了一篇介绍如何使用的文章:Vert.x TCP EventBus Bridge补遗。该项目中的例子源码在 github 上。看了源码之后,发现是一个 groovy项目。于是就将例子用 Java 代码重新写了下。总共有如下几个文件:

1. pom 文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>io.example</groupId>
    <artifactId>vertx-example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<vertx.version>3.4.2</vertx.version>
        <main.class>io.vertx.core.Launcher</main.class>
        <main.verticle>io.example.MainVerticle</main.verticle>
        <guava.version>20.0</guava.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-web</artifactId>
            <version>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值