员工管理系统 2.0 橙色版(java实现版,附源码)

本文涉及的产品
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介: 员工管理系统 2.0 橙色版(java实现版,附源码)

员工管理系统 2.0 橙色版(java实现版,附源码)

员工管理系统简介:

项目注意事项:struts2中我的action跳转到另外一个action是用的redirect,因为redirect 是重定向到一个URL,我把路径写全之后他也可以跳转action


image.png



小型员工管理系统 1.0 绿色版(java实现版,附源码) :https://blog.csdn.net/weixin_44385486/article/details/120832999


员工管理系统 2.0 橙色版 :

整个系统其实很简单,这里主要技术:idea开发工具+JSP + Struts+Mybatis+ Mysql实现

1、管理员的登录,注册,验证码功能

2、员工的增删改查,批量删除,上传文件,下载文件 其中类的设计(实体)很有参考意义。

整个系统设计的目标人群是管理者,系统的主要功能是对员工进行各种信息的操作。

主要是完成对数据库的增删改查的功能。

3、新增功能:展示所有员工数据页面升级为分页(后端mybatis实现,前端使用bootStrap实现分页)展示所有员工,分页的页面新增图灵机器人 实现智能客服,新增跳转QQ客服功能


前提:项目新增功能:

1、智能机器人程序

图灵机器人网址:http://www.turingapi.com/

# 图灵机器人的访问
1. 地址:
   http://www.tuling123.com/openapi/api
2. apikey: 用来区别使用哪个机器人
    key=apikey的值
3. 问题:
   info=要问的问题. 
总结:
   **http://www.tuling123.com/openapi/api?key=apikey的值&info=这里拼接你的问题**

image.png



image.png

image.png

http工具

// 1. 定义一个问题
String que = "天津今天天气如何?";
/**
 * 2. 使用hutool的http工具,向图灵发起请求
 * 
 * key=是机器人的apikey
 * info=是向机器人发起的问题
 * 返回值是机器人回答的结果.
 */
String ans = HttpUtil.get("http://www.tuling123.com/openapi/api?key=7789c9a323de40908d7792be7b1dd7c6&info=" + que, Charset.forName("UTF-8"));
System.out.println(ans);
public class RobotTest {
    public static void main(String[] args) {
        System.out.println("--------欢迎使用智能机器人--------");
        //---循环开始
        while(true) {
            //2.提示用户输入问题
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入你的问题:");
            String que = scanner.nextLine();
            //3.如果用户输入“退出”,则退出程序
            if (que.equals("退出")) {
                break;
            }
            //4.创建用来处理问题的机器人对象
            String ans = HttpUtil.get("http://www.tuling123.com/openapi/api?key=7789c9a323de40908d7792be7b1dd7c6&info=" + que, Charset.forName("UTF-8"));
            //5.显示答案给用户
            System.out.println(ans);
        }
    }
}

一. 项目整体目录结构

MVC实现,界面层(Web)主要使用jsp来动态展现数据库中的数据,业务逻辑层(servlets)使用的servlet,数据访问层(dao)主要是连接各个Servlet与数据库之前的通信,从而实现对数据库的各种操作。其中的entity包主要是封装了两个实体:管理员和员工,方便且规范对数据的操作和代码的书写。

image.png

image.png




二. 界面效果展示:

1、管理员页面

(1)管理员登录页面

image.png


(2)管理员注册页面

image.png


2、员工页面

(1)员工页面展示

页面展示完成员工的增删改查

image.png

image.png



(2)员工更新【页面数据回显】

image.png


(3)添加员工页面

image.png


(4)图灵机器人实现智能回复

image.png


三、数据库设计

1、admin表(管理员的账号和密码)


image.png

2、user表(员工信息表)


image.png

四、核心jar包(jar包下载参见文章末尾)


image.png

五、核心代码展示:(完整代码参见文章末尾)

1、entity类


image.png

(1)Admin.java(管理员属性的实体层,这里有管理员的登录账号和密码的定义)

