首页 > 编程知识 正文

中国芯片项目下马原因(消息队列中间件)

时间:2023-05-03 21:41:11 阅读:69149 作者:151

点击关注公众号,“http://www.Sina.com/http://www.Sina.com/http://www.Sina.com”

最近,这个Apache Pulsar消息中间件非常受欢迎,被称为新一代消息中间件。 今天,让我们看看它有多强大。

摘要Apache Pulsar是一个使用Apache Bookkeeper提供持久化的pub/sub消息传递平台,是从服务端到服务端的消息中间件。 最初由雅虎开发,2016年开源。 目前正在Apache基金会下孵化。 它具有以下特点:

区域间复制

多租户

零数据丢失

零修复时间

统一的队列和流模型

高可扩展性

吞吐量高

Pulsar Proxy

函数

体系结构Pulsar使用分层结构将存储机制与broker隔离。 该体系结构为Pulsar提供了以下好处:

独立扩展broker

独立扩展存储(Bookies ) ) ) ) ) ) ) ) )。

容易将Zookeeper、Broker and Bookies容器化

ZooKeeper提供群集配置和状态存储

在Pulsar集群中,一个或多个代理处理生产者传入的消息并平衡负载,为消费者分配消息,与Pulsar配置存储通信并处理各种协调任务,以及依赖于特定于集群的ZooKeeper集群任务等的book

由一个或多个bookie组成的BookKeeper群集处理消息的永久存储。

此群集特定的ZooKeeper群集处理Pulsar群集之间的协调任务。

有关Pulsar体系结构的详细信息,请参阅https://pulsar.Apache.org/docs/en/concepts-architecture-overview /

四种订阅模式Pulsar有四种订阅模式: exclusive、shared、failover和key_shared。 这些模式如下图所示。

详见https://pulsar.Apache.org/docs/en/concepts-messaging /

性能优于Kafka Pulsar的是性能,Pulsar的速度比Kafka快得多,Pulsar的速度比Kafka快了2.5倍,延迟减少了40%。

数据源:https://streaml.io/pdf/gigaom-benchmarking-streaming-platforms.pdf

注:比较是包含100字节消息的单个分区的一个主题,Pulsar每秒可以发送220,000条消息。

安装二进制版本Pulsar #下载官方二进制软件包[ root @ centos7~ ] # wget https://archive.Apache.org/dist/pulsar/pulsar-2 Apache-pache tarzxfapache-pulsar-2.8.0-wx dhm.tar.gz [根@ centos7~ ] # CD Apache-pulsar-2.8.0 [根ltotal 72 drwxr-xr-x3根根225 Jan 222020 wxdhmdrwxr-xr-X5根根4096 Jan 222020 confdrwxr-xr-x3根根132 jul 6113:000000000 t 16384 jul 611336047 lib- rw-r---1 root root 31639 Jan 222020 licensedrwxr-xr-x2 root root 6612 Jan 222020 notice-rw-r-- r [ root @ centos7~-p 808033608080--mount source=pulsar data,target=/pulsar/data--mount source=pulsar conf

 apachepulsar/pulsar:2.8.0  wxdhm/pulsar standalone

http协议访问使用8080端口,pulsar协议(Java、Python等客户端)访问使用6650端口。

官方提供的可视化工具 Pulsar Manager,可以对多个Pulsar进行可视化管理。https://pulsar.apache.org/docs/en/administration-pulsar-manager/

[root@centos7 ~]# docker pull apachepulsar/pulsar-manager:v0.2.0[root@centos7 ~]# docker run -it    -p 9527:9527 -p 7750:7750    -e SPRING_CONFIGURATION_FILE=/pulsar-manager/pulsar-manager/application.properties    apachepulsar/pulsar-manager:v0.2.0

设置管理员用户与密码

[root@centos7 ~]# CSRF_TOKEN=$(curl http://localhost:7750/pulsar-manager/csrf-token)curl   -H 'X-XSRF-TOKEN: $CSRF_TOKEN'   -H 'Cookie: XSRF-TOKEN=$CSRF_TOKEN;'   -H "Content-Type: application/json"   -X PUT http://localhost:7750/pulsar-manager/users/superuser   -d '{"name": "admin", "password": "admin123", "description": "test", "email": "mingongge@test.org"}'{"message":"Add super user success, please login"}

浏览器直接输入 http://server_ip:9527 登录如下

输入刚刚创建的用户与密码,配置管理的服务端

列表

Toptic列表

Toptic详细信息

客户端配置 Java客户端

下面是一个使用共享订阅的 Java 消费者配置示例:

import org.apache.pulsar.client.api.Consumer;import org.apache.pulsar.client.api.PulsarClient;import org.apache.pulsar.client.api.SubscriptionType;String SERVICE_URL = "pulsar://localhost:6650";String TOPIC = "persistent://public/default/mq-topic-1";String subscription = "sub-1";PulsarClient client = PulsarClient.builder()        .serviceUrl(SERVICE_URL)        .build();Consumer consumer = client.newConsumer()        .topic(TOPIC)        .subscriptionName(subscription)        .subscriptionType(SubscriptionType.Shared)        // If you'd like to restrict the receiver queue size        .receiverQueueSize(10)        .subscribe(); Python客户端

下面是一个使用共享订阅的 Python 消费者配置示例:

from pulsar import Client, ConsumerTypeSERVICE_URL = "pulsar://localhost:6650"TOPIC = "persistent://public/default/mq-topic-1"SUBSCRIPTION = "sub-1"client = Client(SERVICE_URL)consumer = client.subscribe(    TOPIC,    SUBSCRIPTION,    # If you'd like to restrict the receiver queue size    receiver_queue_size=10,    consumer_type=ConsumerType.Shared) C++ 客户端

下面是一个使用共享订阅的 C++ 消费者配置示例:

#include <pulsar/Client.h>std::string serviceUrl = "pulsar://localhost:6650";std::string topic = "persistent://public/defaultmq-topic-1";std::string subscription = "sub-1";Client client(serviceUrl);ConsumerConfiguration consumerConfig;consumerConfig.setConsumerType(ConsumerType.ConsumerShared);// If you'd like to restrict the receiver queue sizeconsumerConfig.setReceiverQueueSize(10);Consumer consumer;Result result = client.subscribe(topic, subscription, consumerConfig, consumer);

更多配置及操作指南,官方的文档写的都很清楚,官方文档:https://pulsar.apache.org/docs/

总结

Plusar 作为下一代分布式消息队列,拥有非常多吸引人的特性,也弥补了一些其他竞品的短板,例如地域复制、多租户、扩展性、读写隔离等等。

我的新书:《 Linux系统运维指南 》已出版

推荐阅读 点击标题可跳转

深圳最最最牛逼的 IT 公司全在这了!

南京最最最牛逼的 IT 公司全在这了

ClickHouse 这么牛逼吗?是的,简直开挂!

挺带劲!这款开源数据库迁移工具超牛逼

干掉 Swagger (丝袜哥),试试这个新工具!

再见!Eclipse

4 万字超强总结!Java 这些必备基础知识不可少

Docker 常用命令!还有谁不会?

Sharding-Jdbc 实现读写分离、分库分表

觉得文章不错,请大家随手点在看、转发支持!

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。