Article
|
5
 minutes
Overcoming the Homelessness Problem in Tech Partnerships
Video
|
50
 minutes
Nearbound Podcast #072: F*ck the Funnel - The Beginning of the End, with Allan Adler
eBook
Email Service Providers
Article
|
3
 minutes
Why is GoToEcosystem Necessary for B2B SaaS, Part II
Article
|
6
 minutes
Every Stat We Have That Proves The Value Of Partnerships
Article
|
4
 minutes
Why is GoToEcosystem Necessary for B2B SaaS?
Article
|
10
 minutes
How Box Uses Reveal Everyday to Power Their Nearbound GTM
Video
|
45
 minutes
Nearbound Podcast #070: Xero to Hero — Building a World-Class Platform Ecosystem
Article
|
15
 minutes
Partnerships 101: Sandboxes (And Why You Should Consider Building One)
Article
|
2
 minutes
Strategic partnerships create competitive advantages and accelerate growth
Article
|
1
 minutes
Howdy Partners #9: Tiering Your Partnership Programs
Article
|
1
 minutes
Size Isn't Everything: How Small Programs Win Big Partners
Article
|
15
 minutes
Everything You Should Know About Launching a Startup Partner Program
Video
|
60
 minutes
Nearbound Podcast #122: Category Design and Trust
Article
|
6
 minutes
The Era of Second-Party Data is Here. Are You Ready?
Video
|
57
 minutes
Nearbound Podcast #067: Be a Gardener, not a Builder - Platforms, Ecosystems, and Complexity
Article
|
3
 minutes
Your Vision, Mission and Core Values Are Foundational to a Successful Partnership Organization
Article
|
3
 minutes
The Relationship-First Engagement Model, Part II
Article
|
8
 minutes
Get Your Sales Team Excited About Co-Selling With a 50% Faster Time to Close
Video
|
48
 minutes
Nearbound Podcast #066: What Complex B2B Marketing Can Learn from Simple B2C Partnerships
Article
|
8
 minutes
The Community Mindset: How Building a Customer Community Empowers Partnerships
Video
|
2
 minutes
Crossbeam Explains: The Three Partnership Types
Article
|
5
 minutes
What Symbiotic Relationships In Nature Teach Us About Partnerships
Article
|
7
 minutes
Two Ways Partner Data Can Inform Your Product Strategy and Improve Retention
Article
|
4
 minutes
Partnership Manager or Master Politician?
Article
|
2
 minutes
Nearbound Weekend 07/02: Driving the bus
Video
|
39
 minutes
Everything You Didn't Know You Could Do With Partner Data
Article
|
1
 minutes
Nearbound Daily #005: Dear reader
Article
|
13
 minutes
A Hiring Manager’s Guide to Partnerships Roles and Job Titles
Article
|
5
 minutes
How VC Firms Are Using Crossbeam to Grow Their Portfolio Companies at Scale
Article
|
9
 minutes
Six Partnerships Team Org Charts (So You Can Plan Ahead for Your Team’s Growth)
Video
|
4
 minutes
How to Source and Convert Pipeline in HubSpot | Connector Summit 2022
Article
|
8
 minutes
Confessions of a GSI: Here's What GSIs Look for in an ISV Partner
Article
|
8
 minutes
Confessions of an ISV: How to Be a Good Channel Partner
Article
|
3
 minutes
Sales Leadership and Partner Enablement: Part 3
Article
|
15
 minutes
The Partner Tiers Cheat Sheet: Benefits, Drawbacks, and Checklists
Article
|
5
 minutes
Reflections on 'The Age of Connected Work'
Article
|
1
 minutes
Is ELG Right For Me? Find Out With the ELG Readiness Matrix
Article
|
4
 minutes
Sales Leadership and Partner Enablement: Part 1
Article
|
2
 minutes
The growing importance of partner attach across the buying cycle
Video
|
3
 minutes
Getting Primed for Account Mapping with Partners in Crossbeam | Connector Summit 2022
Video
|
3
 minutes
Crossbeam Product Drop Webinar: New Features Worth Buzzing About
Article
|
4
 minutes
How to Become the Beyoncé of Your Ecosystem
Video
|
51
 minutes
Nearbound Podcast #057: What Your Agency Partners Won't Tell You
Article
|
8
 minutes
