Orkes logo image
Product
Platform
Orkes Platform thumbnail
Orkes Platform
Orkes Agentic Workflows
Orkes Conductor Vs Conductor OSS thumbnail
Orkes vs. Conductor OSS
Orkes Cloud
How Orkes Powers Boat Thumbnail
How Orkes Powers BOAT
Try enterprise Orkes Cloud for free
Enjoy a free 14-day trial with all enterprise features
Start for free
Capabilities
Microservices Workflow Orchestration icon
Microservices Workflow Orchestration
Enable faster development cycles, easier maintenance, and improved user experiences.
Realtime API Orchestration icon
Realtime API Orchestration
Enable faster development cycles, easier maintenance, and improved user experiences.
Event Driven Architecture icon
Event Driven Architecture
Create durable workflows that promote modularity, flexibility, and responsiveness.
Human Workflow Orchestration icon
Human Workflow Orchestration
Seamlessly insert humans in the loop of complex workflows.
Process orchestration icon
Process Orchestration
Visualize end-to-end business processes, connect people, processes and systems, and monitor performance to resolve issues in real-time
Use Cases
By Industry
Financial Services icon
Financial Services
Secure and comprehensive workflow orchestration for financial services
Media and Entertainment icon
Media and Entertainment
Enterprise grade workflow orchestration for your media pipelines
Telecommunications icon
Telecommunications
Future proof your workflow management with workflow orchestration
Healthcare icon
Healthcare
Revolutionize and expedite patient care with workflow orchestration for healthcare
Shipping and logistics icon
Shipping and Logistics
Reinforce your inventory management with durable execution and long running workflows
Software icon
Software
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean leo mauris, laoreet interdum sodales a, mollis nec enim.
Docs
Developers
Learn
Blog
Explore our blog for insights into the latest trends in workflow orchestration, real-world use cases, and updates on how our solutions are transforming industries.
Read blogs
Check out our latest blog:
Conductor CLI Guide: Register, Run, Retry, and Recover Durable Workflows Without Leaving Your Terminal šŸ’»
Customers
Discover how leading companies are using Orkes to accelerate development, streamline operations, and achieve remarkable results.
Read case studies
Our latest case study:
Twilio Case Study Thumbnail
Orkes Academy New!
Master workflow orchestration with hands-on labs, structured learning paths, and certification. Build production-ready workflows from fundamentals to Agentic AI.
Explore courses
Featured course:
Orkes Academy Thumbnail
Events icon
Events
Videos icons
Videos
In the news icon
In the News
Whitepapers icon
Whitepapers
About us icon
About Us
Pricing
Get a demo
Signup
Slack FaviconDiscourse Logo icon
Get a demo
Signup
Slack FaviconDiscourse Logo icon
Orkes logo image

Company

Platform
Careers
HIRING!
Partners
About Us
Legal Hub
Security

Product

Cloud
Platform
Support

Community

Docs
Blogs
Events

Use Cases

Microservices Workflow Orchestration
Realtime API Orchestration
Event Driven Architecture
Agentic Workflows
Human Workflow Orchestration
Process Orchestration

Compare

Orkes vsĀ Camunda
Orkes vsĀ BPMN
Orkes vsĀ LangChain
Orkes vsĀ Temporal
Twitter or X Socials linkLinkedIn Socials linkYouTube Socials linkSlack Socials linkGithub Socials linkFacebook iconInstagram iconTik Tok icon
Ā© 2026 Orkes. All Rights Reserved.
Back to Blogs

Table of Contents

Share on:Share on LinkedInShare on FacebookShare on Twitter
Worker Code Illustration

Get Started for Free with Dev Edition

Signup
Back to Blogs
SOLUTIONS

Building a Robust Subscription System with Java Spring Boot and Conductor

Riza Farheen
Riza Farheen
Developer Advocate
Last updated: June 1, 2023
June 1, 2023
6 min read

Related Blogs

How to Build a Simple, Modular, and AI-Powered Fraud Detection Workflow

