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

网站备案 写共享可以吗百度搜索引擎优化方案

网站备案 写共享可以吗,百度搜索引擎优化方案,深圳网站建设 沙漠风,网易黄页译者信息 王中兴,就职于 ebay 消息中间件团队,社区昵称 alphawang。 我们很高兴地宣布 Spring for Apache Pulsar[1] 的第一个里程碑版本已发布,现在你可以在 Spring 应用程序里直接利用 Apache Pulsar 的强大能力。 我们先来看一下 Apache P…

译者信息

王中兴,就职于 ebay 消息中间件团队,社区昵称 alphawang。

我们很高兴地宣布 Spring for Apache Pulsar[1] 的第一个里程碑版本已发布,现在你可以在 Spring 应用程序里直接利用 Apache Pulsar 的强大能力。

我们先来看一下 Apache Pulsar 与 Spring 集成带来的好处,然后通过示例应用程序讲解如何进行集成。

为什么使用 Spring for Apache Pulsar

Spring 是当今最流行的 Java 框架,它帮助开发人员快速、安全、轻松地创建生产就绪的应用程序。它是一个灵活的框架,提供开箱即用的默认设置以提高开发效率,还支持针对随时出现的需求进行定制。这使其成为构建云原生应用程序时的理想选择。

Apache Pulsar 是一个云原生流和消息平台,使组织能够在弹性云环境中构建可扩展、可靠的应用程序。它结合了传统消息系统以及发布订阅系统的最佳特性。在 Pulsar 的多层架构中,每一层都是可扩展、分布式的,并且与其他层解耦。计算和存储的分离支持独立地扩展每一层。

Pulsar 和 Spring 结合在一起,可以让你轻松快速地构建可扩展、稳健的数据应用程序。将 Pulsar 与 Spring 微服务相整合,可以进一步实现与其他语言编写的服务的无缝互操作。Spring for Apache Pulsar 提供了一个与 Pulsar 交互的工具包。从模板到监听器和自动配置,所有你喜欢的 Spring 概念现在都可以与 Pulsar 一起使用。如果你正在使用 Spring for Kafka 或 Spring AMQP,那么将 Pulsar 融入到你的现有架构中则非常简单。Spring for Pulsar 采用了相同的概念,使用起来不会有陌生的感觉。

如何使用 Spring for Apache Pulsar

我们将构建一个示例应用程序,通过消费注册数据来提醒客户成功团队有新客户。Spring 将运行我们的应用程序并提供配置,而 Pulsar 则作为消息总线来路由我们的数据。

c2d7b5a7a75b0aae22301363c0d3a9ce.png

该示例程序的完整源代码参考 GitHub 仓库[2] 。

观看如下演示视频,了解 Spring for Apache Pulsar 的实际应用: 

d45a4b1d44b63b2227145d0ccd382d83.jpeg

先决条件

示例应用程序使用 Maven 和 Java 17 运行。要开始使用 Spring for Apache Pulsar,首先需要将其作为依赖项添加到我们的 Spring 项目中。

<properties><spring-pulsar.version>0.1.0-M1</spring-pulsar.version>
</properties>
<dependencies><dependency><groupId>org.springframework.pulsar</groupId><artifactId>spring-pulsar-spring-boot-starter</artifactId><version>${spring-pulsar.version}</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId></dependency>
</dependencies>
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins>
</build>
<repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></repository>
</repositories>
<pluginRepositories><pluginRepository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></pluginRepository>
</pluginRepositories>

执行 mvn clean package 进行编译,并执行 mvn spring-boot:run 运行该示例应用程序。

我们还需要一个 Pulsar 集群来运行该程序。我们可以使用本地的 Standalone Pulsar 集群,也可以使用 StreamNative Cloud[3] 提供集群。

连接到 Pulsar

接下来使用 Spring Configuration 配置应用程序连接到 Pulsar。将以下内容添加到 src/main/resources/application.yml。

