Class AbstractCamelWorkItemHandler
- java.lang.Object
-
- org.jbpm.process.workitem.core.AbstractLogOrThrowWorkItemHandler
-
- org.apache.camel.component.jbpm.workitem.AbstractCamelWorkItemHandler
-
- All Implemented Interfaces:
org.kie.api.runtime.process.WorkItemHandler
,org.kie.internal.runtime.Cacheable
- Direct Known Subclasses:
InOnlyCamelWorkItemHandler
,InOutCamelWorkItemHandler
public abstract class AbstractCamelWorkItemHandler extends org.jbpm.process.workitem.core.AbstractLogOrThrowWorkItemHandler implements org.kie.internal.runtime.Cacheable
Camel jBPMWorkItemHandler
which allows to call Camel routes with adirect
endpoint. The handler passes the to the route that has a consumer on the endpoint-id that can be passed with theCamelEndpointId
WorkItem
parameter. E.g. when a the value "myCamelEndpoint" is passed to the {link WorkItem} via theCamelEndpointId
parameter, this command will send theWorkItem
to the Camel URIdirect:myCamelEndpoint
. The body of the resultMessage
of the invocation is returned via theResponse
parameter. Access to the raw responseMessage
is provided via theMessage
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 aWorkItemHandlerRuntimeException
. This is the default behaviour, but can also be explicitly configured by setting theHandleExceptions
workitem parameter totrue
/ When theHandleExceptions
workitem parameter is set tofalse
, 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 aRuntimeManager
to the constructor, the handler will try to find the global KIECamelContext
from thejBPM
ServiceRegistry
. When theRuntimeManager
is passed to the constructor, the handler will retrieve and use theCamelContext
bound to theRuntimeManage
from theServiceRegistry
. When aCamelEndpointId
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 theCamelEndpointId
in theWorkItem
parameters.
-
-
Constructor Summary
Constructors Constructor Description AbstractCamelWorkItemHandler()
Default Constructor.AbstractCamelWorkItemHandler(String camelEndointId)
AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager)
Constructor which acceptsRuntimeManager
.AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager, String camelEndpointId)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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)
-
-
-
Constructor Detail
-
AbstractCamelWorkItemHandler
public AbstractCamelWorkItemHandler()
Default Constructor. This creates aProducerTemplate
for the globalCamelContext
.
-
AbstractCamelWorkItemHandler
public AbstractCamelWorkItemHandler(String camelEndointId)
-
AbstractCamelWorkItemHandler
public AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager)
Constructor which acceptsRuntimeManager
. This causes this WorkItemHanlder to create aProducerTemplate
for the runtime specificCamelContext
.
-
AbstractCamelWorkItemHandler
public AbstractCamelWorkItemHandler(org.kie.api.runtime.manager.RuntimeManager runtimeManager, String camelEndpointId)
-
-
Method Detail
-
executeWorkItem
public void executeWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
- Specified by:
executeWorkItem
in interfaceorg.kie.api.runtime.process.WorkItemHandler
-
getCamelEndpointId
protected String getCamelEndpointId(org.kie.api.runtime.process.WorkItem workItem)
-
handleResponse
protected abstract void handleResponse(org.apache.camel.Exchange responseExchange, org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
-
buildExchange
protected abstract org.apache.camel.Exchange buildExchange(org.apache.camel.ProducerTemplate template, org.kie.api.runtime.process.WorkItem workItem)
-
abortWorkItem
public void abortWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
- Specified by:
abortWorkItem
in interfaceorg.kie.api.runtime.process.WorkItemHandler
-
close
public void close()
- Specified by:
close
in interfaceorg.kie.internal.runtime.Cacheable
-
-