How to be a customer-obsessed partner manager
Article
|
11
 minutes
Six Tips for Strengthening the Bond Between Your CSMs and Partners
Article
|
1
 minutes
SAS Gets IPO Ready via Partnerships
Video
|
45
 minutes
Nearbound Podcast #055: The Partner Manager Playbook — Managing the Front Lines
Article
|
7
 minutes
Partnerships 101: What Is Partner Marketing
Video
|
45
 minutes
Partnership Secrets: Enable Sales Teams and Hit Revenue Goals
Article
|
6
 minutes
SaaS Reseller Partnerships: What they Are & How They Work
Article
|
26
 minutes
Partnerships 101: ISVs, VARs, SIs, MSPs, and the Glue that Holds them Together
Article
|
7
 minutes
Partnerships 101: What is Cross-Selling?
Article
|
7
 minutes
Partnerships 101: Strategic Alliances Explained (Finally!) Plus Examples
Article
|
8
 minutes
Don’t Fall Behind: Get Your Partner Data in Your Data Warehouse (Part 1 of 2)
Article
|
3
 minutes
What Partner Ecosystem Maturity is and Why it Matters
Article
|
10
 minutes
The nearbound.com manifesto: Trust is the new data
Article
|
6
 minutes
How RingCentral Built an Internal Culture of Partnerships
Article
|
11
 minutes
It’s Happening! Crossbeam and Reveal are Joining Forces to Disrupt Go-to-Market Strategy as We Know It.
Article
|
6
 minutes
Just Because It’s Partnership Tech Doesn’t Mean It’s a PRM
Article
|
14
 minutes
The Beginner’s Guide to SaaS Tech Partnerships
Article
|
16
 minutes
Everything You Ever Wanted to Know About Channel Partnerships
Video
|
53
 minutes
Nearbound Podcast #051: Day Zero Mentality - How Rob Brewster Went from Partner Chief to Company Chief
Article
|
8
 minutes
Navigating Partnership Ecosystems: Channel, Tech, and Strategic
Article
|
20
 minutes
Partnerships 101: What Is a System Integrator (SI), and Should You Partner With One?
Article
|
7
 minutes
How to Build Your Agency Partner’s Reputation While Protecting Your Own
eBook
2022 State of the Partner Ecosystem Report
Video
|
38
 minutes
Nearbound Podcast #048: The Fear & Greed Index - Right Now Every Partner Pro Needs to Stand Tall
Article
|
25
 minutes
25 Articles Showing the Business Impact of Partnerships (Bring These to Your CEO)
Article
|
5
 minutes
The Case for a Co-Marketing-First Approach
Article
|
12
 minutes
Growing Your Partnerships Team? Here are 3 Skills You Should Look for in Your New Hires
Article
|
23
 minutes
Does Partnerships Have a Boredom Problem?
Article
|
10
 minutes
A 5-Step Guide for Scoping and Qualifying Your First Tech Partners
Video
|
43
 minutes
Secrets to Building a High-Impact Partner Program
Article
|
46
 minutes
How to Ensure Accurate Ecosystem Data
Article
|
7
 minutes
A recommended ecosystem AI strategy: Take an integrated rather than a top-down approach
Article
|
1
 minutes
A Primer: 3 Things to Lookout for as a Partnership Leader
Article
|
17
 minutes
Your Guide to Preparing for Your Next Partner Pitch Meeting
Article
|
4
 minutes
How to Launch a Strategic Partner Program (And Not Take Forever to Deliver Value)
Article
|
6
 minutes
How to Guide: Partnership Alignment with Internal Stakeholders
Article
|
45
 minutes
How to measure and attribute nearbound impact
Article
|
5
 minutes
Balancing AI, automation, and the human touch in partner management in 2024
Article
|
12
 minutes
Tech Ecosystem Maturity: Scaling Your Integration Program Via Your API
Video
|
18
 minutes
The Inside Track: How to Accelerate Crossbeam Onboarding for Your Partners
Article
|
5
 minutes
Tech Ecosystem Maturity: 4 Ways Most Partner Programs Fall Short
Article
|
8
 minutes
You Have Dormant Partners. Here’s How to Get Their Interest
Article
|
4
 minutes
How to nail co-marketing events in 2024 with nearbound
Video
|
12
 minutes
