Article
|
8
 minutes
Partnerships 101: What Is a PRM and Should I Use One?
Article
|
7
 minutes
Tech Ecosystem Maturity: How to Level Up Your “Better Together” Messaging
Video
|
36
 minutes
Partner Ecosystems 101
Video
|
1
 minutes
Dave Goldstein: Ecosystem-Led Sales for the Enterprise: How Braze Leveraged Alliances to Fuel Robust Growth | Supernode 2023
Article
|
11
 minutes
8 Times a Partnership Impacted an “Exit Event” (And Why Acquisitions are on The Rise)
Article
|
9
 minutes
5 Signs Your Tech Partner's About to Get Acquired (And How to Prepare for Change)
Article
|
12
 minutes
Tech Ecosystem Maturity: How to Level Up Your Integrations Team
Video
|
18
 minutes
The Inside Track: Crossbeam Security 101 with CISO Chris Castaldo
Article
|
8
 minutes
Six Tips for Expanding Internationally Using Channel Partners
Article
|
6
 minutes
10 steps to develop a co-marketing strategy
Article
|
4
 minutes
How Typeform Went from 30 Integrations to 100+ in Just One Year
Article
|
6
 minutes
How Typeform Improved Their Revenue by 40% with ELG and PLG
Article
|
6
 minutes
Partnerships 101: What Is Co-Selling?
Article
|
6
 minutes
Partnerships 101: Inbound vs Outbound Integrations and Why They Matter for Your Partnerships
Article
|
11
 minutes
How to Communicate Effectively With Your Entire GTM Team and The C-Suite
Article
|
11
 minutes
Partnerships 101: What Is an Ecosystem and How Is It Redefining Partnerships?
Video
|
20
 minutes
The Inside Track: Get to know the Crossbeam Salesforce App
Article
|
18
 minutes
The 7 Metrics That Prove the Business Impact of Your Tech Integrations
Article
|
7
 minutes
8 Times Sales Reps Won the Deal by Co-Selling With Partners
Article
|
9
 minutes
6 Ways Sales Professionals Can Use Partnerships to Advance Their Careers (and Get Promoted)
Article
|
6
 minutes
How Co-Selling & Co-Marketing Build Revenue
Article
|
43
 minutes
How Demandbase Acquired DemandMatrix in Seven Months After Launching a Partnership
Article
|
8
 minutes
The Intersection of Partnerships and Product Development with Pandium’s Cristina Flaschen
Video
|
37
 minutes
The 4 Levels of Tech Ecosystem Maturity
Article
|
12
 minutes
8 Tips for Surfacing the Business Impact of Partnerships and Driving Partner-Sourced Revenue Earlier
Article
|
7
 minutes
Tech Ecosystem Maturity: How to Level Up Your Co-selling Workflows
Article
|
31
 minutes
Despite The Economy, Gartner Projects Double-Digit Growth As Companies Find Ways to Do More with Less
Article
|
11
 minutes
The 5 Things to Do in Your First 90 Days as a Partnership Leader
Article
|
6
 minutes
Ecosystem is Everything: How to Embrace Second Party Data with Crossbeam
Article
|
7
 minutes
Vetting 100s of Channel Partners? Use This Four-Criteria Checklist to Speed Up the Process
Article
|
6
 minutes
8 Ways to Treat Your Co-Selling Partners With R-E-S-P-E-C-T
Video
|
42
 minutes
Nearbound Podcast #026: Building Trust in Channel Partnerships
Article
|
12
 minutes
Partnership KPIs For Marketing, Sales, Customer Success + More
Video
|
44
 minutes
No More Silos: 4 New Ways to Use Partner Data
Article
|
12
 minutes
Account mapping. How to (finally) do it without giant, cumbersome spreadsheets
Article
|
13
 minutes
15+ Questions to Help Your Sales Reps Master Their Co-Selling Motions
Article
|
23
 minutes
How We Foster Collaboration Remotely at Crossbeam
Article
|
7
 minutes
21 Partnerships People You Should Follow on LinkedIn
Article
|
10
 minutes
A Fill-in-the-Blanks Exercise for Evaluating Your Partner Program
Article
|
12
 minutes
How to Use CRM Data & Automation to Nurture Your Co-Selling Relationships
Article
|
12
 minutes
How to Use Partner Data In Your Sales and Marketing Dashboards (Part 2 of 2)
Article
|
7
 minutes
How CallRail Increased Integration Adoption by 167% Through Strategic Partnership with HubSpot and Reveal
Article
|
7
 minutes
3-step strategy for partnership managers
Video
|
5
 minutes
How to Execute an Effective Nearbound Channel Strategy
Article
|
10
 minutes
Don't Try To Fit Ecosystem Partners into a Channel Hole
Video
|
61
 minutes
Nearbound Podcast #022: Build, Buy, or Partner
Article
|
9
 minutes
You Should be Account Mapping at Every Stage of the Customer Lifecycle
Article
|
5
 minutes
5 Ways to Incentivize Your Sales Team to Live, Eat, and Breathe Partnerships
Article
|
7
 minutes
How to Learn the Partnerships Love Languages
Article
|
5
 minutes
