Ucommerce
  • Ucommerce Next Gen
    • Getting Started
      • Prerequisites
      • Licensing
      • Ucommerce Templates
      • Headless Template
      • MVC Template
    • Headless
      • Postman Collection
      • Headless API Authentication
        • Token endpoint - Authorization Header
        • Authorization Scopes
        • Refreshing the Access Token
      • Reference
        • Cart
        • Cart / Order Line Items
        • Shipment
        • Billing
        • Promotion Codes
        • Price Groups
        • Payment Methods
        • Countries
        • Shipping Methods
        • Catalogs
        • Cart Custom Properties
        • Line Item Custom Properties
        • Orders
        • Views for Cart modifying operations
      • Custom Headless APIs
      • Error Handling
      • Pagination
      • Deprecation
    • Backoffice Authentication
      • Microsoft Entra ID Example
      • Auth0 Authentication Example
    • Definitions
      • What is a Definition
    • Search and indexing
      • Configuration
      • Indexing
        • Index Definitions
        • Facets
        • Indexing Prices
        • Suggestions
        • Custom Data
      • Searching
    • Payment Providers
      • Stripe Provider Integration
      • Implementing a custom payment provider
    • Data Import
    • Miscellaneous
      • Media
      • Price Group Inheritance
      • Price Group Criteria
      • Soft Deletion Of Entities
      • Logging
      • OpenTelemetry
    • Extensions
      • Extending Pipelines
        • Order Processing Pipelines
        • Checkout Pipelines
      • Changing Service Behavior
        • Images
        • Content
      • Custom Headless APIs
      • Extend the Backoffice
        • Custom UI Components
      • Custom Editor UI
      • Custom Promotion Criteria
      • Custom Price Group Criteria
    • How-To
      • Migrate from Classic
        • Common database issues
      • Entities from code
        • Bootstrapping data on startup
        • Product Definitions & Fields
      • Discover pipelines and their tasks
      • Executing a pipeline
    • Integrations
      • Umbraco Media Delivery API
      • App Slices
        • Product Picker
  • Release Notes
  • Contact Us
Powered by GitBook
On this page

Was this helpful?

  1. Ucommerce Next Gen
  2. How-To

Executing a pipeline

Injecting and Executing a Pipeline

Inject the Pipeline

If you want to execute a pipeline from somewhere else, first, inject it into the constructor. This is demonstrated in the MyController constructor, which takes an IPipeline<PipelineInputType, PipelineOutputType> as a parameter:

public MyController(IPipeline<PipelineInputType, PipelineOutputType> pipeline)
{
    _myPipeline = pipeline;
}

Execute the Pipeline

When you're ready to execute the pipeline, create an instance of the input type and populate it with your desired parameters. Then, use the _myPipeline.Execute method to process the input and get the output from the result. Here's how you can do it:

var input = new PipelineInputType()
{
    Property1 = true,
    Property2 = 42,
    Property3 = "Hello",
};
var response = await _myPipeline.Execute(input, token);
var output = response.EnsureSuccess();

response.EnsureSuccess() throws a PipelineException if any exceptions happen during the execution of the pipeline, otherwise, it will return the output (result) of the pipeline execution. The exceptions and output are also directly accessible using response.Errors and response.Output respectively.

PreviousDiscover pipelines and their tasksNextIntegrations

Last updated 1 year ago

Was this helpful?