Camel Components

Dapr

Since Camel 4.12

Both producer and consumer are supported

The Dapr Component provides support for interacting with the Dapr Building Blocks.

URI format

dapr:operation[?options]

Where operation indicates the specific Dapr building block to interact with.

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The Dapr component supports the following options which are listed below.

Name Description Default Type

client (common)

Autowired The DaprClient for service invocation, state, publishing to pub/sub, bindings, secrets and configuration (also the configuration consumer). When not set, the endpoint builds one with DaprClientBuilder, which connects to the Dapr sidecar given by the Dapr properties, such as DAPR_SIDECAR_IP and DAPR_GRPC_PORT.

DaprClient

configKeys (common)

The keys of the configuration items to get (producer) or whose changes to receive (consumer) with the configuration operation, as a comma-separated list. Required for the configuration operation.

String

configStore (common)

The name of the Dapr configuration store component of the configuration operation, to get configuration items (producer) or to subscribe to their changes (consumer).

String

configuration (common)

The configuration shared by the endpoints of this component.

DaprConfiguration

contentType (common)

The content type of the event data that the pubSub producer publishes. When not set, the Dapr client uses the content type of its serializer, application/json by default.

String

previewClient (common)

Autowired The DaprPreviewClient for the lock operation and the pubSub consumer (streaming subscription to a topic). When not set, one is built with DaprClientBuilder from the Dapr properties.

DaprPreviewClient

pubSubName (common)

The name of the Dapr pub/sub component to publish to (producer) or to subscribe to (consumer) with the pubSub operation. Required for the pubSub operation.

String

topic (common)

The topic to publish to (producer) or to subscribe to (consumer) in the pub/sub component given by pubSubName. Required for the pubSub operation.

String

bridgeErrorHandler (consumer)

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

bindingName (producer)

The name of the Dapr output binding component to call with the invokeBinding operation.

String

bindingOperation (producer)

The operation of the output binding to call with the invokeBinding operation, such as create, get, delete or list. The supported operations depend on the binding component.

String

concurrency (producer)

The concurrency mode of the state save, get and delete operations: FIRST_WRITE (first-write-wins) or LAST_WRITE (last-write-wins). When not set, the state store applies its default, which is last-write-wins.

Enum values:

  • FIRST_WRITE

  • LAST_WRITE

Concurrency

consistency (producer)

The consistency level of the state save, get and delete operations: EVENTUAL or STRONG. When not set, the state store applies its default, which is eventual consistency.

Enum values:

  • EVENTUAL

  • STRONG

Consistency

eTag (producer)

The ETag of the value in the state store, for optimistic concurrency of the state save and delete operations: the state store applies the change only when the ETag matches the current ETag of the value.

String

eventName (producer)

The name of the event to send to the workflow instance with the raiseEvent workflow operation. Event names are case-insensitive.

String

expiryInSeconds (producer)

The time in seconds after which the lock expires, if not unlocked before. Required for the tryLock lock operation.

Integer

getWorkflowIO (producer)

Whether the state, waitForInstanceStart and waitForInstanceCompletion workflow operations also fetch the inputs, outputs and custom status of the workflow instance.

false

boolean

httpExtension (producer)

Autowired The HttpExtension (HTTP method, query parameters and HTTP headers) of the invokeService operation. A text value is converted to the HttpExtension constant of that HTTP method, without query parameters or HTTP headers: GET, POST, PUT, DELETE, HEAD, CONNECT, OPTIONS or TRACE (any case), and NONE for any other value. When set, the verb option and the CamelDaprVerb, CamelDaprQueryParameters and CamelDaprHttpHeaders headers are not used.

HttpExtension

key (producer)

The key of the value in the state store for the state save, get and delete operations, or the name of the secret to get with the secret operation. When the secret operation has no key, it gets all the secrets of the secret store.

String

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

lockOperation (producer)

The operation on the distributed lock: tryLock acquires the lock (the message body is then true when acquired, false otherwise), unlock releases it.

Enum values:

  • tryLock

  • unlock

tryLock

LockOperation

lockOwner (producer)

The ID of the owner of the lock: only the owner that acquired the lock can unlock it. Required for the lock operation.

String

metadata (producer)

Additional key-value pairs to pass as metadata to the Dapr building block, such as metadata.namespace=production. Used by the state get, getBulk, delete and executeTransaction operations, pubSub, invokeBinding, secret and configuration; the state save and saveBulk, invokeService, lock and workflow operations and the consumers do not pass it. The CamelDaprMetadata header takes the place of these for one message, except for the secret operation unless allowSecretStoreAndKeyFromHeaders is enabled. This is a multi-value option with prefix: metadata.

Map

methodToInvoke (producer)

The method to call on the service with the invokeService operation: the path that follows /method/ in the Dapr invocation URL, such as orders or api/orders.

String

reason (producer)

The reason for suspending or resuming the workflow instance. Required for the suspend and resume workflow operations.

String

resourceId (producer)

The ID of the resource to lock or unlock with the lock operation. Required for the lock operation.

String

secretStore (producer)

The name of the Dapr secret store component of the secret operation. Required for the secret operation.

String

serviceToInvoke (producer)

The service to call with the invokeService operation: the app ID of a Dapr application, the name of an HTTPEndpoint resource, or the URL of a non-Dapr endpoint.

String

stateOperation (producer)

The operation on the state store: save (one key), saveBulk (the states of the CamelDaprStates header), get (one key), getBulk (the keys of the CamelDaprKeys header), delete (one key) or executeTransaction (the operations of the CamelDaprTransactions header in one transaction).

Enum values:

  • save

  • saveBulk

  • get

  • getBulk

  • delete

  • executeTransaction

get

StateOperation

stateStore (producer)

The name of the Dapr state store component of the state operation. Required for the state operation.

String

storeName (producer)

The name of the Dapr lock store component of the lock operation. Required for the lock operation.

String

timeout (producer)

How long the waitForInstanceStart and waitForInstanceCompletion workflow operations wait for the workflow instance to start or to complete, before they fail. Required for these operations.

Duration

verb (producer)

The HTTP method of the invokeService operation, in upper case: GET, POST, PUT, DELETE, PATCH, HEAD, CONNECT, OPTIONS or TRACE. Not used when an HttpExtension is set with the httpExtension option or the CamelDaprHttpExtension header.

POST

String

workflowClass (producer)

