cancel
Showing results for 
Search instead for 
Did you mean: 

Mule Integration

brianrook
Champ in-the-making
Champ in-the-making
Hello, I'm working on a project where I intend to call Mule from inside of an Activiti process.  I have downloaded and installed Activiti 5.6 and I've got the database setup.

From my bpmn20.xml file:


   <process id="createInboundDocument">
      <startEvent id="start" />

      <sequenceFlow sourceRef="start" targetRef="create_workitem_action" />

      <serviceTask id="create_workitem_action"
         name="Create a WorkItem from the InboundDocumentAction"
         activiti:class="com.stoneriver.iip.document.bpm.CreateWorkItemFromInboundDocument" />


      <sequenceFlow sourceRef="create_workitem_action"
         targetRef="create_workitem" />

      <sendTask id="create_workitem" activiti:type="mule">
         <extensionElements>
            <activiti:field name="endpointUrl"
               expression="vm://createWorkItem.in?connector=vmSync" />
            <activiti:field name="language">
               <activiti:string>juel</activiti:string>
            </activiti:field>
            <activiti:field name="payloadExpression">
               <activiti:string>#{createWorkItemAction}</activiti:string>
            </activiti:field>
            <activiti:field name="resultVariable">
               <activiti:string>workItemCollection</activiti:string>
            </activiti:field>
         </extensionElements>
      </sendTask>

      <sequenceFlow sourceRef="create_workitem" targetRef="end" />

I can see the first task being called (create_workitem_action).  However, as soon as it tries to call the second task, I get this error in my console:


SEVERE: Error while closing command context
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'muleContext' is defined
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFac
tory.java:521)

The Activiti process is being called from a Mule endpoint, so I'm positive that Mule is communicating with Activiti, but it appears that Activiti doesn't have access to the Mule context for some reason.  How do I fix that?


Thanks!
18 REPLIES 18

trademak
Star Contributor
Star Contributor
Hi,

Did you look at my blog post article and the corresponding source code?
http://bpmn20inaction.blogspot.com/2011/05/supersize-activiti-with-mule-esb-and.html

Best regards,

brianrook
Champ in-the-making
Champ in-the-making
I did see your post.

I think my bpmn sequence element is correct and I'm using the activiti-mule.jar.  Is there something else I need to be doing?

trademak
Star Contributor
Star Contributor
You should really provide more information about your problem.
Are you using the remote or the embedded version of the Activiti Mule integration?
Did you include the following lines in the ProcessEngineConfiguration:

<property name="beans">
                        <map>
                                <entry key="muleContext" value-ref="_muleContext" />
                        </map>
                </property>

Best regards,

mathiasd
Champ in-the-making
Champ in-the-making
Hi,
I try to make my own "Hello world" activiti-mule sample. I try to understand your code https://code.google.com/p/activiti-esb-blog/ but it is a little bit complicated for a newbie :s
Is it the shortest "hello world" possible using activiti and mule ?

What I would like to do is interact with this mule :


<simple-service name="hello" address="http://localhost:8080/hello">
        <script:component>
            <script:script engine="groovy">
                <script:text>return "Hello World"</script:text>
            </script:script>
        </script:component>
    </simple-service>

Is it possible ?

trademak
Star Contributor
Star Contributor
Sure. But if you find the blog post contains not enough information, a better way to learn it is to read chapter 11 of the Activiti in Action book, which is already available in the MEAP program.
There's an example in there that does almost the same thing as you describe.

Best regards,

mathiasd
Champ in-the-making
Champ in-the-making
Ok, thanks

mathiasd
Champ in-the-making
Champ in-the-making
Could I ask you something else ? Smiley Very Happy

In your sample, you define the processEngineConfiguration as :

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="databaseType" value="h2" />
  <property name="dataSource" ref="dataSource" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="databaseSchemaUpdate" value="true" />
  <property name="beans">
   <map>
    <entry key="muleContext" value-ref="_muleContext" />
   </map>
  </property>
</bean>

I don't understand where the "_muleContext" comes from. I was expecting to find something like :


<bean id="_muleContext" …>

</bean>

But I didn't find anything like that. When I tried to run my own helloWorld, i have :

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '_muleContext' is defined


Could you explain me how to instantiate this _muleContext variable ?

Thanks

trademak
Star Contributor
Star Contributor
Sure. I can understand that, it's a bit low-level.
The _muleContext variable is created within the Mule framework when starting an embedded Mule container.
So when you use the activiti-embedded connector of Mule this variable is available.
When you use the remote equivalent this is not possible.
So you can only invoke Mule flows directly when using the embedded approach.
When you would want to use the remote approach, the default way to invoke flows is to use a web service task.

Best regards,

mathiasd
Champ in-the-making
Champ in-the-making
Ok, but I added this :


<bean id="_muleContext" factory-bean="muleFactory" factory-method="createMuleContext">
  <constructor-arg type="java.lang.String" value="src/main/resources/application-context.xml"/>
</bean>

And it works. Smiley Wink
The problem I have now is that the http mule sends back a "ReleasingInputStream" which is not serializable and so Activiti throw an exception when I try to put this into a resultVariable.
But I guess this is more a Mule problem than an Activiti one and I have some ideas to fix this.

Thanks for your help !

Mathias