Video
|
36
 minutes
Nearbound Sales #7: They Win, You Win
Article
|
3
 minutes
Nearbound Daily #024: Partnerships are your greatest resource
Video
|
43
 minutes
Nearbound Podcast #103: Think Customer Outcomes or Die - Raja Nucho on Surrounding the Sale with Partners
Article
|
7
 minutes
You Only Get One Shot At A First Impression: How To Ace Partner Onboarding
Article
|
2
 minutes
Nearbound Daily #023: Don't swim against the current
Video
|
23
 minutes
Howdy Partners #25: What is the 'SaaS Buying River'
Article
|
5
 minutes
What are ecosystem leads and how to find them
Video
|
22
 minutes
Nearbound Sales#6: Sell Together, Sell More
Article
|
6
 minutes
The partner experience weekly: Should partnerops role up to revops?
Article
|
2
 minutes
Nearbound Daily #020: GTM is about to get wild
Video
|
54
 minutes
Nearbound Podcast #102: War Stories with Legends
Video
|
31
 minutes
Nearbound Marketing #20: Creators Are Your Cheat Code
Article
|
3
 minutes
Women in SaaS Partnerships Are (Probably) Underpaid
Video
|
27
 minutes
Nearbound Sales #5: Unlock Unstoppable Momentum and Build a Flywheel
Article
|
11
 minutes
The Partner Experience Weekly: Account Mapping - 9-Box Strategic Plan
Video
|
42
 minutes
Nearbound Podcast #101: From Seller to VP Sales to CEO — How to Partner Pill Your Sales Org
Article
|
16
 minutes
How to earn the respect of your sales team in 60 Days
Article
|
12
 minutes
Building an Ecosystem Cluster Strategic Co-Sell Program
Article
|
2
 minutes
Nearbound Weekend 03/04: How can we save B2B?
Video
|
46
 minutes
Nearbound Marketing #4: Evangelism Leads Where?
Article
|
5
 minutes
The Ecosystem-Led Growth Race Between the US and Europe: Who’s Winning?
Video
|
23
 minutes
Howdy Partners #24: How to Make Partner Enablement Actually Engaging
Video
|
25
 minutes
Nearbound Sales #4: The Dark Side of Working with Partners
Article
|
8
 minutes
The Partner Experience Weekly: Building CRM for Partnerships
Video
|
150
 minutes
Nearbound Podcast #100: From Scorpions and Casinos to Hubspot and PartnerHacker
Article
|
6
 minutes
8 SaaS Leaders You Should Follow: Partnerships Edition
Video
|
41
 minutes
Nearbound Marketing #3: How to Use Events to Drive Your Marketing
Article
|
16
 minutes
Unlocking the Power of Partnerships with Martin Scholz of PartnerXperience
Article
|
27
 minutes
Howdy Partners #22: Developing Your Ideal Partner Profile
Article
|
7
 minutes
Getting Started with Ecosystem-Led Growth: Your First 3 Plays
Article
|
8
 minutes
The Partner Experience Weekly: Salesforce List Views for Partnerships
Video
|
40
 minutes
Nearbound Marketing #2: Building a Brand with Zero Network
Video
|
3
 minutes
Leveraging Nearbound Data in HubSpot
Article
|
11
 minutes
Your 2023 Interview Kit For Landing Your Next Partnerships Role
Article
|
1
 minutes
Filling the Critical Gap: How to Become Every Technology Platform's Favorite Partner
Article
|
9
 minutes
The Partner Experience Weekly: Building a Partnership App in Salesforce CRM
Video
|
42
 minutes
Nearbound Marketing #1: Market Like a Journalist
Article
|
5
 minutes
5 Reasons to Attend Supernode 2023
Article
|
27
 minutes
Howdy Partners #19: Approaching Agency Partnerships
Video
|
38
 minutes
Nearbound Sales #1: 1 + 1 = 1
Article
|
8
 minutes
The Partner Experience Weekly: Partner Recruitment in Salesforce (with screenshots)
Article
|
6
 minutes
The Most Common Partnership KPIs and Quarterly Targets for 2023
Article
|
6
 minutes
7 Ways to Sabotage Your Partner Ecosystem: A Guide for Partner Managers
Article
|
7
 minutes
How to build a B2B affiliate program in seven steps
Article
|
5
 minutes
Top tips for managing a successful B2B partnership
Article
|
1
 minutes
nearbound.com CEO Jared Fuller Wins 2023 SaaSy Sales Leadership Award
Article
|
8
 minutes
A Career in Partnerships Could Help You Make More Money Faster
Article
|
32
 minutes
Howdy Partners #17: Living in the Ecosystem
Article
|
5
 minutes
HubSpot Ecosystem Set to Reach $17.9 Billion in Revenue by 2025
Article
|
12
 minutes
nearbound.com principles: show me you know me — Samantha McKenna
Article
|
12
 minutes
