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.CacheableCamel jBPMWorkItemHandlerwhich allows to call Camel routes with adirectendpoint. The handler passes the to the route that has a consumer on the endpoint-id that can be passed with theCamelEndpointIdWorkItemparameter. E.g. when a the value "myCamelEndpoint" is passed to the {link WorkItem} via theCamelEndpointIdparameter, this command will send theWorkItemto the Camel URIdirect:myCamelEndpoint. The body of the resultMessageof the invocation is returned via theResponseparameter. Access to the raw responseMessageis provided via theMessageparameter. 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 theHandleExceptionsworkitem parameter totrue/ When theHandleExceptionsworkitem 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 aRuntimeManagerto the constructor, the handler will try to find the global KIECamelContextfrom thejBPMServiceRegistry. When theRuntimeManageris passed to the constructor, the handler will retrieve and use theCamelContextbound to theRuntimeManagefrom theServiceRegistry. When aCamelEndpointIdis 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 theCamelEndpointIdin theWorkItemparameters.
-
-
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 voidabortWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)protected abstract org.apache.camel.ExchangebuildExchange(org.apache.camel.ProducerTemplate template, org.kie.api.runtime.process.WorkItem workItem)voidclose()voidexecuteWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)protected StringgetCamelEndpointId(org.kie.api.runtime.process.WorkItem workItem)protected abstract voidhandleResponse(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 aProducerTemplatefor 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 aProducerTemplatefor 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:
executeWorkItemin 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:
abortWorkItemin interfaceorg.kie.api.runtime.process.WorkItemHandler
-
close
public void close()
- Specified by:
closein interfaceorg.kie.internal.runtime.Cacheable
-
-