The fully qualified name of the workflow class to start with the scheduleNew workflow operation: a class that implements io.dapr.workflows.Workflow and is registered in the workflow runtime. Required for scheduleNew.

String

workflowClient (producer)

Autowired The DaprWorkflowClient for the workflow operation. When not set, the endpoint creates one from the Dapr properties.

DaprWorkflowClient

workflowInstanceId (producer)

The ID of the workflow instance. For scheduleNew it is the ID of the new instance, and the Dapr client generates a random UUID when it is not set; the other workflow operations require it.

String

workflowOperation (producer)

The operation of the workflow client: scheduleNew (start a new workflow instance), terminate, purge (delete the state of a completed or terminated instance), suspend, resume, state (get the state of an instance), waitForInstanceStart, waitForInstanceCompletion or raiseEvent (send an event to an instance).

Enum values:

  • scheduleNew

  • terminate

  • purge

  • suspend

  • resume

  • state

  • waitForInstanceStart

  • waitForInstanceCompletion

  • raiseEvent

scheduleNew

WorkflowOperation

workflowStartTime (producer)

The time at which the scheduleNew workflow operation starts the new workflow instance. When not set, the instance starts right away.

Instant

workflowVersion (producer)

The version of the workflow to start with the scheduleNew workflow operation.

String

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

headerFilterStrategy (advanced)

To use a custom HeaderFilterStrategy to filter header to and from Camel message.

HeaderFilterStrategy

allowSecretStoreAndKeyFromHeaders (security)

Whether to allow overriding the secret store, the key and the metadata of the endpoint with the CamelDaprSecretStore, CamelDaprKey and CamelDaprMetadata headers for the secret operation. Disabled by default; enable it only when the header source is trusted, since it lets a message choose the secret store and the secret that the secret operation reads.

false

boolean

Endpoint Options

The Dapr endpoint is configured using URI syntax:

dapr:operation

With the following path and query parameters:

Path Parameters

Name Description Default Type

operation (producer)

Required The Dapr building block to use: invokeService (service invocation), state (state management), pubSub (publish and subscribe), invokeBinding (output bindings), secret (secrets), configuration, lock (distributed lock) or workflow. The consumer supports only pubSub (subscribe to a topic) and configuration (subscribe to configuration changes).

Enum values:

  • invokeService

  • state

  • pubSub

  • invokeBinding

  • secret

  • configuration

  • lock

  • workflow

DaprOperation

Query Parameters

Name Description Default Type

client (common)

Autowired The DaprClient for service invocation, state, publishing to pub/sub, bindings, secrets and configuration (also the configuration consumer). When not set, the endpoint builds one with DaprClientBuilder, which connects to the Dapr sidecar given by the Dapr properties, such as DAPR_SIDECAR_IP and DAPR_GRPC_PORT.

DaprClient

configKeys (common)

The keys of the configuration items to get (producer) or whose changes to receive (consumer) with the configuration operation, as a comma-separated list. Required for the configuration operation.

String

configStore (common)

The name of the Dapr configuration store component of the configuration operation, to get configuration items (producer) or to subscribe to their changes (consumer).

String

contentType (common)

The content type of the event data that the pubSub producer publishes. When not set, the Dapr client uses the content type of its serializer, application/json by default.

String

previewClient (common)

Autowired The DaprPreviewClient for the lock operation and the pubSub consumer (streaming subscription to a topic). When not set, one is built with DaprClientBuilder from the Dapr properties.

DaprPreviewClient

pubSubName (common)

The name of the Dapr pub/sub component to publish to (producer) or to subscribe to (consumer) with the pubSub operation. Required for the pubSub operation.

String

topic (common)

The topic to publish to (producer) or to subscribe to (consumer) in the pub/sub component given by pubSubName. Required for the pubSub operation.

String

bridgeErrorHandler (consumer (advanced))

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

exceptionHandler (consumer (advanced))

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.

ExceptionHandler

exchangePattern (consumer (advanced))

Sets the exchange pattern when the consumer creates an exchange.

Enum values:

  • InOnly

  • InOut

ExchangePattern

bindingName (producer)

The name of the Dapr output binding component to call with the invokeBinding operation.

String

bindingOperation (producer)

The operation of the output binding to call with the invokeBinding operation, such as create, get, delete or list. The supported operations depend on the binding component.

String

concurrency (producer)

The concurrency mode of the state save, get and delete operations: FIRST_WRITE (first-write-wins) or LAST_WRITE (last-write-wins). When not set, the state store applies its default, which is last-write-wins.

Enum values:

  • FIRST_WRITE

  • LAST_WRITE

Concurrency

consistency (producer)

The consistency level of the state save, get and delete operations: EVENTUAL or STRONG. When not set, the state store applies its default, which is eventual consistency.

Enum values:

  • EVENTUAL

  • STRONG

Consistency

eTag (producer)

The ETag of the value in the state store, for optimistic concurrency of the state save and delete operations: the state store applies the change only when the ETag matches the current ETag of the value.

String

eventName (producer)

The name of the event to send to the workflow instance with the raiseEvent workflow operation. Event names are case-insensitive.

String

expiryInSeconds (producer)

The time in seconds after which the lock expires, if not unlocked before. Required for the tryLock lock operation.

Integer

getWorkflowIO (producer)

Whether the state, waitForInstanceStart and waitForInstanceCompletion workflow operations also fetch the inputs, outputs and custom status of the workflow instance.

false

boolean

httpExtension (producer)

Autowired The HttpExtension (HTTP method, query parameters and HTTP headers) of the invokeService operation. A text value is converted to the HttpExtension constant of that HTTP method, without query parameters or HTTP headers: GET, POST, PUT, DELETE, HEAD, CONNECT, OPTIONS or TRACE (any case), and NONE for any other value. When set, the verb option and the CamelDaprVerb, CamelDaprQueryParameters and CamelDaprHttpHeaders headers are not used.

HttpExtension

key (producer)

The key of the value in the state store for the state save, get and delete operations, or the name of the secret to get with the secret operation. When the secret operation has no key, it gets all the secrets of the secret store.

String

lockOperation (producer)

The operation on the distributed lock: tryLock acquires the lock (the message body is then true when acquired, false otherwise), unlock releases it.

Enum values:

  • tryLock

  • unlock

tryLock

LockOperation

lockOwner (producer)

The ID of the owner of the lock: only the owner that acquired the lock can unlock it. Required for the lock operation.