public class Admin {
    private Integer id;
    private String name;
    private  String password;

(2)User.java(和Admin.java差不多主要是实体属性的get和set方法)

public class User {
    private Integer id;
    private String username;
    private String password;
    private Integer age;
    private Date birthday;

2、Dao层


image.png

(1)AdminDao接口

管理员功能:登录 注册 退出

public interface AdminDao {
    /**
     * 登录
     * @param name
     * @param password
     * @return
     */
    public Admin selectByNameAndPassword(@Param("name") String name,@Param("password") String password);
    /**
     * 添加管理员
     * @param admin
     */
    public void insertAdmin(Admin admin);
}

(2)AdminDaoImpl.xml接口实现

<mapper namespace="com.tjcu.dao.AdminDao">
    <select id="selectByNameAndPassword" resultType="admin">
        select * from admin where name=#{name} and password=#{password}
    </select>
    <insert id="insertAdmin">
        insert into admin value(#{id},#{name},#{password})
    </insert>
</mapper>

(3)UserDao接口

员工功能:分页展示所有 、 添加 、 删除 、 修改

public interface UserDao {
    /**
     * 分页查询:查询当前页的开始条数,及当前页数
     * offset:表示查询条目的起始下标,
     * rows:表示当前页最多显示多少条
     * @param offset 当前页的开始条数
     * @param rows  页展示的条数
     * @return 用户集合
     */
    public List<User> selectPage(@Param ("offset")int offset, @Param("rows") int rows);
    /**
     * 查询当前数据库用户数据总条数
     * @return
     */
    public int selectTotalNumber();
    /**
     * 添加用户
     * @param user
     */
    public void insertUser(User user);
    /**
     * 删除用户
     * @param id
     */
    public void deleteUserById(Integer id);
    /**
     * 更新用户
     * @param user
     */
    public void updateById(User user);
    /**
     * 根据id查询用户,用户数据回显
     * @param id
     * @return
     */
    public User selectById(Integer id);
    /**
     * 批量删除
     * @param ids
     * @return
     */
    public void batchDelete(List<Integer> ids);
}

(4)UserDaoImpl.xml接口实现

<mapper namespace="com.tjcu.dao.UserDao">
    <!--动态分片-->
    <sql id="selectUser">
        select *
        from t_user
    </sql>
    <!--    
     /**
     分页查询:
      查询当前页的开始条数,及当前页数接口
      offset:表示查询条目的起始下标,
      rows:表示最多显示多少条
      public List<User> selectPage(int beginNumber,int size);
       mysql中分页的sql语句:
       limit关键字用来限制查询结果的条目数,通常用于分页查询。
       语法:
       //sql语句中的最后一行语句
            limit offset,rows;
             offset:表示查询条目的起始下标,
             rows:表示最多显示多少条
       例:获取前10行:
       select * from employees limit 0,10;
       例:获取11行~20行
       select * from employees limit 10,10;
        -->
    <select id="selectPage" resultType="user">
        select *
        from t_user limit #{offset},#{rows}
    </select>
    <!--
     查询当前数据库用户的所有条数
        public int selectTotalPage();
    -->
    <select id="selectTotalNumber" resultType="int">
        select count(*)
        from t_user
    </select>
    <!--
    insertUser:添加用户
    User属性: id,username,password,age,birthday;
    -->
    <insert id="insertUser">
        insert into t_user
        values (#{id}, #{username}, #{password}, #{age}, #{birthday});
    </insert>
    <!--
    删除用户
    deleteUserById
    -->
    <delete id="deleteUserById">
        delete
        from t_user
        where id = #{id}
    </delete>
    <!--
     更新用户
     updateById
     Mybatis中的Sql动态语句
     User属性: id,username,password,age,birthday;
    -->
    <update id="updateById">
        update t_user
        <set>
            <if test="username">
                username=#{username},
            </if>
            <if test="password">
                password=#{password},
            </if>
            <if test="age">
                age=#{age},
            </if>
            <if test="birthday">
                birthday=#{birthday}
            </if>
        </set>
        where id=#{id}
    </update>
    <!--
       根据id查询用户,用户数据回显
        selectById
    -->
    <select id="selectById" resultType="user">
        <include refid="selectUser"/>
        where id=#{id}
    </select>
    <!--
    批量删除
    batchDelete(List<Integer> ids);
    -->
    <!--
  t_user : 表名
  id : 字段名
  collection:表示类型,这里参数是数组,就写成array,如果是集合,就写成list
  item : 是一个变量名,自己随便起名
  -->
    <delete id="batchDelete">
        delete from t_user where id
        <foreach collection="list" open="in(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>

3、service层[略,详情请参见文章末尾]


image.png

4、struts2实现Action层


image.png

(1)AdminAction:管理员登录、注册

package com.tjcu.action;
import com.opensymphony.xwork2.ActionSupport;
import com.tjcu.entity.Admin;
import com.tjcu.service.AdminServiceImpl;
import org.apache.struts2.ServletActionContext;
import javax.servlet.http.HttpSession;
/**
 * @author 王恒杰
 * @version 1.0
 * @date 2021/10/17 20:37
 * @email 1078993387@qq.com
 * @Address 天津
 * @Description:
 */
public class AdminAction extends ActionSupport {
    private Admin admin;
    private String password2;
    private  String code;
    /**
     * 登录
     *
     * @return
     */
    public String login() {
        AdminServiceImpl adminService = new AdminServiceImpl();
        System.out.println("12323r4tfr"+admin);
        HttpSession session = ServletActionContext.getRequest().getSession();
        String code1 = (String) session.getAttribute("code1");
        System.out.println("1234"+code1);
        System.out.println("code"+code);
        if(code.equals(code1)){
            if (admin != null) {
               ServletActionContext.getRequest().getSession().setAttribute("login",admin.getName());
                return "loginOk";
            } else {
                return "loginError";
            }
        }else {
            return "loginError";
        }
    }
    /**
     * 注册
     *
     * @return
     */
    public String register() {
        AdminServiceImpl adminService = new AdminServiceImpl();
        if (admin.getPassword().equals(password2) ) {
            System.out.println("OK");
            HttpSession session = ServletActionContext.getRequest().getSession();
            String code1 = (String) session.getAttribute("code1");
            if(code.equals(code1)) {
                adminService.insertAdmin(admin);
                return "registerOk";
            }else {
                return "registerError";
            }
        } else {
            return "registerError";
        }
    }
    public Admin getAdmin() {
        return admin;
    }
    public void setAdmin(Admin admin) {
        this.admin = admin;
    }
    public String getPassword2() {
        return password2;
    }
    public void setPassword2(String password2) {
        this.password2 = password2;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}

(2)UserDao员工:增删改查

package com.tjcu.action;
import com.opensymphony.xwork2.ActionSupport;
import com.tjcu.entity.User;
import com.tjcu.service.UserServiceImpl;
import java.util.List;
/**
 * @author 王恒杰
 * @version 1.0
 * @date 2021/10/13 11:11
 * @email 1078993387@qq.com
 * @Address 天津
 * @Description:
 */
public class UserAction extends ActionSupport {
    /**
     * 总页数
     */
    private Integer totalPage;
    /**
     * 第几页
     */
    private Integer pageNumber;
    /**
     * 实体类
     */
    private User user;
    private List<User> users;
    private List<Integer> ids;
    /**
     * 分页实现展示页面
     *
     * @return
     */
    public String page() {
        UserServiceImpl userService = new UserServiceImpl();
        //第几页获取的用户
        users = userService.selectPage(pageNumber);
        System.out.println(users);
        //总页数
        totalPage = userService.selectTotalPage();
        System.out.println(totalPage);
        return "pageOk";
    }
    /**
     * 增
     */
    public String insertUser() {
        UserServiceImpl userService = new UserServiceImpl();
        //User属性: id,username,password,age,birthday;
        user.setId(null);
        userService.insertUser(user);
        return "insertOK";
    }
    /**
     * 删
     */
    public String deleteUser() {
        UserServiceImpl userService = new UserServiceImpl();
        userService.deleteUserById(user.getId());
        return "deleteOk";
    }
    /**
     * 更新
     */
    public String updateUser() {
        UserServiceImpl userService = new UserServiceImpl();
        userService.updateById(user);
        return "updateOk";
    }
    /**
     * 通过id查询用户
     */
    public String selectUserById() {
        UserServiceImpl userService = new UserServiceImpl();
        user = userService.selectById(user.getId());
        System.out.println(user);
        return "selectOK";
    }
    /**
     * 批量删除
     * @return
     */
    public String batchDelete() {
        UserServiceImpl userService = new UserServiceImpl();
        System.out.println(ids);
        userService.batchDelete(ids);
        return "batchDeleteOk";
    }
    public Integer getTotalPage() {
        return totalPage;
    }
    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }
    public Integer getPageNumber() {
        return pageNumber;
    }
    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }
    public User getUser() {
        return user;
    }
    public void setUser(User user) {
        this.user = user;
    }
    public List<User> getUsers() {
        return users;
    }
    public void setUsers(List<User> users) {
        this.users = users;
    }
    public List<Integer> getIds() {
        return ids;
    }
    public void setIds(List<Integer> ids) {
        this.ids = ids;
    }
}

(3)ValidationCodeAction:验证码功能

package com.tjcu.action;
/**
 *  用于生成验证码图片  不提供返回页面
 * @author 86151
 */
public class ValidationCodeAction implements Action {
  private static final long serialVersionUID = 5126616339795936447L;
  private ConfigurableCaptchaService configurableCaptchaService = null;
  private ColorFactory colorFactory = null;
  private RandomFontFactory fontFactory = null;
  private RandomWordFactory wordFactory = null;
  private TextRenderer textRenderer = null;
  public void init() throws ServletException {
    configurableCaptchaService = new ConfigurableCaptchaService();
    // 颜色创建工厂,使用一定范围内的随机色
    colorFactory = new RandomColorFactory();
    configurableCaptchaService.setColorFactory(colorFactory);
    // 随机字体生成器
    fontFactory = new RandomFontFactory();
    fontFactory.setMaxSize(32);
    fontFactory.setMinSize(28);
    configurableCaptchaService.setFontFactory(fontFactory);
    // 随机字符生成器,去除掉容易混淆的字母和数字,如o和0等
    wordFactory = new RandomWordFactory();
    wordFactory.setCharacters("abcdefghkmnpqstwxyz23456789");
    wordFactory.setMaxLength(5);
    wordFactory.setMinLength(4);
    configurableCaptchaService.setWordFactory(wordFactory);
    // 自定义验证码图片背景
    MyCustomBackgroundFactory backgroundFactory = new MyCustomBackgroundFactory();
    configurableCaptchaService.setBackgroundFactory(backgroundFactory);
    // 图片滤镜设置
    ConfigurableFilterFactory filterFactory = new ConfigurableFilterFactory();
    List<BufferedImageOp> filters = new ArrayList<BufferedImageOp>();
    WobbleImageOp wobbleImageOp = new WobbleImageOp();
    wobbleImageOp.setEdgeMode(AbstractImageOp.EDGE_MIRROR);
    wobbleImageOp.setxAmplitude(2.0);
    wobbleImageOp.setyAmplitude(1.0);
    filters.add(wobbleImageOp);
    filterFactory.setFilters(filters);
    configurableCaptchaService.setFilterFactory(filterFactory);
    // 文字渲染器设置
    textRenderer = new BestFitTextRenderer();
    textRenderer.setBottomMargin(3);
    textRenderer.setTopMargin(3);
    configurableCaptchaService.setTextRenderer(textRenderer);
    // 验证码图片的大小
    configurableCaptchaService.setWidth(82);
    configurableCaptchaService.setHeight(32);
  }
  @Override
  public String execute() throws Exception {
    init();
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setContentType("image/png");
    response.setHeader("cache", "no-cache");
    HttpSession session = request.getSession(true);
    OutputStream outputStream = response.getOutputStream();
    // 得到验证码对象,有验证码图片和验证码字符串
    Captcha captcha = configurableCaptchaService.getCaptcha();
    // 取得验证码字符串放入Session
    String validationCode = captcha.getChallenge();
    session.setAttribute("code", validationCode);
    // 取得验证码图片并输出
    BufferedImage bufferedImage = captcha.getImage();
    ImageIO.write(bufferedImage, "png", outputStream);
    outputStream.flush();
    outputStream.close();
    destroy();
    return null;
  }
  public void destroy() {
    wordFactory = null;
    colorFactory = null;
    fontFactory = null;
    textRenderer = null;
    configurableCaptchaService = null;
  }
  /**
   * 自定义验证码图片背景,主要画一些噪点和干扰线
   */
  private class MyCustomBackgroundFactory implements BackgroundFactory {
    private Random random = new Random();
    @Override
    public void fillBackground(BufferedImage image) {
      Graphics graphics = image.getGraphics();
      // 验证码图片的宽高
      int imgWidth = image.getWidth();
      int imgHeight = image.getHeight();
      // 填充为白色背景
      graphics.setColor(Color.WHITE);
      graphics.fillRect(0, 0, imgWidth, imgHeight);
      // 画100个噪点(颜色及位置随机)
      for (int i = 0; i < 100; i++) {
        // 随机颜色
        int rInt = random.nextInt(255);
        int gInt = random.nextInt(255);
        int bInt = random.nextInt(255);
        graphics.setColor(new Color(rInt, gInt, bInt));
        // 随机位置
        int xInt = random.nextInt(imgWidth - 3);
        int yInt = random.nextInt(imgHeight - 2);
        // 随机旋转角度
        int sAngleInt = random.nextInt(360);
        int eAngleInt = random.nextInt(360);
        // 随机大小
        int wInt = random.nextInt(6);
        int hInt = random.nextInt(6);
        graphics.fillArc(xInt, yInt, wInt, hInt, sAngleInt, eAngleInt);
        // 画5条干扰线
        if (i % 20 == 0) {
          int xInt2 = random.nextInt(imgWidth);
          int yInt2 = random.nextInt(imgHeight);
          graphics.drawLine(xInt, yInt, xInt2, yInt2);
        }
      }
    }
  }
}

5、util层

手动封装JDBCUtils工具类

package com.tjcu.utils;
import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;
/**
 * @author 王恒杰
 * @version 1.0
 * @date 2021/9/11 12:38
 * @email 1078993387@qq.com
 * @Address 天津
 * @Description:
 */
public class JdbcUtils {
    //    静态的Properties集合,相当于属性
    private static Properties p = new Properties();
    //    静态的ThreadLocal输性  线程绑定对象
    private static final ThreadLocal<Connection> t = new ThreadLocal();
    static {
        InputStream is = JdbcUtils.class.getResourceAsStream("/com/tjcu/jdbc.properties");
        try {
            p.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection() {
        //从ThreadLocal中获取Connection
        Connection conn = t.get();
        try {
            if (conn == null) {
                Class.forName(p.getProperty("driver"));
                conn = DriverManager.getConnection(p.getProperty("url"), p.getProperty("username"), p.getProperty("password"));
                t.set(conn);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return t.get();
    }
    public static void close(ResultSet rs, PreparedStatement pstm, Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (pstm != null) {
            try {
                pstm.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (conn != null) {
            try {
                conn.close();
                t.remove();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
    public static void close(ResultSet rs, PreparedStatement pstm) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (pstm != null) {
            try {
                pstm.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
    public static void close(PreparedStatement pstm, Connection conn) {
        if (pstm != null) {
            try {
                pstm.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (conn != null) {
            try {
                conn.close();
                //关闭链接后切记使用remove方法,移除ThreadLocal中已关闭的链接对象
                t.remove();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
    //关闭资源  用于关闭连接
    public static void close(Connection conn) {
        if (conn != null) {
            try {
                conn.close();
                //关闭链接后切记使用remove方法,移除ThreadLocal中已关闭的链接对象
                t.remove();
            } catch (Exception e) {
            }
        }
    }
}

6、config 配置文件:jdbc.properties

mysql-connector-java-8.0.16.jar之后com.mysql.cj.jdbc.Driver

driver=com.mysql.cj.jdbc.Driver
username=root
password=root
url=jdbc:mysql://localhost:3306/msc?useUnicode=true&characterEncoding=UTF-8  & useSSL=false & serverTimezone=Asia/Shanghai

源代码在githee仓库:

程序员小王Gitee: https://gitee.com/wanghengjie563135/EMS.git


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1天前
|
缓存 监控 NoSQL
使用Java实现分布式缓存系统
使用Java实现分布式缓存系统
|
1天前
|
存储 数据采集 搜索推荐
使用Java实现智能推荐系统的关键技术
使用Java实现智能推荐系统的关键技术
|
1天前
|
存储 缓存 NoSQL
使用Java构建高性能的分布式缓存系统
使用Java构建高性能的分布式缓存系统
|
1天前
|
消息中间件 Java 中间件
如何在Java项目中实现高效的消息队列系统
如何在Java项目中实现高效的消息队列系统
|
1天前
|
消息中间件 安全 Java
使用Java实现智能物流管理系统的关键技术
使用Java实现智能物流管理系统的关键技术
|
1天前
|
消息中间件 监控 Java
使用Java实现高性能消息队列系统
使用Java实现高性能消息队列系统
|
1天前
|
Java jenkins 持续交付
Jenkins是开源CI/CD工具,用于自动化Java项目构建、测试和部署。通过配置源码管理、构建触发器、执行Maven目标,实现代码提交即触发构建和测试
【7月更文挑战第1天】Jenkins是开源CI/CD工具,用于自动化Java项目构建、测试和部署。通过配置源码管理、构建触发器、执行Maven目标,实现代码提交即触发构建和测试。成功后,Jenkins执行部署任务,发布到服务器或云环境。使用Jenkins能提升效率,保证软件质量,加速上线,并需维护其稳定运行。
11 0
|
1天前
|
消息中间件 Java API
解析Java微服务架构:从零构建高性能系统
解析Java微服务架构:从零构建高性能系统
|
2天前
|
存储 监控 Java
使用Java实现实时数据处理系统
使用Java实现实时数据处理系统
|
2天前
|
消息中间件 存储 Java
深度探索:使用Apache Kafka构建高效Java消息队列处理系统
【6月更文挑战第30天】Apache Kafka是分布式消息系统,用于高吞吐量的发布订阅。在Java中,开发者使用Kafka的客户端库创建生产者和消费者。生产者发送序列化消息到主题,消费者通过订阅和跟踪偏移量消费消息。Kafka以持久化、容灾和顺序写入优化I/O。Java示例代码展示了如何创建并发送/接收消息。通过分区、消费者组和压缩等策略,Kafka在高并发场景下可被优化。
12 1