public abstract class AbstractCamelWorkItemHandler
extends org.jbpm.process.workitem.core.AbstractLogOrThrowWorkItemHandler
implements org.kie.internal.runtime.Cacheable
WorkItemHandler
which allows to call Camel routes with a direct
endpoint.
The handler passes the to the route that has a consumer on the endpoint-id that can be passed with the
CamelEndpointId
WorkItem
parameter. E.g. when a the value "myCamelEndpoint" is passed to the {link WorkItem} via the
CamelEndpointId
parameter, this command will send the WorkItem
to the Camel URI
direct:myCamelEndpoint
.
The body of the result Message
of the invocation is returned via the Response
parameter. Access to the raw response
Message
is provided via the Message
parameter. This gives the user access to more advanced fields like message
headers and attachments.
The handler can be configured to always wrap exceptions coming from Camel in a WorkItemHandlerRuntimeException
. This is the default behaviour, but
can also be explicitly configured by setting the HandleExceptions
workitem parameter to true
/ When
the HandleExceptions
workitem parameter is set to false
, any exceptions coming from the Camel route will simply be
re-thrown. This makes the Camel route's exception handling logic responsible for correctly handling any exceptions.
This handler can be constructed in multiple ways. When you don't pass a RuntimeManager
to the constructor, the handler will try
to find the global KIE CamelContext
from the jBPM
ServiceRegistry
. When the RuntimeManager
is passed
to the constructor, the handler will retrieve and use the CamelContext
bound to the RuntimeManage
from the
ServiceRegistry
. When a CamelEndpointId
is passed to the constructor, the handler will send all requests to the
Camel route that is consuming from that endpoint, unless the endpoint is overridden by passing a the CamelEndpointId
in the
WorkItem
parameters.Constructor and Description |
---|
AbstractCamelWorkItemHandler()
Default Constructor.
|
AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager)
Constructor which accepts
RuntimeManager . |
AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager,
String camelEndpointId) |
AbstractCamelWorkItemHandler(String camelEndointId) |
Modifier and Type | Method and Description |
---|---|
void |
abortWorkItem(org.kie.api.runtime.process.WorkItem workItem,
org.kie.api.runtime.process.WorkItemManager manager) |
protected abstract org.apache.camel.Exchange |
buildExchange(org.apache.camel.ProducerTemplate template,
org.kie.api.runtime.process.WorkItem workItem) |
void |
close() |
void |
executeWorkItem(org.kie.api.runtime.process.WorkItem workItem,
org.kie.api.runtime.process.WorkItemManager manager) |
protected String |
getCamelEndpointId(org.kie.api.runtime.process.WorkItem workItem) |
protected abstract void |
handleResponse(org.apache.camel.Exchange responseExchange,
org.kie.api.runtime.process.WorkItem workItem,
org.kie.api.runtime.process.WorkItemManager manager) |
public AbstractCamelWorkItemHandler()
ProducerTemplate
for the global CamelContext
.public AbstractCamelWorkItemHandler(String camelEndointId)
public AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager)
RuntimeManager
. This causes this WorkItemHanlder to create a ProducerTemplate
for the
runtime specific CamelContext
.public AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager, String camelEndpointId)
public void executeWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
executeWorkItem
in interface org.kie.api.runtime.process.WorkItemHandler
protected String getCamelEndpointId(org.kie.api.runtime.process.WorkItem workItem)
protected abstract void handleResponse(org.apache.camel.Exchange responseExchange, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
protected abstract org.apache.camel.Exchange buildExchange(org.apache.camel.ProducerTemplate template, org.kie.api.runtime.process.WorkItem workItem)
public void abortWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
abortWorkItem
in interface org.kie.api.runtime.process.WorkItemHandler
public void close()
close
in interface org.kie.internal.runtime.Cacheable
Apache Camel