String

metadata (producer)

Additional key-value pairs to pass as metadata to the Dapr building block, such as metadata.namespace=production. Used by the state get, getBulk, delete and executeTransaction operations, pubSub, invokeBinding, secret and configuration; the state save and saveBulk, invokeService, lock and workflow operations and the consumers do not pass it. The CamelDaprMetadata header takes the place of these for one message, except for the secret operation unless allowSecretStoreAndKeyFromHeaders is enabled. This is a multi-value option with prefix: metadata.

Map

methodToInvoke (producer)

The method to call on the service with the invokeService operation: the path that follows /method/ in the Dapr invocation URL, such as orders or api/orders.

String

reason (producer)

The reason for suspending or resuming the workflow instance. Required for the suspend and resume workflow operations.

String

resourceId (producer)

The ID of the resource to lock or unlock with the lock operation. Required for the lock operation.

String

secretStore (producer)

The name of the Dapr secret store component of the secret operation. Required for the secret operation.

String

serviceToInvoke (producer)

The service to call with the invokeService operation: the app ID of a Dapr application, the name of an HTTPEndpoint resource, or the URL of a non-Dapr endpoint.

String

stateOperation (producer)

The operation on the state store: save (one key), saveBulk (the states of the CamelDaprStates header), get (one key), getBulk (the keys of the CamelDaprKeys header), delete (one key) or executeTransaction (the operations of the CamelDaprTransactions header in one transaction).

Enum values:

  • save

  • saveBulk

  • get

  • getBulk

  • delete

  • executeTransaction

get

StateOperation

stateStore (producer)

The name of the Dapr state store component of the state operation. Required for the state operation.

String

storeName (producer)

The name of the Dapr lock store component of the lock operation. Required for the lock operation.

String

timeout (producer)

How long the waitForInstanceStart and waitForInstanceCompletion workflow operations wait for the workflow instance to start or to complete, before they fail. Required for these operations.

Duration

verb (producer)

The HTTP method of the invokeService operation, in upper case: GET, POST, PUT, DELETE, PATCH, HEAD, CONNECT, OPTIONS or TRACE. Not used when an HttpExtension is set with the httpExtension option or the CamelDaprHttpExtension header.

POST

String

workflowClass (producer)

The fully qualified name of the workflow class to start with the scheduleNew workflow operation: a class that implements io.dapr.workflows.Workflow and is registered in the workflow runtime. Required for scheduleNew.

String

workflowClient (producer)

Autowired The DaprWorkflowClient for the workflow operation. When not set, the endpoint creates one from the Dapr properties.

DaprWorkflowClient

workflowInstanceId (producer)

The ID of the workflow instance. For scheduleNew it is the ID of the new instance, and the Dapr client generates a random UUID when it is not set; the other workflow operations require it.

String

workflowOperation (producer)

The operation of the workflow client: scheduleNew (start a new workflow instance), terminate, purge (delete the state of a completed or terminated instance), suspend, resume, state (get the state of an instance), waitForInstanceStart, waitForInstanceCompletion or raiseEvent (send an event to an instance).

Enum values:

  • scheduleNew

  • terminate

  • purge

  • suspend

  • resume

  • state

  • waitForInstanceStart

  • waitForInstanceCompletion

  • raiseEvent

scheduleNew

WorkflowOperation

workflowStartTime (producer)

The time at which the scheduleNew workflow operation starts the new workflow instance. When not set, the instance starts right away.

Instant

workflowVersion (producer)

The version of the workflow to start with the scheduleNew workflow operation.

String

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

headerFilterStrategy (advanced)

To use a custom HeaderFilterStrategy to filter header to and from Camel message.

HeaderFilterStrategy

allowSecretStoreAndKeyFromHeaders (security)

Whether to allow overriding the secret store, the key and the metadata of the endpoint with the CamelDaprSecretStore, CamelDaprKey and CamelDaprMetadata headers for the secret operation. Disabled by default; enable it only when the header source is trusted, since it lets a message choose the secret store and the secret that the secret operation reads.

false

boolean

Message Headers

The Dapr component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelDaprServiceToInvoke (producer)

Constant: SERVICE_TO_INVOKE

The service to call with the invokeService operation: the app ID of a Dapr application, the name of an HTTPEndpoint resource, or the URL of a non-Dapr endpoint.

String

CamelDaprMethodToInvoke (producer)

Constant: METHOD_TO_INVOKE

The method to call on the service with the invokeService operation: the path that follows /method/ in the Dapr invocation URL.

String

CamelDaprVerb (producer)

Constant: VERB

The HTTP method of the invokeService operation, in upper case, such as GET or POST. Not used when an HttpExtension is set.

String

CamelDaprQueryParameters (producer)

Constant: QUERY_PARAMETERS

The query parameters of the invokeService request. Not used when an HttpExtension is set.

Map

CamelDaprHttpHeaders (producer)

Constant: HTTP_HEADERS

The HTTP headers of the invokeService request. Not used when an HttpExtension is set.

Map

CamelDaprHttpExtension (producer)

Constant: HTTP_EXTENSION

The HttpExtension (HTTP method, query parameters and HTTP headers) of the invokeService operation. Takes precedence over the httpExtension and verb options and the CamelDaprVerb, CamelDaprQueryParameters and CamelDaprHttpHeaders headers.

HttpExtension

CamelDaprStateOperation (producer)

Constant: STATE_OPERATION

The operation on the state store, in place of the stateOperation option.

Enum values:

  • save

  • saveBulk

  • get

  • getBulk

  • delete

  • executeTransaction

get

StateOperation

CamelDaprStateStore (producer)

Constant: STATE_STORE

The name of the Dapr state store component of the state operation.

String

CamelDaprSecretStore (producer)

Constant: SECRET_STORE

The name of the Dapr secret store component of the secret operation. This header is ignored unless the endpoint enables allowSecretStoreAndKeyFromHeaders=true (disabled by default).

String

CamelDaprConfigStore (producer)

Constant: CONFIG_STORE

The name of the Dapr configuration store component of the configuration operation.

String

CamelDaprKey (producer)

Constant: KEY

The key of the value in the state store for the state save, get and delete operations, or the name of the secret to get with the secret operation. For the secret operation, this header is ignored unless the endpoint enables allowSecretStoreAndKeyFromHeaders=true (disabled by default).

String