How to Gain Internal Buy-in to Build New Integrations | Connector Summit 2022
Article
|
3
 minutes
Track Churn and You’re 3.6x More Likely to Have Dedicated Budget for Integrations
Video
|
54
 minutes
The State of the Partner Ecosystem 2022 Webinar
Video
|
3
 minutes
Crossbeam Explains: What are System Integrators?
Article
|
9
 minutes
The Awkward Dance: Should You or Your Partner Build the Integration?
Article
|
16
 minutes
Building the Flywheel Starts with Your Partners
Article
|
2
 minutes
Remote, In-Office, or Hybrid? Where Partnership Professionals Worked in 2021
Article
|
8
 minutes
Four Signs it’s Time to Expand Your API Docs
Article
|
9
 minutes
7 Tips for Co-Selling Like a Supernode
Video
|
48
 minutes
Nearbound Podcast #039: Dancing with Elephants — The Art of Strategic Partnering
Article
|
8
 minutes
Tech Ecosystem Maturity: How to Level Up Your Co-Marketing Motions
Article
|
14
 minutes
20+ Interview Questions for Hiring Your First Tech Partner Manager
Article
|
7
 minutes
3 Reasons to Get Certified in Your Partners’ Tech and Become Indispensable to Your Team
Ecosystem Operations and Alignment
Turning Clojure Code into Temporal Gold: Crossbeam’s Data Pipeline Transformation
by
Bailey Kremiller-Kocin
SHARE THIS

Discover how Crossbeam’s engineering team transformed their data pipelines by integrating Temporal with Clojure. In this article, Bailey Kremiller-Kocin shares their step-by-step journey to optimize data orchestration, reduce duplication, and boost efficiency using Temporal’s powerful workflow capabilities.

by
Bailey Kremiller-Kocin
SHARE THIS

In this article

Join the movement

Subscribe to ELG Insider to get the latest content delivered to your inbox weekly.

Crossbeam recently migrated its data pipelines to Temporal, a powerful data pipeline orchestration tool. As a Clojure shop — a robust, practical, and fast programming language — we were looking for a tool that would integrate seamlessly with our existing codebase. Temporal provides our engineering team with in-code abstractions and granular control over our data pipelines. Additionally, the Clojure community is actively developing a Temporal Clojure Software Development Kit (SDK), wrapping the Temporal Java SDK.

The migration process had its challenges, but with support from the Clojure community and thorough testing, it was manageable. We’ve been running Temporal in production for a while now with minimal issues.

A Temporal survival guide

At its core, Temporal is all about executing units of work. 

In Temporal, a unit of work is defined against a Temporal service using gRPC — a cross-platform, high-performance Remote Procedure Call framework — which schedules the unit of work on a Temporal worker. Temporal workers operate within a worker pool, similar to Kubernetes pods.

Here’s a breakdown of how Temporal handles a unit of work:

  1. A Temporal client schedules the work against the Temporal platform.
  2. The Temporal platform uses its state machine/history to create a new unit of work on a worker.
  3. The worker executes that unit of work against the application code.
  4. The results are reported back to the Temporal platform.

Temporal defines several key terms (learn more about Temporal here):

  • Activity: The smallest unit of work. It includes business logic that is idempotent (i.e., it can be safely retried) and always produces the same result with the same input.
  • Synchronous Activity: Runs until it is completed and blocks subsequent activities.
  • Asynchronous Activity: Returns immediately and allows other work to run concurrently.
  • Workflow: Encapsulates multiple activities into a single construct. This is the main unit of work that starts against Temporal.

To learn about how we transformed Crossbeam’s data pipeline, this article takes you through our journey in six key steps using Temporal:

  1. Migrating our data pipelines
  2. Refining the migration process
  3. Scheduling with precision
  4. Streamlining pipeline releases
  5. Configuring efficient gRPC payloads
  6. Batching activities for optimized performance

Let’s dive in!

Step 01: Migrating the data pipelines

It is easy to represent an existing data pipeline as a set of activities within a workflow, which means migrating to Temporal starts with a Workflow.

The Clojure SDK defines Workflows with macros (a command or a batch of commands executed by single action), since the code definitions are just functions. At Crossbeam, our existing data pipeline was a series of functions, so our migration to the Temporal abstraction involved refactoring those functions into workflows.