Jul 8, 2025

How to Build a Simple, Modular, and AI-Powered Fraud Detection Workflow

Automating Serialization/Deserialization Tests with Orkes Conductor and LLMs

May 29, 2025

Automating Serialization/Deserialization Tests with Orkes Conductor and LLMs

Automating Insurance Claims Processing with AI and Conductor

Apr 24, 2025

Automating Insurance Claims Processing with AI and Conductor

Ready to Build Something Amazing?

Join thousands of developers building the future with Orkes.

Start for free

When managing subscriptions, manually handling the renewal process is daunting for an organization. What if you forget your renewal? It can definitely impact your organization resulting in service disruptions and financial penalties.

You might have already heard of several instances where organizations forget their domain renewal, resulting in service outages that cost them millions.

Automating your subscription renewal process is the only way to overcome such scenarios. An orchestration engine like Orkes Conductor can be leveraged to automate your subscription workflows. Orkes Conductor is an app-building platform built over Netflix Conductor.

In this blog, let’s look at how to build a sample subscription application for managing monthly subscriptions using Conductor and Java Spring Boot 2.

Monthly Subscription Workflow: Explained

The code used to define this application is available on Github here: https://github.com/conductor-sdk/orkes-java-springboot2-subscription-example

Suppose the business logic for your monthly subscription workflow is as follows:

  1. Trigger a subscription workflow that includes a trial period. The trial period consists of sending a welcome mail and a waiting period until the trial ends.
  2. Once the trial ends, it starts the billing process that should recur every billing period.
  3. At the end of the number of specified billing periods, the workflow ends and notifies the user.
  4. The user should be able to cancel the subscription at any point during either the trial or billing period.
  5. A way to notify the users before the trial starts, when billing commences, and when the subscription is completed/canceled.

Let’s visualize the workflow:

Workflow handling monthly subscriptions

Workflow JSON