CamelDaprETag (producer)

Constant: E_TAG

The ETag of the value in the state store, for optimistic concurrency of the state save and delete operations.

String

CamelDaprConcurrency (producer)

Constant: CONCURRENCY

The concurrency mode of the state save, get and delete operations: FIRST_WRITE or LAST_WRITE.

Enum values:

  • FIRST_WRITE

  • LAST_WRITE

Concurrency

CamelDaprConsistency (producer)

Constant: CONSISTENCY

The consistency level of the state save, get and delete operations: EVENTUAL or STRONG.

Enum values:

  • EVENTUAL

  • STRONG

Consistency

CamelDaprMetadata (producer)

Constant: METADATA

Additional key-value pairs to be passed to the Dapr building block, in place of the metadata option. For the secret operation, this header is ignored unless the endpoint enables allowSecretStoreAndKeyFromHeaders=true (disabled by default).

Map

CamelDaprStates (producer)

Constant: STATES

The states (key, value and optional ETag and options of each) to save with the state saveBulk operation. Required for saveBulk.

List

CamelDaprKeys (producer)

Constant: KEYS

The keys of the values to get with the state getBulk operation. Required for getBulk.

List

CamelDaprTransactions (producer)

Constant: TRANSACTIONS

The operations (upsert or delete) to run in one transaction with the state executeTransaction operation. Required for executeTransaction.

List

CamelDaprPubSubName (common)

Constant: PUBSUB_NAME

The name of the Dapr pub/sub component to publish to with the pubSub operation.

String

CamelDaprTopic (common)

Constant: TOPIC

The topic to publish to with the pubSub operation.

String

CamelDaprContentType (common)

Constant: CONTENT_TYPE

The content type of the event data that the pubSub operation publishes.

String

CamelDaprID (consumer)

Constant: ID

The ID of the received CloudEvent.

String

CamelDaprSource (consumer)

Constant: SOURCE

The source of the received CloudEvent: a URI that identifies the application that published the event.

String

CamelDaprType (consumer)

Constant: TYPE

The type of the received CloudEvent.

String

CamelDaprSpecificVersion (consumer)

Constant: SPECIFIC_VERSION

The version of the CloudEvents specification of the received event (specversion).

String

CamelDaprDataContentType (consumer)

Constant: DATA_CONTENT_TYPE

The content type of the data of the received CloudEvent (datacontenttype).

String

CamelDaprBinaryData (consumer)

Constant: BINARY_DATA

The binary data of the received CloudEvent (data_base64), if any.

byte[]

CamelDaprTime (consumer)

Constant: TIME

The time at which the received CloudEvent occurred.

OffsetDateTime

CamelDaprTraceParent (consumer)

Constant: TRACE_PARENT

The W3C traceparent of the received CloudEvent, with the trace ID and the span ID.

String

CamelDaprTraceState (consumer)

Constant: TRACE_STATE

The W3C tracestate of the received CloudEvent, with vendor-specific trace context.

String

CamelDaprBindingName (producer)

Constant: BINDING_NAME

The name of the Dapr output binding component to call with the invokeBinding operation.

String

CamelDaprBindingOperation (producer)

Constant: BINDING_OPERATION

The operation of the output binding to call with the invokeBinding operation, such as create, get, delete or list.

String

CamelDaprConfigKeys (producer)

Constant: CONFIG_KEYS

The keys of the configuration items to get with the configuration operation, as a comma-separated String or a Collection of keys.

String

CamelDaprSubscriptionId (consumer)

Constant: SUBSCRIPTION_ID

The ID of the subscription to configuration changes that received the change.

String

CamelDaprRawConfigResponse (common)

Constant: RAW_CONFIG_RESPONSE

The ConfigurationItem (value, version and metadata) of each key, as received from Dapr: the items read by the configuration producer, or the items changed for the configuration consumer.

ConfigurationItem

CamelDaprLockOperation (producer)

Constant: LOCK_OPERATION

The operation on the distributed lock, in place of the lockOperation option.

Enum values:

  • tryLock

  • unlock

tryLock

LockOperation

CamelDaprStoreName (producer)

Constant: STORE_NAME

The name of the Dapr lock store component of the lock operation.

String

CamelDaprResourceId (producer)

Constant: RESOURCE_ID

The ID of the resource to lock or unlock with the lock operation.

String

CamelDaprLockOwner (producer)

Constant: LOCK_OWNER

The ID of the owner of the lock: only the owner that acquired the lock can unlock it.

String

CamelDaprExpiryInSeconds (producer)

Constant: EXPIRY_IN_SECONDS

The time in seconds after which the lock expires, if not unlocked before. Required for tryLock.

Integer

CamelDaprWorkflowOperation (producer)

Constant: WORKFLOW_OPERATION

The operation of the workflow client, in place of the workflowOperation option.

Enum values:

  • scheduleNew

  • terminate

  • purge

  • suspend

  • resume

  • state

  • waitForInstanceStart

  • waitForInstanceCompletion

  • raiseEvent

scheduleNew

WorkflowOperation

CamelDaprWorkflowClass (producer)

Constant: WORKFLOW_CLASS

The fully qualified name of the workflow class to start with the scheduleNew workflow operation: a class that implements io.dapr.workflows.Workflow.

String

CamelDaprWorkflowVersion (producer)

Constant: WORKFLOW_VERSION

The version of the workflow to start with the scheduleNew workflow operation.

String

CamelDaprWorkflowInstanceId (producer)

Constant: WORKFLOW_INSTANCE_ID

The ID of the workflow instance of the workflow operation. The terminate, purge, suspend, resume and raiseEvent operations also set it on the result.

String

CamelDaprWorkflowStartTime (producer)

Constant: WORKFLOW_START_TIME

The time at which the scheduleNew workflow operation starts the new workflow instance.

Instant

CamelDaprSuspendReason (producer)

Constant: REASON

The reason for suspending or resuming the workflow instance. The suspend and resume operations also set it on the result.

String

CamelDaprNewWorkflowInstanceId (producer)

Constant: NEW_WORKFLOW_INSTANCE_ID

The ID of the workflow instance that the scheduleNew workflow operation started.

String

CamelDaprGetWorkflowIO (producer)

Constant: GET_WORKFLOW_IO

Whether the state, waitForInstanceStart and waitForInstanceCompletion workflow operations also fetch the inputs, outputs and custom status of the workflow instance.

boolean

