”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > 宣布推出新的 Conductor Java 客户端 v4

宣布推出新的 Conductor Java 客户端 v4

发布于2024-11-07
浏览:604

Announcing the New Conductor Java Client v4

By: Miguel Prieto


Earlier this year, Python SDK had a major facelift. Now other Conductor SDKs are undergoing significant rehaul, and we are thrilled to announce Java Client v4, featuring significant design enhancements, performance improvements, and optimized dependencies.

In our Java Client v4, we’ve reduced the dependency footprint by improving its design. We’ve added filters, events, and listeners to remove direct dependencies. This design decision was made after careful consideration to make the client easier to use, extend, and maintain.

Read on to learn more!


Why are we doing this?

We’ve heard your feedback and are working to improve the developer experience. Orkes and the Conductor OSS community were managing two separate Java client/SDK projects, both of which, like many in our industry, had accumulated some technical debt. We decided it was the right time to address this debt.

Some of the key things we wanted to address immediately were:

  1. One Conductor Java client (to rule them all)
    The goal was to consolidate the two existing projects into a unified, more manageable solution, taking the strongest elements from each. This should translate into faster updates, better support, and a more cohesive development experience.

  2. Dependency optimization
    As part of code cleanup, we’ve removed several dependencies:

    • Dependencies on backend code—The previous OSS Java client and SDK projects were part of the Conductor OSS repo and depended on conductor-commons. Although this kept the backend/client models in sync, it also meant some backend-related code and dependencies were leaking to the client.
    • Dependencies on deprecated artifacts.
    • Dependencies on stuff you won’t be needing.

    By removing hard-coded dependencies, users and contributors can extend the client without being locked into specific libraries or tools.

  3. More modularity
    We’ve restructured the project to increase modularity, making the client more flexible and easier to customize.

    With this modular approach, you can integrate your preferred monitoring, logging, or discovery tools through events, listeners, and filters. This not only simplifies customization but also makes the codebase more maintainable and future-proof, empowering developers to build and scale their own extensions as needed.

  4. Code cleanup/refactoring
    With a cleaner codebase, future development should be faster and less error-prone, making it easier for community contributions as well.

  5. Better examples
    We've introduced a module within the project specifically for examples. While it's still a work in progress, this module will serve as a central resource for practical, real-world examples whether you're getting started or looking for advanced use cases.

Home, sweet home

Official Conductor Client and SDKs are currently housed in https://github.com/conductor-sdk, with the exception of the OSS Java Client/SDK, which is part of the Conductor OSS repo https://github.com/orkes-io/orkes-conductor-client/tree/main.

Going forward, all Conductor Clients and SDKs will eventually be housed in the same conductor-clients directory in the conductor-oss/conductor repo. Head there to find the source code for the Java Client/SDK v4.

What’s new in Java Client v4?

1. Optimized dependencies

Java Client v4 introduces a more streamlined and efficient dependency set compared to the two projects it replaces.

We’ve removed all unused, deprecated, and unnecessary dependencies, significantly reducing classpath pollution. This optimization not only minimizes the risk of conflicts between libraries but should also improve overall performance and maintainability. By simplifying the dependency tree, v4 provides a cleaner and more lightweight client that is easier to work with and integrates more smoothly into your projects.

2. New TaskRunner

TaskRunner has been refactored. It replaces TaskPollExecutor, since both share the same core responsibility: managing the thread pool that workers use for polling, executing, and updating tasks.

With that, we've removed direct dependencies on Netflix Eureka and Spectator, introduced event-driven mechanisms, and added a PollFilter—a callback that determines whether polling should occur. Additionally, error handling and concurrency management have been improved.

If you’re using Eureka and Spectator, no need to worry—events and filters are provided for seamless integration with these great tools and libraries.

3. Extensibility using events, listeners, and filters

Java Client v4 introduces enhanced extensibility through events, listeners, and filters. These can be used for various purposes, including metrics tracking, logging, auditing, and triggering custom actions based on specific conditions.