Partnerships 101: What Is Ecosystem-Led Growth?
Article
|
25
 minutes
Howdy Partners #15: Your Partner Team Tech Stack
Article
|
2
 minutes
Five Soft Skills You Need as a Partnerships Leader
Video
|
48
 minutes
Nearbound Podcast #091: Going-To-Market through Community with Kathleen Booth
Article
|
7
 minutes
The Four Main Sales Pain Points From 2022 and How To Beat Them
Article
|
8
 minutes
Meet the Startup Choosing Ecosystem-Led Growth Over Direct Sales
Article
|
10
 minutes
Partnership Success Checklist: How to Start the Year Strong
Article
|
8
 minutes
Sunday Stories: The Unseen Cost of Not Integrating
Article
|
29
 minutes
Howdy Partners #11: Revenue Generating Activities
Video
|
43
 minutes
Nearbound Podcast #088: Building Partner Relationships, A CrossPod Takeover with Ecosystem Aces
Video
|
47
 minutes
Nearbound Podcast #087: Ecosystems Expansion and Enablement: The How Behind Growth and Partner Engagement
Article
|
2
 minutes
Driving Deals Faster: A Nearbound GTM Strategy Amplifies Revenue
Video
|
3
 minutes
Andreessen Horowitz’s Sarah Wang: The best performing companies are prioritizing partnerships | Supernode 2022
Article
|
5
 minutes
IRL Partnerships and Ecosystem Conferences to Attend in 2023
Article
|
7
 minutes
Introduction to Partner Manager
Article
|
2
 minutes
The Secret to Partner Retention: Treating your Partners Like Customers
Video
|
47
 minutes
Nearbound Podcast #085: Integrating Partnerships Into Products: A Crosspod Takeover with Mark Brigman
Article
|
10
 minutes
Partners Contribute to 58% of the Revenue of Top Performers (And 5 Other Sales Stats)
eBook
Foreword of the Nearbound and the Rise of the Who Economy Book
Article
|
3
 minutes
Getting Your Frogs Out of the Pot to Incubate Packaged Ecosystem IP
Article
|
5
 minutes
4 Parts of the Sales Cycle Where Partnerships Can Help
Video
|
5
 minutes
Building Your Dream ELG Tech Stack
Article
|
 minutes
ELG Insider Daily #695: Connected selling = connected customers
Video
|
40
 minutes
Nearbound Podcast #083: Building Partnerships from the Ground-up
Article
|
18
 minutes
Four Tips for Launching a 30-60-90 Day Enablement Program for Your New Sales Hires
Article
|
4
 minutes
The Secret to a Successful Second Sales Call: Involving a Partner
Article
|
5
 minutes
How Sales Teams Leverage Their Ecosystems to Enter Every Deal With Confidence
Article
|
4
 minutes
First Friday: Partner Success Maturity Model
Article
|
4
 minutes
Hunting for Leverage Points in Partnerships
Video
|
27
 minutes
Howdy Partners #75: Prioritizing Operations or Relationships? Striking the Balance in Partnerships with Coriena Hipple Merejo
Article
|
4
 minutes
The Direct vs Partner-Led Dilemma
Article
|
7
 minutes
How to Win Over Your Strategic Partner’s Customer Success Team Right Away
Article
|
 minutes
How to Build a Partner Program From the Ground Up
Article
|
9
 minutes
Want To Up Your Integration Game? Adopt A Product Mindset.
Article
|
6
 minutes
Building a Partnership Program That Works - with Donagh Kiernan
Video
|
20
 minutes
The Inside Track: Top Partnership Plays from Chris Lavoie at Gorgias
Article
|
5
 minutes
Your Services Partners Can Help Close the “Impossible” Deal (And Make Your Customers Happier)
Article
|
8
 minutes
Why Co-innovation Between Tech Partners Is So Hard
Article
|
6
 minutes
Sharing Partner Data Used To Be Scary. These New Best Practices Can Help
Article
|
1
 minutes
WorkSpan Raises $30M Series C
Video
|
22
 minutes
School of Partnerships - Recordings
Article
|
5
 minutes
Using Composable Ecosystem Management To Break Down Market Silos
Article
|
1
 minutes
Nearbound Daily #010: Creator economy in B2B
Article
|
24
 minutes
3 Companies on Building Their First Partnerships Team (And Hiring From Within)
Video
|
25
 minutes
Howdy Partners #37: Conference Strategy
Video
|
18
 minutes
Howdy Partners #28: Positioning With Your Partners is More Important Than Working On Your Co-Sell Pitch
Article
|
11
 minutes
The 5 Phases of Co-selling for Rolling Out Your New Tech Partnership
Article
|
6
 minutes
18 Partnerships People You Should Follow On LinkedIn In 2022
Article
|
4
 minutes
The Power In GoToEco Bundles
Article
|
15
 minutes
Tech Ecosystem Maturity: Are You Influencing Your Company’s Product/Feature Roadmap?
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