CamelDaprWorkflowName (producer)

Constant: WORKFLOW_NAME

The name of the workflow, set by the state, waitForInstanceStart and waitForInstanceCompletion workflow operations.

String

CamelDaprWorkflowCreatedAt (producer)

Constant: WORKFLOW_CREATED_AT

The time in UTC at which the workflow instance was created, set by the state and wait workflow operations.

Instant

CamelDaprWorkflowUpdatedAt (producer)

Constant: WORKFLOW_UPDATED_AT

The time in UTC at which the workflow instance was last updated, set by the state and wait workflow operations.

Instant

CamelDaprWorkflowSerializedInput (producer)

Constant: WORKFLOW_SERIALIZED_INPUT

The serialized input of the workflow instance, if any, set by the state and wait workflow operations when the inputs and outputs are fetched.

String

CamelDaprWorkflowSerializedOutput (producer)

Constant: WORKFLOW_SERIALIZED_OUTPUT

The serialized output of the workflow instance, if any, set by the state and wait workflow operations when the inputs and outputs are fetched.

String

CamelDaprWorkflowFailureDetails (producer)

Constant: WORKFLOW_FAILURE_DETAILS

The failure details of the workflow instance when it failed, otherwise null, set by the state and wait workflow operations.

WorkflowFailureDetails

CamelDaprIsWorkflowRunning (producer)

Constant: IS_WORKFLOW_RUNNING

Whether the workflow instance exists and is running, set by the state and wait workflow operations.

boolean

CamelDaprIsWorkflowCompleted (producer)

Constant: IS_WORKFLOW_COMPLETED

Whether the workflow instance is in a terminal state (completed, failed or terminated), set by the state and wait workflow operations.

boolean

CamelDaprTimeout (producer)

Constant: TIMEOUT

How long the waitForInstanceStart and waitForInstanceCompletion workflow operations wait for the workflow instance to start or to complete, before they fail.

Duration

CamelDaprEventName (producer)

Constant: EVENT_NAME

The name of the event to send to the workflow instance with the raiseEvent workflow operation. Event names are case-insensitive. The raiseEvent operation also sets it on the result.

String

Message Body

The message body at each side of the Dapr component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Consumer

bytes or map

For pubSub the data of the cloud event as bytes, with its id, type, source and content type in headers. For configuration a Map of the changed keys and their values, with the ConfigurationItems in the CamelDaprRawConfigResponse header.

  • With operation=pubSub: bytes (byte[])

  • With operation=configuration: map (java.util.Map<java.lang.String, java.lang.String>)

Producer input

text, bytes, stream, value, map, list, pojo or null

The data of invokeService, pubSub, invokeBinding, state save and the workflow input, event and output. For invokeService, pubSub, invokeBinding and state save, text and streams are converted to bytes, bytes are sent as they are, and other bodies are serialized as JSON. The workflow operations give the body to the workflow client as is, which serializes it as JSON, so a stream fails there: convert it first. State save needs a body; the other operations do not read it.

Producer output

bytes, pojo, list, map, value, unchanged or null

The response as bytes for invokeService and invokeBinding (null when there is none), the PublishEventRequest for pubSub, the State for state get and save, a List of State for getBulk and the request for the other state operations, a Map for secret and configuration, true or false for tryLock and the UnlockResponseStatus for unlock. For workflow the NewWorkflowOptions for scheduleNew, the WorkflowState for state and the waits, unchanged for terminate and raiseEvent, and null otherwise.

  • With operation=invokeService: bytes or null

  • With operation=invokeBinding: bytes or null

  • With operation=pubSub: pojo (io.dapr.client.domain.PublishEventRequest)

  • With operation=state: pojo or list

  • With operation=secret: map

  • With operation=configuration: map (java.util.Map<java.lang.String, java.lang.String>)

  • With operation=lock: value

  • With operation=workflow: pojo, unchanged or null

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Dapr Producer operations

Camel Dapr component provides a wide range of operations on the producer side:

The producer keeps the headers of the message, and adds the headers of the Dapr response, such as CamelDaprRawConfigResponse for the configuration operation.

The invokeService, pubSub, invokeBinding and state save operations send the message body as the data: a text or stream body is converted to bytes and sent as it is, bytes are sent as they are, and other bodies, such as a Map or a POJO, are serialized as JSON. For pubSub, set the content type of the data with the contentType option or the CamelDaprContentType header.

1. invokeService:

Using service invocation, your application can reliably and securely communicate with other applications using the standard HTTP protocol. For this operation serviceToInvoke and methodToInvoke are mandatory.

2. state:

State management in Dapr allows your application to save, get and delete key-value pairs in a reliable and consistent way. For these operations stateStore is required.

State Operations

Operation Description

save

Store or update a single key-value pair in the state store. For this operation payload and key are required.

saveBulk

Store or update multiple key-value pairs in the state store in a single operation. For this operation (List<State<?>>) states is a required field.

get

Retrieve the value of a specific key from the state store. For this operation key is a required field.

getBulk

Retrieve values for multiple keys from the state store in a single request. For this operation (List<String>) keys is a required field.

delete

Remove a specific key and its associated value from the state store. For this operation key is a required field.

executeTransaction

Execute a batch of operations (save or delete) atomically within a transaction. For this operation (List<TransactionalStateOperation<?>>) transactions is a required field.

2. pubSub:

Dapr’s publish-subscribe (Pub/Sub) building block enables asynchronous, event-driven communication between microservices. For this operation, the pubSubName and topic are required.

3. invokeBinding:

Dapr’s bindings building block allows interaction with external systems via input/output bindings. The invokeBinding operation enables sending data to a configured output binding. This operation requires specifying the bindingName (the name of the binding component) and the bindingOperation (such as create, get, or delete, depending on the binding’s capabilities).

4. secret:

Dapr’s secret management building block enables secure retrieval of secrets from external secret stores. The secret operation fetches a secret from the specified secret store. If a key is provided, the operation retrieves the corresponding secret; if no key is specified, a bulk retrieval of all secrets from the store is performed. This operation requires the secretStore name, and optionally the key.

The secret operation takes the secret store, the key and the metadata from the secretStore, key and metadata options of the endpoint, unless the endpoint sets allowSecretStoreAndKeyFromHeaders=true: only then do the CamelDaprSecretStore, CamelDaprKey and CamelDaprMetadata headers take their place. An endpoint without a key fails, instead of reading all the secrets of the store, when the message has a CamelDaprKey header that it ignores.