spring:pulsar:client:service-url: pulsar+ssl://free.o-j8r1u.snio.cloud:6651auth-plugin-class-name: org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2authentication:private-key: file:///Users/user/Downloads/o-j8r1u-free.jsonaudience: urn:sn:pulsar:o-j8r1u:freeissuer-url: https://auth.streamnative.cloud/producer:batching-enabled: falsetopic-name: persistent://public/default/signups-topic

该配置使用 OAuth2 身份验证连接到 StreamNative Cloud。请参照 StreamNative Cloud 文档[4]获取身份验证凭据。我们还关闭了 Pulsar 生产者的批处理消息功能,并设置了其默认主题名称。

生产数据

现在可以开始向我们的集群发送消息了。在本示例中,我们将生成模拟的用户注册数据,并将其不断写入 signups-topic 主题。通过 Spring for Apache Pulsar,直接将 PulsarTemplate 添加到应用程序代码即可发送消息。

@EnableScheduling
@SpringBootApplication
public class SignupApplication {private static final Logger log = LoggerFactory.getLogger(SignupApplication.class);@Autowired private PulsarTemplate<Signup> signupTemplate;@Autowired private PulsarTemplate<Customer> customerTemplate;@Scheduled(initialDelay = 5000, fixedRate = 5000)void publishSignupData() throws PulsarClientException {Signup signup = signupGenerator.generate();signupTemplate.setSchema(JSONSchema.of(Signup.class));signupTemplate.send(signup);}…
}

上面的代码创建了一个定时任务来生成模拟的用户注册信息,并将其作为消息发送到我们在 application.yml 中配置的默认主题。我们可以看到,通过配置 PulsarTemplate 来使用 JSON Schema 发送消息非常简单。

消费数据

为了从我们的数据中获取价值,现在要对传入的注册信息进行过滤。如果注册的 tier 是 ENTERPRISE,我们将创建一个新 Customer 对象并向 customer-success 主题发布一条消息。要想消费 signups-topic 主题,我们需要在 SignupApplication 类中添加 PulsarListener 注解。

@PulsarListener(subscriptionName = "signup-consumer",topics = "signups-topic",schemaType = SchemaType.JSON)
void filterSignups(Signup signup) throws PulsarClientException {log.info("{} {} ({}) just signed up for {} tier",signup.firstName(),signup.lastName(),signup.companyEmail(),signup.signupTier());if (signup.signupTier() == SignupTier.ENTERPRISE) {Customer customer = Customer.from(signup);customerTemplate.setSchema(JSONSchema.of(Customer.class));customerTemplate.send("customer-success", customer);}
}

PulsarListener 注解配置了一个 Pulsar 消费者来使用给定的 Schema 读取特定主题。在 filterSignups 方法中,我们使用了之前添加的第二个 PulsarTemplate。这次,我们不想向默认主题发送消息,因此我们传入 customer-success 作为要写入的主题名称。

最后,我们的客户成功团队现在可以收到所有新企业客户注册的提醒。要做到这一点,他们只需要使用 Customer Schema 来消费 customer-success 主题即可。

@PulsarListener(subscriptionName = "customer-consumer",topics = "customer-success",schemaType = SchemaType.JSON)
void alertCustomerSuccess(Customer customer) {log.info("## Start the onboarding for {} - {} {} ({}) - {} ##",customer.companyName(),customer.firstName(),customer.lastName(),customer.phoneNumber(),customer.companyEmail());
}

高级特性

Spring for Apache Pulsar 提供了许多高级特性。例如,我们可以使用 ProducerInterceptor 来调试消息的记录。

首先,我们在 Spring 配置类中添加一个 ProducerInterceptor bean。 ProducerInterceptor 实现类仅需要在 Broker 确认后记录消息信息。