For example, you can use a Lambda Function as a PollFilter to check the instance status as reported by Eureka. If the instance is marked as UP—meaning Eureka considers it healthy and available—the worker will proceed to poll for tasks.

Additionally, a listener can be registered to handle PollCompleted events. In this scenario, the listener logs event details and uses Prometheus to track the duration of the polling process, attaching the task type as a label for detailed metrics tracking. This approach not only adds flexibility but also improves observability and control over the client's behavior.

var runnerConfigurer = new TaskRunnerConfigurer
        .Builder(taskClient, List.of(new HelloWorldWorker()))
        .withThreadCount(10)
        .withPollFilter((String taskType, String domain) -> {
            return eurekaClient.getInstanceRemoteStatus().equals(InstanceStatus.UP);
        })
        .withListener(PollCompleted.class, (e) -> {
            log.info("Poll Completed {}", e);
            var timer = prometheusRegistry.timer("poll_completed", "type", e.getTaskType());
            timer.record(e.getDuration());
        })
        .build();

runnerConfigurer.init();

The client also has some specialized interfaces like MetricsCollector, which is built on top of these events and listeners. We’ll be providing concrete implementations of Metrics Collectors soon.

4. OkHttp3 v4 — the right amount of features OOTB

OkHttp3 v4 is one of the most popular and well-regarded HTTP clients for Java. By upgrading to it, our Java Client/SDK v4 now supports HTTP2 and Gzip out-of-the-box, allowing you to make swifter HTTP requests or data transfers. While there are other excellent options, OkHTTP was chosen for its simplicity, performance, and reliability.

With the OkHttp upgrade, we also decided to remove one abstraction layer, Jersey. Jersey is more feature-rich but also more heavyweight compared to a simple HTTP client like OkHttp. Some of these features (such as dependency injection, filters, and exception mappers) can be overkill if you just want to make basic HTTP requests.

5. Ease of migration from OSS to Orkes

The client promotes seamless integration between OSS Conductor and Orkes Conductor, empowering users with the flexibility to switch as their needs evolve, while maintaining support for the open-source community first.

The Orkes Client module simply extends the Conductor Client by adding authentication through a HeaderSupplier.

For OSS users who have created workers with Client v4 but want to give Orkes Conductor a shot, they just need to add the orkes-conductor-client dependency to their project and instantiate the client with OrkesAuthentication as a Header Supplier. Switching back to OSS is as simple as removing that Header Supplier.

var client = ConductorClient.builder()
                .basePath(BASE_PATH)
                .addHeaderSupplier(new OrkesAuthentication(KEY, SECRET))
                .build();
return new TaskClient(client); // Use this TaskClient with TaskRunner to initialize workers

Find out the 6 differences between Conductor OSS and Orkes Conductor.

6. Improved examples and documentation

We’ve started consolidating examples into a dedicated module, with improvements that cover key areas like authorization, managing workflow and task definitions, scheduling workflows, and more. While this module is still a work in progress, we’ll continuously add and refine examples to provide better guidance and cover real-world use cases.

Our goal is to enable developers to use our Client/SDK effectively and explore best practices as the module evolves.

Getting started with Java Client v4

Here’s how you can get started using Java Client v4:

Step 1: Spin up Conductor

Use Conductor OSS or Orkes Conductor:

  • Conductor OSS—Run it from source or use Docker.
  • Orkes Conductor—Try out Orkes Playground or sign up for a free trial.

Step 2: Add conductor-client dependency to your project

For Gradle-based projects:

implementation 'org.conductoross:conductor-client:4.0.0'
implementation 'io.orkes:orkes-conductor-client:4.0.0' // required if using Orkes Conductor

For Maven-based projects:

org.conductorossconductor-client4.0.0io.orkesorkes-conductor-client4.0.0
版本声明 本文转载于:https://dev.to/orkes/announcing-the-new-conductor-java-client-v4-4p4e?1如有侵犯,请联系[email protected]删除
最新教程 更多>
  • 如何在 PHP 中组合两个关联数组,同时保留唯一 ID 并处理重复名称?
    如何在 PHP 中组合两个关联数组,同时保留唯一 ID 并处理重复名称?
    在 PHP 中组合关联数组在 PHP 中,将两个关联数组组合成一个数组是一项常见任务。考虑以下请求:问题描述:提供的代码定义了两个关联数组,$array1 和 $array2。目标是创建一个新数组 $array3,它合并两个数组中的所有键值对。 此外,提供的数组具有唯一的 ID,而名称可能重合。要求...
    编程 发布于2024-11-20
  • 如何使用 C++ ifstream 从具有不同整数计数的文本文件中高效读取整数?
    如何使用 C++ ifstream 从具有不同整数计数的文本文件中高效读取整数?
    使用 C ifstream 从文本文件读取整数在以下情况下从文本文件检索图邻接信息并将其存储到向量中会带来挑战处理可变整数计数的行。这是使用 C 的 ifstream 的综合解决方案:传统方法包括使用 getline() 读取每一行并使用输入字符串流来解析该行。此技术对于整数数量一致的行非常有效。#...
    编程 发布于2024-11-20
  • Bootstrap 4 Beta 中的列偏移发生了什么?
    Bootstrap 4 Beta 中的列偏移发生了什么?
    Bootstrap 4 Beta:列偏移的删除和恢复Bootstrap 4 在其 Beta 1 版本中引入了重大更改柱子偏移了。然而,随着 Beta 2 的后续发布,这些变化已经逆转。从 offset-md-* 到 ml-auto在 Bootstrap 4 Beta 1 中, offset-md-*...
    编程 发布于2024-11-20
  • 除了“if”语句之外:还有什么地方可以在不进行强制转换的情况下使用具有显式“bool”转换的类型?
    除了“if”语句之外:还有什么地方可以在不进行强制转换的情况下使用具有显式“bool”转换的类型?
    无需强制转换即可上下文转换为 bool您的类定义了对 bool 的显式转换,使您能够在条件语句中直接使用其实例“t”。然而,这种显式转换提出了一个问题:“t”在哪里可以在不进行强制转换的情况下用作 bool?上下文转换场景C 标准指定了四种值可以根据上下文转换为 bool 的主要场景:语句:if、w...
    编程 发布于2024-11-20
  • 如何修复 macOS 上 Django 中的“配置不正确:加载 MySQLdb 模块时出错”?
    如何修复 macOS 上 Django 中的“配置不正确:加载 MySQLdb 模块时出错”?
    MySQL配置不正确:相对路径的问题在Django中运行python manage.py runserver时,可能会遇到以下错误:ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Python/2.7/site-...
    编程 发布于2024-11-20
  • 如何使用 MySQL 查找今天生日的用户?
    如何使用 MySQL 查找今天生日的用户?
    如何使用 MySQL 识别今天生日的用户使用 MySQL 确定今天是否是用户的生日涉及查找生日匹配的所有行今天的日期。这可以通过一个简单的 MySQL 查询来实现,该查询将存储为 UNIX 时间戳的生日与今天的日期进行比较。以下 SQL 查询将获取今天有生日的所有用户: FROM USERS ...
    编程 发布于2024-11-20
  • 为什么 Goroutine 在 Windows 上有时会执行失败?
    为什么 Goroutine 在 Windows 上有时会执行失败?
    理解 Windows 上非功能性 Goroutines 之谜在并发领域,Goroutines 在 Go 中充当轻量级线程。然而,一些程序员遇到了意想不到的挑战:goroutines 无法在 Windows 上执行。为了解开这个谜团,让我们深入研究一下根本问题。根本原因:异步执行与传统线程不同,gor...
    编程 发布于2024-11-20
  • 大批
    大批
    方法是可以在对象上调用的 fns 数组是对象,因此它们在 JS 中也有方法。 slice(begin):将数组的一部分提取到新数组中,而不改变原始数组。 let arr = ['a','b','c','d','e']; // Usecase: Extract till index p...
    编程 发布于2024-11-20
  • 尽管代码有效,为什么 POST 请求无法捕获 PHP 中的输入?
    尽管代码有效,为什么 POST 请求无法捕获 PHP 中的输入?
    解决 PHP 中的 POST 请求故障在提供的代码片段中:action=''而不是:action="<?php echo $_SERVER['PHP_SELF'];?>";?>"检查 $_POST数组:表单提交后使用 var_dump 检查 $_POST 数...
    编程 发布于2024-11-19
  • 如何使用 PHP 高效地将大型 MySQL 文件导入共享主机?
    如何使用 PHP 高效地将大型 MySQL 文件导入共享主机?
    PHP 中高效的 MySQL 文件导入:共享主机的拆分查询在 Web 开发领域,通常需要在使用共享主机提供商时导入大型数据库文件出现。不幸的是,通过命令行访问 MySQL 可能会受到限制,因此需要一个基于 PHP 的解决方案来解析和执行查询。为了解决这一挑战,开发了一个名为 SplitSQL() 的...
    编程 发布于2024-11-19
  • 可以仅使用 CSS 将图像大小调整为其大小的百分比吗?
    可以仅使用 CSS 将图像大小调整为其大小的百分比吗?
    仅使用 CSS 将图像大小调整为自身的百分比在网页设计领域,需要将图像大小调整为特定尺寸经常出现。一种场景涉及将图像的大小减小到其原始大小的一定百分比,而不改变其容器元素的大小。虽然 JavaScript 或服务器端脚本提供了解决方案,但本文探讨了潜在的纯 CSS 替代方案。是否可以使用 CSS 百...
    编程 发布于2024-11-19
  • 何时为 JavaScript 继承选择 Object.create 而不是 new?
    何时为 JavaScript 继承选择 Object.create 而不是 new?
    JavaScript 继承:Object.create 与 newJavaScript 中的继承概念可能会令人困惑,因为有多种实现方法它。本文旨在阐明最受接受的方法,并为您的特定场景提供解决方案。理解 Object.create 和 newObject.create 是一个创建对象的方法通过从现有对...
    编程 发布于2024-11-19
  • Bootstrap 网格类(如 col-md-4、col-xs-1 和 col-lg-2)中的数字如何确定元素宽度和响应能力?
    Bootstrap 网格类(如 col-md-4、col-xs-1 和 col-lg-2)中的数字如何确定元素宽度和响应能力?
    理解 Bootstrap 网格类中的数字:col-md-4、col-xs-1、col-lg-2The Bootstrap 框架引入了强大的网格系统,有助于创建响应式布局。该系统的组成部分是具有 col-* 格式的类,其中星号代表数字。这些数字在确定网格内的元素如何对齐以及它们如何响应不同的屏幕尺寸方...
    编程 发布于2024-11-19
  • 如何确定 C++ 编译器是否符合 IEEE 754 浮点标准?
    如何确定 C++ 编译器是否符合 IEEE 754 浮点标准?
    检查 C 中的 IEEE 754 浮点标准 确定 C 编译器是否遵循 IEEE 754 浮点标准通常通过以下方式完成编译器定义。然而,用于 C 的技术可能并不直接适用于 C 。C 特定方法幸运的是,C 提供了一种简单的方法来使用 numeric_limits 完成此检查class:std::nume...
    编程 发布于2024-11-19
  • 如何使用 SHA-256 在 Java 中实现安全字符串哈希?
    如何使用 SHA-256 在 Java 中实现安全字符串哈希?
    使用 SHA-256 的 Java 哈希字符串在 Java 中使用 SHA-256 哈希字符串可能看起来是一个简单的任务,但是有散列和编码之间的关键区别需要澄清。SHA-256(安全散列算法-256)是不是编码机制;它是一种单向哈希函数。这意味着当您对字符串进行哈希处理时,您会生成不可逆的二进制数据...
    编程 发布于2024-11-19

免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

Copyright© 2022 湘ICP备2022001581号-3