json
{
  "name": "monthly_subscription_workflow_with_trial",
  "description": "Edit or extend this sample workflow. Set the workflow name to get started",
  "version": 1,
  "inputParameters": [
    "userId",
    "userEmail",
    "billingAmount",
    "billingPeriods"
  ],
  "tasks": [
    {
      "name": "set_workflow_variables",
      "taskReferenceName": "monthly_subscription_workflow_with_trial",
      "type": "SET_VARIABLE",
      "inputParameters": {
        "billingAmount": "${workflow.input.billingAmount}",
        "billingPeriods": "${workflow.input.billingPeriods}"
      }
    },
    {
      "name": "start_subscription_and_wait",
      "taskReferenceName": "start_subscription_and_wait",
      "type": "FORK_JOIN",
      "forkTasks": [
        [
          {
            "name": "monthly_subscription_workflow_webhook",
            "taskReferenceName": "monthly_subscription_workflow_webhook",
            "type": "WAIT_FOR_WEBHOOK",
            "inputParameters": {
              "matches": {
                "$['event']['userId']": "${workflow.input.userId}"
              }
            }
          },
          {
            "name": "send-subscription-demo-email",
            "taskReferenceName": "send_subscription_canceled_email",
            "type": "SIMPLE",
            "inputParameters": {
              "emailSubject": "Your subscription has been canceled",
              "emailContent": "Some email content welcoming user to subscription",
              "userEmail": "${workflow.input.userEmail}",
              "userId": "${workflow.input.userId}"
            }
          },
          {
            "name": "terminate_subscription_workflow",
            "taskReferenceName": "terminate_subscription_workflow",
            "type": "TERMINATE",
            "inputParameters": {
              "terminationStatus": "COMPLETED",
              "terminationReason": "User canceled with reason: ${monthly_subscription_workflow_webhook.output.event.reason}"
            }
          }
        ],
        [
          {
            "name": "send-subscription-demo-email",
            "taskReferenceName": "send_welcome_email",
            "type": "SIMPLE",
            "inputParameters": {
              "emailSubject": "Welcome to the subscription!",
              "emailContent": "Some email content welcoming user to subscription",
              "userEmail": "${workflow.input.userEmail}",
              "userId": "${workflow.input.userId}"
            }
          },
          {
            "name": "wait_trial_period",
            "taskReferenceName": "wait_trial_period",
            "type": "WAIT",
            "inputParameters": {
              "duration": "10 seconds"
            }
          },
          {
            "name": "send-subscription-demo-email",
            "taskReferenceName": "send_subscription_active_email",
            "type": "SIMPLE",
            "inputParameters": {
              "emailSubject": "Thanks for your subscription, billing will start soon!",
              "emailContent": "Some email content informing billing",
              "userEmail": "${workflow.input.userEmail}",
              "userId": "${workflow.input.userId}"
            }
          },
          {
            "name": "loop_until_cancel_or_billing_count",
            "taskReferenceName": "loop_until_cancel_or_billing_count",
            "type": "DO_WHILE",
            "inputParameters": {
              "billingPeriods": "${workflow.variables.billingPeriods}"
            },
            "loopCondition": "(function () {\n  return $.loop_until_cancel_or_billing_count[\"iteration\"] < $.billingPeriods;\n})();",
            "loopOver": [
              {
                "name": "subscription-monthly-charge",
                "taskReferenceName": "subscription-monthly-charge",
                "type": "SIMPLE",
                "inputParameters": {
                  "userId": "${workflow.input.userId}",
                  "amount": "${workflow.variables.billingAmount}",
                  "billingPeriodNumber": "${loop_until_cancel_or_billing_count.output.iteration}"
                }
              },
              {
                "name": "wait_for_billing_period",
                "taskReferenceName": "wait_for_billing_period",
                "type": "WAIT",
                "inputParameters": {
                  "duration": "10 seconds"
                }
              }
            ],
            "evaluatorType": "javascript"
          }
        ]
      ]
    },
    {
      "name": "start_subscription_and_wait_join",
      "taskReferenceName": "start_subscription_and_wait_join",
      "type": "JOIN",
      "joinOn": [
        "loop_until_cancel_or_billing_count"
      ]
    },
    {
      "name": "send-subscription-demo-email",
      "taskReferenceName": "send_subscription_ended_email",
      "type": "SIMPLE",
      "inputParameters": {
        "emailSubject": "Your subscription has ended! Thank you :)",
        "emailContent": "Some email content informing end of subscription",
        "userEmail": "${workflow.input.userEmail}",
        "userId": "${workflow.input.userId}"
      }
    },
    {
      "name": "complete_workflow",
      "taskReferenceName": "complete_workflow",
      "type": "TERMINATE",
      "inputParameters": {
        "terminationStatus": "COMPLETED"
      }
    }
  ],
  "schemaVersion": 2
}

You need to provide the following input parameters while running the workflow.

  • userId
  • userEmail
  • billingAmount
  • billingPeriod

Let’s see how the workflow progress:

  • The workflow begins with a fork-join task that lets you run a specified list of tasks in parallel.
    • In this example, we have two forks. The first fork handles the subscription flow, including the trial and actual subscription process.
    • The second fork waits for a signal if the user is canceling.
    • Either fork can complete and end the workflow.
  • In the first fork, when a user subscribes, the trial period begins. An email is sent to the user regarding the trial commencement. This is implemented using a worker task (SIMPLE task), where you can configure the email subject, & email content. The email ID and username will be invoked from the workflow input.
json
{
           "name": "send-subscription-demo-email",
           "taskReferenceName": "send_welcome_email",
           "inputParameters": {
             "emailSubject": "Welcome to the subscription!",
             "emailContent": "Some email content welcoming user to subscription",
             "userEmail": "${workflow.input.userEmail}",
             "userId": "${workflow.input.userId}"
           },
           "type": "SIMPLE",
},
  • It is followed by a wait task that can be configured to wait as per your trial period. In this example, we have configured it to wait until 10 seconds.
  • Once the wait period is over, the subscription begins, and an email regarding this is sent using the same task definition we defined above.
  • Then the subscription begins and is looped until completion using the do-while task.

