Apache Pekko Connectors 项目教程

Apache Pekko Connectors 项目教程

pekko-connectorsApache Pekko Connectors is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Apache Pekko.项目地址:https://gitcode.com/gh_mirrors/pe/pekko-connectors

1. 项目的目录结构及介绍

Apache Pekko Connectors 是一个基于 Reactive Streams 和 Apache Pekko 的反应式企业集成库,支持 Java 和 Scala。项目的目录结构如下:

pekko-connectors/
├── docs/
│   ├── src/
│   │   ├── main/
│   │   │   ├── paradox/
│   │   │   │   ├── docs/
│   │   │   │   │   ├── connectors/
│   │   │   │   │   ├── index.md
│   │   │   │   │   ├── overview.md
│   │   │   │   │   ├── release-notes.md
│   │   │   │   │   ├── contributing.md
│   ├── build.sbt
├── project/
│   ├── build.properties
│   ├── plugins.sbt
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   ├── org/
│   │   │   │   ├── apache/
│   │   │   │   │   ├── pekko/
│   │   │   │   │   │   ├── connectors/
│   │   ├── scala/
│   │   │   ├── org/
│   │   │   │   ├── apache/
│   │   │   │   │   ├── pekko/
│   │   │   │   │   │   ├── connectors/
├── build.sbt
├── LICENSE
├── README.md

目录结构介绍

  • docs/: 包含项目的文档源文件,使用 Paradox 文档生成工具。
  • project/: 包含项目的构建配置文件,如 build.propertiesplugins.sbt
  • src/: 包含项目的主要源代码,分为 Java 和 Scala 两个部分。
  • build.sbt: 项目的 SBT 构建文件。
  • LICENSE: 项目的许可证文件。
  • README.md: 项目的介绍和使用说明。

2. 项目的启动文件介绍

项目的启动文件通常位于 src/main/javasrc/main/scala 目录下,具体取决于你使用的是 Java 还是 Scala。以下是一个典型的启动文件示例:

Java 启动文件示例

package org.apache.pekko.connectors.example;

import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.stream.ActorMaterializer;
import org.apache.pekko.stream.Materializer;
import org.apache.pekko.stream.connectors.amqp.AmqpConnectionFactory;
import org.apache.pekko.stream.connectors.amqp.AmqpSink;
import org.apache.pekko.stream.connectors.amqp.AmqpSinkSettings;

public class Main {
    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("QuickStart");
        Materializer materializer = ActorMaterializer.create(system);

        AmqpConnectionFactory connectionFactory = new AmqpConnectionFactory();
        AmqpSinkSettings settings = AmqpSinkSettings.create(connectionFactory);
        AmqpSink<String> amqpSink = AmqpSink.create(settings);

        system.scheduler().scheduleOnce(
            Duration.ofSeconds(1),
            () -> {
                Source.single("Hello, world!").runWith(amqpSink, materializer);
            },
            system.dispatcher()
        );
    }
}

Scala 启动文件示例

package org.apache.pekko.connectors.example

import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.stream.ActorMaterializer
import org.apache.pekko.stream.connectors.amqp.{AmqpConnectionFactory, AmqpSink, AmqpSinkSettings}

object Main extends App {
  implicit val system = ActorSystem("QuickStart")
  implicit val materializer = ActorMaterializer()

  val connectionFactory = new AmqpConnectionFactory()
  val settings = AmqpSinkSettings(connectionFactory)
  val amqpSink = AmqpSink.create(settings)

  system.scheduler.scheduleOnce(
    1.second,

pekko-connectorsApache Pekko Connectors is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Apache Pekko.项目地址:https://gitcode.com/gh_mirrors/pe/pekko-connectors

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤璞亚Heath

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值