5. configuration:

Dapr’s configuration building block allows applications to retrieve dynamic configuration values from external configuration stores. The configuration operation fetches values associated with keys specified in configKeys. This operation requires the configStore name, and the configKeys.

6. lock:

Lock management in Dapr allows your application to coordinate access to shared resources using a distributed lock mechanism. This is useful for ensuring mutual exclusion across services. For these operations, storeName, resourceId and lockOwner are mandatory.

Lock Operations

Operation Description

tryLock

Attempts to acquire a lock on a resource for a specific duration. For this operation expiryInSeconds is required. Returns a Boolean – true if the lock was successfully acquired, false otherwise.

unlock

Releases a previously acquired lock. Returns an UnlockResponseStatus enum indicating whether the lock was successfully released.

7. workflow:

Dapr Workflows enable developers to write long-running, persistent, and reliable processes as code. Dapr Workflow simplifies complex, stateful coordination requirements in microservice architectures.

Workflow Operations

Operation Description

scheduleNew

Schedules a new workflow instance to be created. Requires workflowClass and optional workflowVersion, workflowInstanceId, workflowStartTime. The message body is used as the workflow input.

terminate

Terminates a running workflow instance. Requires workflowInstanceId. The message body can be used to provide an output for the terminated workflow.

purge

Purges the metadata of a workflow instance from the state store. Requires workflowInstanceId.

suspend

Suspends a running workflow instance. Requires workflowInstanceId and a reason.

resume

Resumes a suspended workflow instance. Requires workflowInstanceId and a reason.

state

Gets the current runtime state of a workflow instance. Requires workflowInstanceId.

waitForInstanceStart

Waits for a workflow instance to start running. Requires workflowInstanceId and a timeout.

waitForInstanceCompletion

Waits for a workflow instance to complete. Requires workflowInstanceId and a timeout.

raiseEvent

Sends an event to a running workflow instance that is waiting for it. Requires workflowInstanceId and eventName. The message body is used as the event payload.

Headers that override the endpoint

The producer headers, such as CamelDaprServiceToInvoke, CamelDaprStateStore, CamelDaprKey, CamelDaprMetadata, CamelDaprPubSubName, CamelDaprTopic, CamelDaprBindingName, CamelDaprStoreName or CamelDaprWorkflowInstanceId, take the place of the endpoint option of the same name for one message.

The metadata that an operation sends to the Dapr building block is set on the endpoint with metadata. options, such as metadata.ttlInSeconds=60 for pubSub, or for one message with the CamelDaprMetadata header (a Map<String, String>).

For the secret operation, the CamelDaprSecretStore, CamelDaprKey and CamelDaprMetadata headers are ignored unless the endpoint sets allowSecretStoreAndKeyFromHeaders=true. With that option, they take the place of the secret store, the key and the metadata of the endpoint for one message, so the message chooses the secret that the operation reads.

As the producer keeps the headers of the message, a CamelDapr* header also applies to the next dapr call of the route. When the messages come from an untrusted producer through a consumer that does not filter out Camel* headers, or when a dapr call must use only the options of its endpoint, remove these headers with removeHeaders("CamelDapr*") before the dapr endpoint.

Dapr Consumer operations

1. pubSub:

The Dapr PubSub Consumer in Apache Camel allows your route to consume events from a Dapr-supported Pub/Sub system. It subscribes to a specified topic on a given pubsub component (pubSubName) and processes incoming CloudEvents as Camel Exchange objects.

To configure a consumer, the pubSubName and topic must be provided. Alternatively, a preconfigured DaprPreviewClient can be registered in the Camel registry to allow the consumer to reuse it instead of creating a new one internally.

When the stream of the subscription to the Dapr sidecar fails, for example because the sidecar restarts, the consumer subscribes again, first after one second and then with a delay that doubles up to 30 seconds while the sidecar cannot be reached. The delay starts again at one second once an event is received.

2. configuration:

The Dapr Configuration Consumer in Apache Camel allows your route to receive real-time updates from a Dapr-supported configuration store. It listens for changes to specified keys in the configuration store and processes the updates as Camel Exchange objects.

To configure the consumer, the configStore name and configKeys must be provided.

When the subscription ends, for example because the Dapr sidecar restarts, the consumer subscribes again, first after one second and then with a growing delay of up to 30 seconds while the sidecar cannot be reached. A change made to the configuration store while the consumer is not subscribed is not delivered.

Examples

Producer Operations Examples

  • invokeService -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprVerb", constant("GET"))
    .to("dapr:invokeService?serviceToInvoke=myService&methodToInvoke=myMethod")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprVerb">
    <constant>GET</constant>
  </setHeader>
  <to uri="dapr:invokeService?serviceToInvoke=myService&amp;methodToInvoke=myMethod"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprVerb
            constant: "GET"
        - to:
            uri: dapr:invokeService
            parameters:
              serviceToInvoke: myService
              methodToInvoke: myMethod
        - to:
            uri: mock:result
  • state: save -

  • Java

  • XML

  • YAML

from("direct:start")
    .setBody(constant("myValue"))
    .to("dapr:state?stateOperation=save&stateStore=myStore&key=myKey")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setBody>
    <constant>myValue</constant>
  </setBody>
  <to uri="dapr:state?stateOperation=save&amp;stateStore=myStore&amp;key=myKey"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setBody:
            constant: "myValue"
        - to:
            uri: dapr:state
            parameters:
              stateOperation: save
              stateStore: myStore
              key: myKey
        - to:
            uri: mock:result
  • state: saveBulk -

Java-only: uses Dapr SDK State types and List.of() to set bulk states
from("direct:start")
    .process(exchange -> {
        State<String> state1 = new State<>("key1", "val1", "etag1");
        State<String> state2 = new State<>("key2", "val1", "etag2");
        List<State<?>> states = List.of(state1, state2);
        exchange.getMessage().setHeader("CamelDaprStates", states);
    })
    .to("dapr:state?stateOperation=saveBulk&stateStore=myStore")
    .to("mock:result");
  • state: get -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprConcurrency", constant("FIRST_WRITE"))
    .setHeader("CamelDaprConsistency", constant("EVENTUAL"))
    .to("dapr:state?stateOperation=get&stateStore=myStore&key=myKey")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprConcurrency">
    <constant>FIRST_WRITE</constant>
  </setHeader>
  <setHeader name="CamelDaprConsistency">
    <constant>EVENTUAL</constant>
  </setHeader>
  <to uri="dapr:state?stateOperation=get&amp;stateStore=myStore&amp;key=myKey"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprConcurrency
            constant: "FIRST_WRITE"
        - setHeader:
            name: CamelDaprConsistency
            constant: "EVENTUAL"
        - to:
            uri: dapr:state
            parameters:
              stateOperation: get
              stateStore: myStore
              key: myKey
        - to:
            uri: mock:result
  • state: getBulk -