Now, what if the user cancels the subscription?

The second fork waits for the signal if the user cancels. To pass the signal, we have leveraged Webhook in this example. A webhook is configured with the following parameters:

Webhook for invoking subscription workflow

  • Under the field Workflows To Receive Webhook Event, we have chosen the monthly subscription workflow.
  • Conductor has out-of-box support for the majority of providers. Since we are using the cURL command to send signals to webhook, we have chosen the Source Platform as Custom.
  • The webhook is configured to expect a header called ā€œsubscriptionflowā€ with the value ā€œsubscription-flow-header-unique-valueā€.
  • On saving the webhook initially, the URL would be Unverified, and when the first event comes from the webhook with header values configured, the URL would be verified.

In the WAIT_FOR_WEBHOOK task in the workflow definition, the input matches are defined as:

json
"inputParameters": {
             "matches": {
               "$['event']['userId']": "${workflow.input.userId}"
             }
},

Hence the sample webhook invocation using cURL looks like this:

shell
curl -H "Content-Type:application/json" -H "Accept:application/json" \
     -H 'subscriptionflow: subscription-flow-header-unique-value'    \
     -X POST 'https://developer.orkescloud.com/webhook/<WEBHOOK-URL>' \
     -d '{"event": {"userId" : "user-id-1"}}'

It includes the headers keys and value (same as configured in the webhook), the webhook URL & the input parameter ā€œuserIdā€, which should be the same as the workflow input you’ve provided.

You can use the webhook we created in Developer Edition to run this example. In case you are using another custom webhook, be sure to replace the webhook URL while invoking. Under application.properties in your spring boot project, too, you need to update the webhook URL.

Running Spring Boot App

The code used to define this application is available on Github here: https://github.com/conductor-sdk/orkes-java-springboot2-subscription-example

To run this app locally:

  1. Clone the spring boot project locally on your system.
  2. Replace the application.properties file with the access keys. Check out this guide on how to generate access keys from Developer Edition.
json
orkes.access.key=your_key_id
orkes.access.secret=your_key_secret
orkes.conductor.server.url=https://developer.orkescloud.com/api.

You also need to provide permissions for the application to access the workflow and tasks.

Note: If you are running Conductor locally, replace orkes.conductor.server.url with your Conductor server URL.

  1. Run your Spring Boot application from the root project folder using the following command:
java
mvn spring-boot:run

This application has a controller that is exposed in SubscriptionApiController.java and has the following API methods:

  1. /startSubscription : When invoked, it will trigger a workflow that handles subscriptions.
  2. /cancelSubscription : When invoked, it will call a webhook API into Conductor to signal that the subscription has ended.

Run Subscription Workflow in Developer Edition

Now you’ve got an understanding of the subscription workflow. Since you have configured and run your Spring Boot app, let’s run the workflow now!

  1. From Developer Edition, click Run Workflow from the left menu.
  2. Choose the workflow monthly_subscription_workflow_with_trial, provide the input parameters, and run the workflow.
json
{
  "userId": "",
  "userEmail": "",
  "billingPeriods": "",
  "billingAmount": ""
}

A successful execution looks like this in case if the user hasn’t canceled:

Successful execution for subscription workflow

If the subscription is canceled by the user (a signal is received via Webhook), the execution looks like this:

Successful execution for subscription workflow when user cancels

Summing Up

We built a visualized flow that can manage subscriptions effectively and even included handling a trial period! šŸ„‚

Try building the application from scratch, and reach out to us for any queries.

Meanwhile, explore other Conductor features through Orkes Developer Edition, a free dedicated developer sandbox for you to try out Conductor in real-time.

If you enjoy building applications with Conductor, don’t forget to give us a star on our Conductor repo. ⭐⭐⭐


Conductor is an enterprise-grade orchestration platform for process automation, API and microservices orchestration, agentic workflows, and more. Check out the full set of features or get a demo of Orkes Cloud, a fully managed and hosted Conductor service.