Here is a generalized example of how our code looked after it was refactored into a Workflow.

We import the macros `defworkflow` and `defactivity` to get started. We then define the activity `take-customer-money` and the workflow `checkout` to call the activity. We are assuming that the input to the workflow itself is a map that defines a transaction.

Since Clojure is such a functional language, migrating to Temporal was pretty easy!

Step 02: Reiterating on the migration

Naturally, during the migration process we ran into every software developer’s worst enemy….code duplication.

Our workflows (data pipelines) consisted of a lot of activities. We started to build up lots of duplication in logging, tracking, and option passing.

We decided to use Clojure macros to reduce the duplicated code, the same tool the Clojure SDK used to expose Temporal abstractions.

First, we defined a function to wrap every workflow and activity with logging and Datadog tracing. The function `with-tracking` simply wraps the function body in a full log context and Datadog span, which is useful when reporting workflow or activity errors.

The `defactivity-with-tracking` macro added a couple of things to the existing Temporal Clojure SDK definitions. We had to generate our own arguments and then bind them to the actual params (it’s a keyword that enables developers to pass in a variable number of values at once, making code more flexible and efficient) of the macro. We did this to extract some more context from the parameters, and it was a neat introduction to more complex macro semantics. Also, the macro did not accept a doc string so we generated our own and added it to the name (symbol) of the `defactivity` as well.

By using macros we reduced the boilerplate code needed to bootstrap an activity definition and workflow definition, saving us a ton of time.

Step 03: Scheduling the data pipelines

Transitioning to Temporal required the use of schedules for our cron (a string comprising 6 or 7 fields separated by white space) jobs. Since the Temporal Clojure SDK didn’t support schedules before our migration, we implemented them ourselves by wrapping the Java SDK.

You can see our implementation here, which we’ve contributed back to the open source library.

While the implementation was uneventful (which is a great thing) we did run into one tricky area. Updating a schedule in temporal requires a function as an argument, specifically a function that implements the Java ‘Functional Interface’.

Clojure functions implement an interface called `IFn` and that is not a `Functional Interface` nor does it implement one, so as Clojure developers, we were surprised when a normal function argument didn’t work!

We solved this by using Clojure’s `reify`* to create an on the fly functional interface that wrapped a Clojure object, as shown here:


The `Functions$Func2` interface is pulled straight from Temporal. While not intuitive at first, the schedule update argument worked just fine after it was passed a Java object.

*Clojure’s reify: It creates an object implementing a protocol or interface — reify is a macro. 

Step 04: Releasing our data pipelines

Once we were using Temporal live in production, we needed to ensure our long running data pipelines ran to completion or failed gracefully.

Soon after releasing a stable version of our data ingestion pipeline to production, we noticed some of our activities would keep execution slots busy and the workers would not pick up any more work. For a few clients in the 95th percentile of execution times, some steps were hours long.

Temporal will keep running until it hears back from the workers and activity task execution. When some of our long running activities died, Temporal wasn’t notified, the worker slots were used up, and Temporal was unable to schedule more work in their place. 

We needed a way to make Temporal aware of these failed activities. To fix this issue, we used Temporal’s heartbeats. Heartbeats let workers ping the Temporal cluster to let Temporal know they are still chugging away. 

We configured our workers to send a heartbeat every two seconds, and for Temporal to check for a heartbeat every 30 seconds. If our Temporal cluster doesn’t receive a heartbeat within that time period, it will mark the worker as dead.

We opted to start the heartbeats with a separate Java TimerTask for each activity, so that the main activity threads could run without interruption. The TimerTask class defines a task that can be scheduled to run for just once or for a repeated number of times. We scheduled each heartbeat on a single Java Timer and it runs all the heartbeat TimerTask’s on a fixed interval using one thread efficiently.

The heartbeats are removed from the Timer when the heartbeat fails or the activity reaches the end. The space is reclaimed for more heartbeats and the single Timer keeps handling heartbeats.

Temporal heartbeats stabilized our system, and allowed us to handle long-running activities more effectively.

Step 05: Configuring gRPC payloads

The Temporal Command-Line tool (CLI) tool provides an easy way to start, pause and schedule workflow execution.  A Temporal CLI provides a command-line interface to manage various aspects of Temporal, including namespaces, workflows, task queues, and more. 