Java-only: uses List.of() to set bulk key list
from("direct:start")
    .process(exchange -> {
        exchange.getIn().setHeader("CamelDaprKeys", List.of("key1", "key2"));
    })
    .to("dapr:state?stateOperation=getBulk&stateStore=myStore")
    .to("mock:result");
  • state: delete -

Java-only: uses Map.of() to set metadata
from("direct:start")
    .process(exchange -> {
        exchange.getIn().setHeader("CamelDaprMetadata", Map.of("partitionKey", "myPartitionKey"));
    })
    .to("dapr:state?stateOperation=delete&stateStore=myStore&key=myKey")
    .to("mock:result");
  • state: executeTransaction -

Java-only: uses Dapr SDK TransactionalStateOperation and State types
from("direct:start")
    .process(exchange -> {
        TransactionalStateOperation.OperationType op = TransactionalStateOperation.OperationType.UPSERT;
        List<TransactionalStateOperation<?>> transactions = List.of(new TransactionalStateOperation<>(op, new State<>("myKey")));
        exchange.getIn().setHeader("CamelDaprTransactions", transactions);
    })
    .to("dapr:state?stateOperation=executeTransaction&stateStore=myStore")
    .to("mock:result");
  • pubSub -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprContentType", constant("application/json"))
    .to("dapr:pubSub?pubSubName=myPubSub&topic=myTopic")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprContentType">
    <constant>application/json</constant>
  </setHeader>
  <to uri="dapr:pubSub?pubSubName=myPubSub&amp;topic=myTopic"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprContentType
            constant: "application/json"
        - to:
            uri: dapr:pubSub
            parameters:
              pubSubName: myPubSub
              topic: myTopic
        - to:
            uri: mock:result
  • invokeBinding -

  • Java

  • XML

  • YAML

from("direct:start")
    .setBody(constant("myBody"))
    .to("dapr:invokeBinding?bindingName=myBinding&bindingOperation=myOperation")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setBody>
    <constant>myBody</constant>
  </setBody>
  <to uri="dapr:invokeBinding?bindingName=myBinding&amp;bindingOperation=myOperation"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setBody:
            constant: "myBody"
        - to:
            uri: dapr:invokeBinding
            parameters:
              bindingName: myBinding
              bindingOperation: myOperation
        - to:
            uri: mock:result
  • secret -

  • Java

  • XML

  • YAML

from("direct:start")
  .to("dapr:secret?secretStore=myStore&key=mySecret")
  .log("Received secret mySecret from Dapr")
  .to("mock:result");
<route>
  <from uri="direct:start"/>
  <to uri="dapr:secret?secretStore=myStore&amp;key=mySecret"/>
  <log message="Received secret mySecret from Dapr"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - to:
            uri: dapr:secret
            parameters:
              secretStore: myStore
              key: mySecret
        - log: "Received secret mySecret from Dapr"
        - to:
            uri: mock:result
  • secret: bulk -

  • Java

  • XML

  • YAML

from("direct:start")
  // when no secret key is passed, bulk retrieval is performed on secret store
  .to("dapr:secret?secretStore=myStore")
  .log("Received ${body.size()} secrets from Dapr")
  .to("mock:result");
<route>
  <from uri="direct:start"/>
  <to uri="dapr:secret?secretStore=myStore"/>
  <log message="Received ${body.size()} secrets from Dapr"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - to:
            uri: dapr:secret
            parameters:
              secretStore: myStore
        - log: "Received ${body.size()} secrets from Dapr"
        - to:
            uri: mock:result
  • configuration -

The CamelDaprConfigKeys header takes the place of the configKeys option. It is a comma-separated String or a Collection of keys.

  • Java

  • XML

  • YAML

