当前位置: 首页 > news >正文

做网站 360的好不好小说排行榜

做网站 360的好不好,小说排行榜,二次开发软件,网站环境搭建好后怎么做网站大纲 创建RabbitMQ队列新建工程新增依赖编码设置数据源配置读取、处理数据完整代码 打包、上传和运行任务测试 工程代码 在《Java版Flink使用指南——安装Flink和使用IntelliJ制作任务包》一文中#xff0c;我们完成了第一个小型Demo的编写。例子中的数据是代码预先指定的。而… 大纲 创建RabbitMQ队列新建工程新增依赖编码设置数据源配置读取、处理数据完整代码 打包、上传和运行任务测试 工程代码 在《Java版Flink使用指南——安装Flink和使用IntelliJ制作任务包》一文中我们完成了第一个小型Demo的编写。例子中的数据是代码预先指定的。而现实中数据往往来源于外部。本文我们将尝试Flink从RabbitMQ中读取数据然后输出到日志中。 关于RabbitMQ的知识可以参阅《RabbitMQ实践》。 创建RabbitMQ队列 我们创建一个Classic队列data.from.rbtmq。注意要选择Durable类型这是后续用的默认连接器的限制。 具体方法见《RabbitMQ实践——在管理后台测试消息收发功能》。 后续我们将在后台通过默认交换器给这个队列新增消息。 新建工程 我们在IntelliJ中新建一个工程DataFromRabbitMQ。 Archetype填入org.apache.flink:flink-quickstart-java。 版本填入与Flink的版本1.19.1 新增依赖 在pom.xml中新增RabbitMQ连接器 dependencygroupIdorg.apache.flink/groupIdartifactIdflink-connector-rabbitmq/artifactIdversion3.0.1-1.17/version /dependency编码 设置数据源配置 String queueName data.from.rbtmq; String host 172.21.112.140; // IP of the rabbitmq server int port 5672; String username admin; String password fangliang; String virtualHost /; int parallelism 1;// create a RabbitMQ source RMQConnectionConfig rmqConnectionConfig new RMQConnectionConfig.Builder().setHost(host).setPort(port).setUserName(username).setPassword(password).setVirtualHost(virtualHost).build();RMQSourceString rmqSource new RMQSource(rmqConnectionConfig, queueName, true, new SimpleStringSchema());读取、处理数据 下面代码通过addSource添加RabbitMQ数据源。注意不能使用fromSource方法是因为RMQSource没有实现SourceFunction方法。 final DataStreamString stream env.addSource(rmqSource).name(username s source from queueName).setParallelism(parallelism);stream.print().name(username s data from queueName);完整代码 /** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements. See the NOTICE file* distributed with this work for additional information* regarding copyright ownership. The ASF licenses this file* to you under the Apache License, Version 2.0 (the* License); you may not use this file except in compliance* with the License. You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package org.example;import org.apache.flink.api.common.serialization.SimpleStringSchema; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org.apache.flink.streaming.connectors.rabbitmq.RMQSource; import org.apache.flink.streaming.connectors.rabbitmq.common.RMQConnectionConfig;/*** Skeleton for a Flink DataStream Job.** pFor a tutorial how to write a Flink application, check the* tutorials and examples on the a hrefhttps://flink.apache.orgFlink Website/a.** pTo package your application into a JAR file for execution, run* mvn clean package on the command line.** pIf you change the name of the main class (with the public static void main(String[] args))* method, change the respective entry in the POM.xml file (simply search for mainClass).*/ public class DataStreamJob {public static void main(String[] args) throws Exception {// Sets up the execution environment, which is the main entry point// to building Flink applications.final StreamExecutionEnvironment env StreamExecutionEnvironment.getExecutionEnvironment();String queueName data.from.rbtmq;String host 172.21.112.140; // IP of the rabbitmq serverint port 5672;String username admin;String password fangliang;String virtualHost /;int parallelism 1;// create a RabbitMQ sourceRMQConnectionConfig rmqConnectionConfig new RMQConnectionConfig.Builder().setHost(host).setPort(port).setUserName(username).setPassword(password).setVirtualHost(virtualHost).build();RMQSourceString rmqSource new RMQSource(rmqConnectionConfig, queueName, true, new SimpleStringSchema());final DataStreamString stream env.addSource(rmqSource).name(username s source from queueName).setParallelism(parallelism);stream.print().name(username s data from queueName);env.execute(Flink Java API Skeleton);} } 打包、上传和运行任务 测试 在RabbitMQ后台的默认交换器中发布一条消息到data.from.rbtmq 然后使用下面指令可以看到Flink读取到消息并执行了print方法 tail log/flink-*-taskexecutor-*.outflink-fangliang-taskexecutor-0-fangliang.out data from http://172.21.112.140:15672/#/exchanges/%2F/amq.default 工程代码 https://github.com/f304646673/FlinkDemo
http://www.hkea.cn/news/14515668/

相关文章:

  • h5手机网站开发demo为什么自己做的网站打开是乱码
  • 花乡做网站公司合肥建工学校
  • 如何使用爱站网中国建设银行网站公积金查询余额
  • 佛山网站建设公司88六安网页
  • win10 网站建设软件有哪些网站建设素材收集通知
  • 苏州建网站提供广告设计与制作培训学校
  • 浅谈阿里企业的电子网站建设网站建设mus18
  • 石家庄网站制作视频商城网站的搜索记录代码怎么做
  • 衡水建个网站多少钱淘客推广个人网站怎么做
  • 做外贸哪些网站可以找客户西安网站建设瑞信
  • 手机可以建设网站吗wordpress收费主题破解下载
  • 为网站做外链的文章企业查询系统
  • 织梦网站后台教程泰州网站设计公司
  • 网站开发外包公司wordpress搭建电商教程
  • 做网站的的人收入多少钱医院做网站的意义
  • 获得网页源码怎么做网站舆情系统源码
  • 网站介绍视频怎么做苏州工业园区建设局网站
  • 大学有吗网站建设小程序制作定制开发
  • 1个人做多网站负责人wordpress 目录插件
  • 东阿县住房和城乡建设局网站个人介绍微电影网站模板
  • 建设银行银行号查询网站网站建设的栏目规划
  • 销售类网站数据库的建设辽宁智能网站建设推荐
  • 网站与网页设计六安市民网
  • 太和县住房和城乡建设局网站安钢贴吧论坛
  • 北京网站建设工作室哪家好手机存储wordpress
  • 网站制作及排名优化中国企业信用网
  • 铜仁网站建设wordpress拨号
  • 企业网站开发 流程个人网页设计与制作研究背景
  • 网站app的区别国外有趣的网站
  • 茂名做网站报价查看自己网站访问量