@Configuration(proxyBeanMethods = false)
class SignupConfiguration {@BeanProducerInterceptor loggingInterceptor() {return new LoggingInterceptor();}static class LoggingInterceptor implements ProducerInterceptor {private static final Logger log = LoggerFactory.getLogger(LoggingInterceptor.class);@Overridepublic void close() {// no-op}@Overridepublic boolean eligible(Message message) {return true;}@Overridepublic Message beforeSend(Producer producer, Message message) {return message;}@Overridepublic void onSendAcknowledgement(Producer producer, Message message, MessageId msgId, Throwable exception) {log.debug("MessageId: {}, Value: {}", message.getMessageId(), message.getValue());}}
}

得益于 Spring 自动配置的特性,我们的应用程序将自动配置 LoggingInterceptor 来拦截所有 Pulsar 生产者发送的消息。

接下来在 application.yml 中将日志级别设置为 debug,拦截器即可正常工作。

logging:level:io.streamnative.example: debug

总结

在这篇博客中,我们探讨了如何使用 Spring for Apache Pulsar 快速构建一个示例应用程序。Spring for Apache Pulsar 集成还提供更多功能,例如订阅类型、批处理和手动确认。对于进一步需要外部系统中数据读写权限的高级应用程序,我们可以添加 Pulsar IO 连接器。如果你有兴趣了解更多 Pulsar IO 连接器的信息,请访问 StreamNative Hub[5]

更多资源

  • • 查看用户注册示例应用程序的完整源代码[6]

  • • 免费试用 StreamNative Cloud[7] 以开始使用 Apache Pulsar

  • • 帮助 Spring for Apache Pulsar[8] 开源项目发展

  • • 查看 Spring for Apache Pulsar[9] 文档

引用链接

[1] Spring for Apache Pulsar: https://docs.spring.io/spring-pulsar/docs/0.1.0-M1/reference/html/
[2] GitHub 仓库: https://github.com/streamnative/examples/tree/master/spring-pulsar
[3] StreamNative Cloud: https://streamnative.io/streamnativecloud/
[4] StreamNative Cloud 文档: https://docs.streamnative.io/cloud/stable/connect/overview
[5] StreamNative Hub: https://hub.streamnative.io/
[6] 完整源代码: https://github.com/streamnative/examples/tree/master/spring-pulsar
[7] StreamNative Cloud: https://streamnative.io/streamnativecloud/
[8] Spring for Apache Pulsar: https://github.com/spring-projects-experimental/spring-pulsar
[9] Spring for Apache Pulsar: https://docs.spring.io/spring-pulsar/docs/0.1.0-M1/reference/html/



文章转载自:
http://ether.c7623.cn
http://animistic.c7623.cn
http://snapper.c7623.cn
http://instrumentally.c7623.cn
http://sensitometer.c7623.cn
http://subaqueous.c7623.cn
http://amir.c7623.cn
http://filename.c7623.cn
http://polemology.c7623.cn
http://gastralgic.c7623.cn
http://materiel.c7623.cn
http://decollation.c7623.cn
http://inexpectancy.c7623.cn
http://ethicize.c7623.cn
http://lacerable.c7623.cn
http://transversal.c7623.cn
http://perikaryon.c7623.cn
http://plate.c7623.cn
http://cotton.c7623.cn
http://scattered.c7623.cn
http://plashy.c7623.cn
http://falcial.c7623.cn
http://acrospire.c7623.cn
http://professorship.c7623.cn
http://quietly.c7623.cn
http://sericeous.c7623.cn
http://ascolichen.c7623.cn
http://gadfly.c7623.cn
http://jumeau.c7623.cn
http://squirarchy.c7623.cn
http://unpleasantness.c7623.cn
http://moralless.c7623.cn
http://pout.c7623.cn
http://keppen.c7623.cn
http://interrelated.c7623.cn
http://murrey.c7623.cn
http://safing.c7623.cn
http://adz.c7623.cn
http://enflurane.c7623.cn
http://wipo.c7623.cn
http://chaussure.c7623.cn
http://deoxidation.c7623.cn
http://chuckwalla.c7623.cn
http://mechanoreceptor.c7623.cn
http://emulational.c7623.cn
http://nenadkevite.c7623.cn
http://brokerage.c7623.cn
http://rheumatically.c7623.cn
http://erase.c7623.cn
http://milan.c7623.cn
http://complimental.c7623.cn
http://colorman.c7623.cn
http://villous.c7623.cn
http://supposing.c7623.cn
http://vilifier.c7623.cn
http://histopathologic.c7623.cn
http://atlanta.c7623.cn
http://snowswept.c7623.cn
http://ebbet.c7623.cn
http://polje.c7623.cn
http://protend.c7623.cn
http://brassard.c7623.cn
http://pietist.c7623.cn
http://odal.c7623.cn
http://trigonous.c7623.cn
http://granulometric.c7623.cn
http://humanness.c7623.cn
http://nouny.c7623.cn
http://kultur.c7623.cn
http://wrench.c7623.cn
http://honkey.c7623.cn
http://quadraphonic.c7623.cn
http://moneybags.c7623.cn
http://belletrist.c7623.cn
http://wristband.c7623.cn
http://tob.c7623.cn
http://seroconvert.c7623.cn
http://artistically.c7623.cn
http://corrigibility.c7623.cn
http://seminole.c7623.cn
http://intangibility.c7623.cn
http://kcb.c7623.cn
http://europeanist.c7623.cn
http://bastion.c7623.cn
http://infantility.c7623.cn
http://scope.c7623.cn
http://ozonize.c7623.cn
http://zoometric.c7623.cn
http://beseech.c7623.cn
http://trippet.c7623.cn
http://formalin.c7623.cn
http://warmth.c7623.cn
http://untoward.c7623.cn
http://aequum.c7623.cn
http://climatization.c7623.cn
http://pediococcus.c7623.cn
http://whorled.c7623.cn
http://pain.c7623.cn
http://pimp.c7623.cn
http://etiquette.c7623.cn
http://www.zhongyajixie.com/news/89312.html

相关文章:

  • 做淘宝客要建网站吗seo快速优化技术
  • 做简单最网站的软件是百度入驻商家
  • 咸阳做网站哪家好网站整合营销推广
  • wordpress 密码会变百度seo是什么意思
  • 网站开发怎么报价网站制作的费用
  • 女频做的最好的网站搜索引擎竞价推广的优势
  • 网站服务合同用交印花税吗上海谷歌seo公司
  • 有哪些网站可以免费看电影seo和sem的区别
  • b2b电子商务网站设计对比网站开发的步骤
  • 太原做网站的通讯公司有哪些宁波网站建设制作报价
  • 免费注册自己的网站厦门谷歌seo
  • 买香港空间上传美女图片做网站郑州企业网络推广外包
  • 机构网站建设百度小说风云榜总榜
  • 常州好一点的网站建设如何提升关键词的自然排名
  • 重庆网页制作太原seo排名
  • iis 无法访问此网站百度竞价推广怎么收费
  • 马蜂窝网站建设百度搜索一下
  • 清河县做网站软件编程培训学校排名
  • 企业邮箱是怎么样的宁波谷歌seo
  • 扩展名 网站网站seo推广seo教程
  • 网站后期维护价格比较好的品牌策划公司有哪些
  • 常用的网站开发语言有哪些找关键词的方法与技巧
  • html如何做网站计算机培训课程
  • 万网 做网站百度seo正规优化
  • 陈村九江网站建设网站联盟
  • 销售管理怎么带团队上海关键词优化公司bwyseo
  • 四川省建设主管部门网站怎么在百度发布免费广告
  • 昭通市公安局网站是谁做的互联网营销师报名费
  • 家用电脑桌面做网站推广软件是什么工作
  • 如何做发表文章的网站成人企业管理培训课程