from("direct:start")
  .setHeader("CamelDaprConfigKeys", constant("k1,k2"))
  .to("dapr:configuration?configStore=myStore")
  .log("Received config updates from Dapr: ${body}")
  .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprConfigKeys">
    <constant>k1,k2</constant>
  </setHeader>
  <to uri="dapr:configuration?configStore=myStore"/>
  <log message="Received config updates from Dapr: ${body}"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprConfigKeys
            constant: "k1,k2"
        - to:
            uri: dapr:configuration
            parameters:
              configStore: myStore
        - log: "Received config updates from Dapr: ${body}"
        - to:
            uri: mock:result
  • lock: tryLock -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprResourceId", constant("myResource"))
    .to("dapr:lock?lockOperation=tryLock&storeName=myStore&expiryInSeconds=100")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprResourceId">
    <constant>myResource</constant>
  </setHeader>
  <to uri="dapr:lock?lockOperation=tryLock&amp;storeName=myStore&amp;expiryInSeconds=100"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprResourceId
            constant: "myResource"
        - to:
            uri: dapr:lock
            parameters:
              lockOperation: tryLock
              storeName: myStore
              expiryInSeconds: 100
        - to:
            uri: mock:result
  • lock: unlock -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprResourceId", constant("myResource"))
    .to("dapr:lock?lockOperation=unlock&storeName=myStore")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprResourceId">
    <constant>myResource</constant>
  </setHeader>
  <to uri="dapr:lock?lockOperation=unlock&amp;storeName=myStore"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprResourceId
            constant: "myResource"
        - to:
            uri: dapr:lock
            parameters:
              lockOperation: unlock
              storeName: myStore
        - to:
            uri: mock:result
  • workflow: scheduleNew -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprWorkflowClass", constant("my.package.MyWorkflow"))
    .to("dapr:workflow?workflowOperation=scheduleNew")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprWorkflowClass">
    <constant>my.package.MyWorkflow</constant>
  </setHeader>
  <to uri="dapr:workflow?workflowOperation=scheduleNew"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprWorkflowClass
            constant: "my.package.MyWorkflow"
        - to:
            uri: dapr:workflow
            parameters:
              workflowOperation: scheduleNew
        - to:
            uri: mock:result
  • workflow: terminate -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprWorkflowInstanceId", constant("myWorkflowInstanceId"))
    .to("dapr:workflow?workflowOperation=terminate")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprWorkflowInstanceId">
    <constant>myWorkflowInstanceId</constant>
  </setHeader>
  <to uri="dapr:workflow?workflowOperation=terminate"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprWorkflowInstanceId
            constant: "myWorkflowInstanceId"
        - to:
            uri: dapr:workflow
            parameters:
              workflowOperation: terminate
        - to:
            uri: mock:result
  • workflow: purge -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprWorkflowInstanceId", constant("myWorkflowInstanceId"))
    .to("dapr:workflow?workflowOperation=purge")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprWorkflowInstanceId">
    <constant>myWorkflowInstanceId</constant>
  </setHeader>
  <to uri="dapr:workflow?workflowOperation=purge"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprWorkflowInstanceId
            constant: "myWorkflowInstanceId"
        - to:
            uri: dapr:workflow
            parameters:
              workflowOperation: purge
        - to:
            uri: mock:result
  • workflow: suspend -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprWorkflowInstanceId", constant("myWorkflowInstanceId"))
    .setHeader("CamelDaprSuspendReason", constant("Suspended for maintenance."))
    .to("dapr:workflow?workflowOperation=suspend")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprWorkflowInstanceId">
    <constant>myWorkflowInstanceId</constant>
  </setHeader>
  <setHeader name="CamelDaprSuspendReason">
    <constant>Suspended for maintenance.</constant>
  </setHeader>
  <to uri="dapr:workflow?workflowOperation=suspend"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprWorkflowInstanceId
            constant: "myWorkflowInstanceId"
        - setHeader:
            name: CamelDaprSuspendReason
            constant: "Suspended for maintenance."
        - to:
            uri: dapr:workflow
            parameters:
              workflowOperation: suspend
        - to:
            uri: mock:result
  • workflow: resume -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprWorkflowInstanceId", constant("myWorkflowInstanceId"))
    .setHeader("CamelDaprSuspendReason", constant("Maintenance complete."))
    .to("dapr:workflow?workflowOperation=resume")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprWorkflowInstanceId">
    <constant>myWorkflowInstanceId</constant>
  </setHeader>
  <setHeader name="CamelDaprSuspendReason">
    <constant>Maintenance complete.</constant>
  </setHeader>
  <to uri="dapr:workflow?workflowOperation=resume"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprWorkflowInstanceId
            constant: "myWorkflowInstanceId"
        - setHeader:
            name: CamelDaprSuspendReason
            constant: "Maintenance complete."
        - to:
            uri: dapr:workflow
            parameters:
              workflowOperation: resume
        - to:
            uri: mock:result
  • workflow: state -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprWorkflowInstanceId", constant("myWorkflowInstanceId"))
    .to("dapr:workflow?workflowOperation=state")
    .log("Workflow state: ${body}")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprWorkflowInstanceId">
    <constant>myWorkflowInstanceId</constant>
  </setHeader>
  <to uri="dapr:workflow?workflowOperation=state"/>
  <log message="Workflow state: ${body}"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprWorkflowInstanceId
            constant: "myWorkflowInstanceId"
        - to:
            uri: dapr:workflow
            parameters:
              workflowOperation: state
        - log:
            message: "Workflow state: ${body}"
        - to:
            uri: mock:result
  • workflow: waitForInstanceStart -

Java-only: uses Duration.ofSeconds() to set timeout
from("direct:start")
    .process(exchange -> {
        exchange.getIn().setHeader("CamelDaprWorkflowInstanceId", "myWorkflowInstanceId");
        exchange.getIn().setHeader("CamelDaprTimeout", Duration.ofSeconds(30));
    })
    .to("dapr:workflow?workflowOperation=waitForInstanceStart")
    .to("mock:result");
  • workflow: waitForInstanceCompletion -

Java-only: uses Duration.ofSeconds() to set timeout
from("direct:start")
    .process(exchange -> {
        exchange.getIn().setHeader("CamelDaprWorkflowInstanceId", "myWorkflowInstanceId");
        exchange.getIn().setHeader("CamelDaprTimeout", Duration.ofSeconds(30));
    })
    .to("dapr:workflow?workflowOperation=waitForInstanceCompletion")
    .to("mock:result");
  • workflow: raiseEvent -

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader("CamelDaprWorkflowInstanceId", constant("myWorkflowInstanceId"))
    .to("dapr:workflow?workflowOperation=raiseEvent&eventName=MyEvent")
    .to("mock:result");
<route>
  <from uri="direct:start"/>
  <setHeader name="CamelDaprWorkflowInstanceId">
    <constant>myWorkflowInstanceId</constant>
  </setHeader>
  <to uri="dapr:workflow?workflowOperation=raiseEvent&amp;eventName=MyEvent"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelDaprWorkflowInstanceId
            constant: "myWorkflowInstanceId"
        - to:
            uri: dapr:workflow
            parameters:
              workflowOperation: raiseEvent
              eventName: MyEvent
        - to:
            uri: mock:result

Consumer Operations Examples

  • pubSub -

  • Java

  • XML

  • YAML

from("dapr:pubSub?pubSubName=myPubSub&topic=myTopic")
  .log("Received message from Dapr pubsub: ${body}")
  .to("mock:result");
<route>
  <from uri="dapr:pubSub?pubSubName=myPubSub&amp;topic=myTopic"/>
  <log message="Received message from Dapr pubsub: ${body}"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: dapr:pubSub
      parameters:
        pubSubName: myPubSub
        topic: myTopic
      steps:
        - log: "Received message from Dapr pubsub: ${body}"
        - to:
            uri: mock:result
  • configuration -

  • Java

  • XML

  • YAML

from("dapr:configuration?configStore=myStore&configKeys=k1,k2")
  .log("Received config updates from Dapr: ${body}")
  .to("mock:result");
<route>
  <from uri="dapr:configuration?configStore=myStore&amp;configKeys=k1,k2"/>
  <log message="Received config updates from Dapr: ${body}"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: dapr:configuration
      parameters:
        configStore: myStore
        configKeys: "k1,k2"
      steps:
        - log: "Received config updates from Dapr: ${body}"
        - to:
            uri: mock:result