As a Clojure shop, we wrote scripts and wrapped them in babashka code to match other operational tools we have for the rest of our system. The CLI expected JSON (JavaScript Object Notation is a lightweight data-interchange format) input and we wanted JSON output in the Temporal UI. However, initially the Clojure SDK didn't support JSON so we had a problem.

To overcome this hurdle, we wrote our own Temporal data converters.

We used Clojure’s reify to create anonymous objects that extended `PayloadConverter` classes in the Temporal Java SDK. We manipulated the data using  nippy and encoded/decoded with JSON via the built in `clojure.data.json`.

The `json-converter` decodes the UTF-8 string from the CLI input into JSON and then turns it into bytes for transit to the Temporal platform.

The 'byte-converter' takes bytes and converts them into valid JSON for the Temporal platform to display in their UI.

As you can see, we leveraged the Java SDK, and extended the class PayloadConverter, a binary form suitable for network transmission that may include some metadata, to handle the inputs and outputs we needed. Once these objects were created,we passed them to our Temporal client and everything from the CLI to the UI worked! 

You could go a level deeper and change the way the bytes are transferred over the wire, which we might have done if we needed to implement data compression or encryption.

Step 06: Batching activities

The activities in our code are often independent, so we wanted a way to run multiple activities at the same time on one workflow. In most cases, we also did not want one failure to short-circuit the execution of other workflows. 

Temporal associates each activity with a promise and allows your workflow executions to wait for all the promises to finish or fail. However, the Temporal Clojure SDK will stop at the first failure, by default. 

To overcome this, we utilized the Java promise handle, enabling us to:

  1. Run batches within a single workflow.
  2. Wait for all batches to finish, handling exceptions gracefully.
  3. Aggregate errors at the end for workflow error management.

Leveraging the built in promise type in Temporal we grabbed the `PromiseAdapter` handles.

The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value

This code runs all promises and waits for the result of each, swallowing exceptions,so the workflow does not crash.

NOTE: We were pretty strict on non reflection with these extensions so the `^"[Lio.temporal.workflow.Promise;"` type annotation is for an array type to avoid reflection.

Now, any part of our code can call `invoke-parallel-activities` to start looping over promises and passing to `execute-parallel-promises` aggregating the results. 

One Clojure-specific note: we had to use a non lazy Clojure loop, this means that sequence elements are not available ahead of time, to avoid starting random sized chunks of processes. By default Clojure’s lazy sequences don’t give us the guarantees we would need to have total control over the batch size. 

NOTE: Temporal had gRPC size limits that we had to respect with batch sizes

Now we can use this pattern to batch executions in a single workflow like so:

This implementation worked well, but there was still a ~50Mb history limit on the workflow execution in Temporal. Once we started running into the history limit, our main workflow batching the activities crashed. 

To address this issue, we implemented `Child Workflows` for the Temporal Clojure SDK, which have their own history, and can be dispatched from a main workflow. With `Child Workflows` we could circumvent all of gRPC limits/pitfalls and continue chugging along activities in parallel.

Child Workflows work similarly to activities and are started under a workflow. In the example, the Child Workflows are batched and completed as promise groups to complete large batches of work.

Each Child Workflow invokes the above activities in parallel and limits the gRPC execution history limit Temporal enforces.

We ended up contributing “Child Workflows” and “all-settled” to the Temporal Clojure SDK using the built-in promise examples found here to construct the parallel batched Child Workflows with batched activities.

A final note

Temporal and Clojure make a powerful pair at Crossbeam. Leveraging macros to streamline activity and workflow definitions saved us significant development time. Clojure idioms like reify proved invaluable for extending the Java SDK and customizing data converters. Even batching promises was straightforward with non-lazy loops, giving us fine-grained control over batch sizes.

For our team, adding new Temporal workflows is now the preferred approach for orchestrating future data workflows.

You’ll also be interested in these

Article
|
7
 minutes
New Data: Involving Partners in Deals Increases Win Rate for Nearly Every Ecosystem Size and Type
Article
|
7
 minutes
5 Ways to Leverage Ecosystem Data
Article
|
7
 minutes
How Bombora discovered hidden pipeline and closed $100K in 2 months with Crossbeam