How to Learn Your Customer’s Tech Stack and Increase Integration Adoption by 17%
Article
|
11
 minutes
The 9-Step Partner Impact Score Methodology for Strategic Co-Selling With Partners
Video
|
7
 minutes
Catherine Brodigan: Effective Co-Selling* (*because you have no other choice) | Supernode 2023
Article
|
11
 minutes
The Most Common Partnership KPIs (According to Company Size and Maturity)
eBook
State of the Partner Ecosystem 2021
Article
|
1
 minutes
Your Slack Connect Channels: Now Powered by Crossbeam
Video
|
2
 minutes
Demystifying Partnership KPIs: Know What to Measure & When
Article
|
26
 minutes
Democratize Partner Insights with Crossbeam’s Chrome Extension
eBook
The Partner Playbook
Article
|
4
 minutes
10 Facts You Oughta Know if You Work in B2B Partnerships
Article
|
9
 minutes
20 Integrations and Chrome Extensions for Partner Managers
Article
|
21
 minutes
An Inside Look Into Google and HubSpot’s GTM Strategy for Their Ads Integration
Article
|
11
 minutes
5 Partnership Challenges Agencies Face (And How to Tackle Them Head-On)
Article
|
9
 minutes
Two Attribution Challenges for Partnership Professionals (and How to Get Ahead of Them)
Article
|
12
 minutes
We Mapped the Career Paths of 6 Women in Partnerships
Article
|
10
 minutes
Five Tactics You Can Use Right Now to Show the Real-Time Impact of Partnerships
Article
|
5
 minutes
How Sendcloud Achieved an 80% Increase in New Leads Sourced from Partners Using Reveal
Article
|
9
 minutes
WP Engine Used This 7-Stage “Bow-Tie” Funnel to Increase Agency Partners by 50%
Video
|
45
 minutes
Nearbound Podcast #013: David and Goliath — Partnering Up With the Big CO's
Article
|
4
 minutes
Nine Micro Co-Marketing Motions for Warming Up a Partnership
Article
|
6
 minutes
ELG and the revenue team: How to break down silos so every GTM function wins
Article
|
4
 minutes
Ecosystem Ops 101: Six Ways to Drive Efficiency and Maximize the ROI of Your Partner Program
Article
|
6
 minutes
30+ Integration Listing Page Examples for Designing Your Tech Marketplace
Article
|
12
 minutes
Your Partner Vetting Checklist: 7 Questions to Ask Yourself Before Signing an Agreement
Article
|
7
 minutes
Standout Traits for a Great Partner Case Study (with Examples)
Article
|
5
 minutes
The Seven Filters You Need for Your Agency Partner Directory
Article
|
5
 minutes
Growth Hack: Where to Find your First Partner
Article
|
8
 minutes
The Enablement Program That Can Help You Boost Agency Partner Retention by 70%
Article
|
2
 minutes
ActiveCampaign’s Co-Marketing Playbook for Getting the #1 Spot in Salesforce’s AppExchange
Article
|
4
 minutes
Your Partnerships Team Should Report to Marketing
Article
|
7
 minutes
The Co-Marketing Flip: Get Strategic with Your Partner Marketing Six Months into the Partnership
Video
|
9
 minutes
Friends With Benefits #8: Good Things Come to Good People
Article
|
5
 minutes
Get Off the Partner Enablement Treadmill
Article
|
9
 minutes
How alliances can leverage their channel partners to go to market with their integrated solution
Article
|
4
 minutes
The Anatomy of a Killer SaaS Partner Newsletter (Plus Examples)
Video
|
53
 minutes
Nearbound Podcast #010: Creating Categories and Partner Ecosystems
Article
|
6
 minutes
You Should Train Your Sales Team to be Tech Stack Experts
Article
|
3
 minutes
Your Product-First Partnerships Team Should Report Directly to the CEO
Video
|
7
 minutes
How to Activate Ecosystem Insights with Reports and Dashboards in Salesforce | Connector Summit 2022
Article
|
4
 minutes
Your B2B SaaS Partner Page Checklist (with 50 Examples)
Article
|
7
 minutes
Your Partnerships Team Should Report to Sales (At First)
Video
|
49
 minutes
Nearbound Podcast #004: Secrets of Partner Enablement & Marketing
Video
|
44
 minutes
Nearbound Podcast #001: Landing your first Sumo
Video
|
50
 minutes
Nearbound Podcast #003: Building API ecosystems, Stripe & Notion
Article
|
10
 minutes
Advanced Crossbeam: Too Many CRMs? Here’s How to Sort it All Out
Article
|
7
 minutes
AEs are Leveraging Ecosystem-Led Sales to Close Deals 46% Faster
Article
|
27
 minutes
The 12 Best Partnership and Business Development Podcasts (So Far)
Article
|
33
 minutes
Monetize Your Technology Partnerships With These 8 Tactics
Article
|
13
 minutes
Source, Decide, Execute: Your Framework For a Successful Partner Program
Video
|
38
 minutes
4 Easy Account Mapping Wins
Video
|
3
 minutes
Cristina Flaschen: Proving the ROI of partnerships | Supernode Conference 2022
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