使用带有activeMQ的activiti和camel时,业务键是Null Exception

时间:2014-09-04 18:41:56

标签: java apache-camel activemq activiti bpmn

我正致力于POC为我们公司设计工作流程。我们在系统中大量使用ActiveMQ。我正在努力集成其中包含activeMQ队列的activiti和camel路由。当我运行该进程时,它会通过包含队列的camel路由并创建新队列,但消息不会从一个队列传递到另一个队列。  我在目标队列上收到以下消息:

  Unknown message type [org.apache.activemq.command.ActiveMQMessage] ActiveMQMessage
下面的

是堆栈跟踪:

 2:11:59.705 [Camel (camelContext) thread #0 - JmsConsumer[TESTQUEUE]] WARN  o.a.c.c.jms.EndpointMessageListener - Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - org.activiti.engine.ActivitiIllegalArgumentException: Business key is null]
org.apache.camel.RuntimeCamelException: org.activiti.engine.ActivitiIllegalArgumentException: Business key is null
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363) ~[camel-core-2.13.2.jar:2.13.2]
    at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:186) ~[camel-jms-2.13.1.jar:2.13.1]
    at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:107) ~[camel-jms-2.13.1.jar:2.13.1]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562) ~[spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500) ~[spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) ~[spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1101) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1093) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:990) [spring-jms-3.2.8.RELEASE.jar:3.2.8.RELEASE]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_40]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_40]
    at java.lang.Thread.run(Thread.java:724) [na:1.7.0_40]
Caused by: org.activiti.engine.ActivitiIllegalArgumentException: Business key is null

这是我的camelRoute.bpmn文件:

 <?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:activiti="http://activiti.org/bpmn" 
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" 
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" 
typeLanguage="http://www.w3.org/2001/XMLSchema" 
expressionLanguage="http://www.w3.org/1999/XPath" 
targetNamespace="http://www.activiti.org/test">

<process id="SimpleCamelCallProcess" isExecutable="true">
  <startEvent id="start"/>

  <sequenceFlow id="flow1" sourceRef="start" targetRef="simpleCall"/>  
  <serviceTask id="simpleCall" activiti:type="camel"/>     

  <sequenceFlow id="flow2" sourceRef="simpleCall" targetRef="end"/>      
  <endEvent id="end"/>
</process>   
</definitions>

以下是我的骆驼路线,呼叫bpmn:

public class CamelHelloRoute extends RouteBuilder {
    private static final Logger logger = LoggerFactory.getLogger(CamelHelloRoute.class);


      @Override
      public void configure() throws Exception {

        from("activemq:queue:TESTQUEUE")        
            .log(LoggingLevel.INFO, "Received message ")          
            .to("activiti:SimpleCamelCallProcess:simpleCall");      


        from("activiti:SimpleCamelCallProcess:simpleCall")    
           .log(LoggingLevel.INFO, "Received message on service task ")      
            .to("activemq:queue:TESTQUEUE3");   

      }

    }

以下是我的junit课程:

public class ProcessTestSimpleCamelCallProcess {

    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-int.xml");

    @Rule   
    public ActivitiRule activitiRule= (ActivitiRule) applicationContext.getBean("activitiRule");
    public RepositoryService repositoryService=(RepositoryService) applicationContext.getBean("repositoryService");

    @Test
    public void startProcess() throws Exception {

        repositoryService = activitiRule.getRepositoryService();

         repositoryService.createDeployment().addClasspathResource("camelRoute.bpmn").deploy();
        RuntimeService runtimeService = activitiRule.getRuntimeService();
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("SimpleCamelCallProcess");
        assertNotNull(processInstance.getId());
        System.out.println("id " + processInstance.getId() + " "
                + processInstance.getProcessDefinitionId());
    }

下面是我的spring文件&#34; camel-int.xml&#34;:

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:camel="http://camel.apache.org/schema/spring"    
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd         
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.1.xsd
         http://www.springframework.org/schema/tx
         http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
          http://camel.apache.org/schema/spring
          http://camel.apache.org/schema/spring/camel-spring-2.13.2.xsd">

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
        <property name="url" value="jdbc:mysql://localhost:3306/workflowtest"></property>
        <property name="username" value="root"></property>
        <property name="password" value="abc123"></property>
    </bean>
     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>

  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">  
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jobExecutorActivate" value="false" />
  </bean>

  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />

    <tx:annotation-driven transaction-manager="transactionManager"/>



  <bean id="activitiRule" class="org.activiti.engine.test.ActivitiRule">
  <property name="processEngine" ref="processEngine" />
</bean>

  <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>



 <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
  <packageScan>
    <package>com.activiti.camel</package>
  </packageScan>
</camelContext>

</beans>

0 个答案:

没有答案