Class 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 jBPM 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 CamelEndpointIdWorkItem 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.

    • Field Summary

      • Fields inherited from class org.jbpm.process.workitem.core.AbstractLogOrThrowWorkItemHandler

        handlingProcessId, handlingStrategy, logThrownException, retries
    • 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)  
      • Methods inherited from class org.jbpm.process.workitem.core.AbstractLogOrThrowWorkItemHandler

        findNodeInstance, handleException, handleException, setLogThrownException
    • Constructor Detail

      • AbstractCamelWorkItemHandler

        public AbstractCamelWorkItemHandler()
        Default Constructor. This creates a ProducerTemplate for the global CamelContext.
      • AbstractCamelWorkItemHandler

        public AbstractCamelWorkItemHandler​(String camelEndointId)
      • AbstractCamelWorkItemHandler

        public AbstractCamelWorkItemHandler​(org.kie.api.runtime.manager.RuntimeManager runtimeManager)
        Constructor which accepts RuntimeManager. This causes this WorkItemHanlder to create a ProducerTemplate for the runtime specific CamelContext.
      • 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 interface org.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 interface org.kie.api.runtime.process.WorkItemHandler
      • close

        public void close()
        Specified by:
        close in interface org.kie.internal.runtime.Cacheable