cancel
Showing results for 
Search instead for 
Did you mean: 

service task monitoring

logic3
Champ in-the-making
Champ in-the-making
HI,

I am trying to monitor a process consisting several service tasks. I am using Listeners to generate events for my service tasks. I need to figure out, for example, If I have service tasks A,B,C,D where D is a service that send emails (for example). I would like know that the start event of the service D should have some information about the invoking service or who access that service. If service B invokes service D then then the start event of the service D must have at least the name of service B. I am not sure how to implement or achieve this.

Any help would be very much appreciated.
7 REPLIES 7

jbarrez
Star Contributor
Star Contributor
I'm not really understanding what you're trying to do …

But I guess you want to know who is calling some service …. autodiscovering it is pretty hard, so the easiest will probably be a process variable … I don't see any reasonable way how else to do it…

logic3
Champ in-the-making
Champ in-the-making
Thanks for you reply..

Yes, for instance who is calling some service. when you say process variable then could you please be explain a bit further. I mean how to use process variable for this purpose.

jbarrez
Star Contributor
Star Contributor
Hmm, the more I think about it, the more I dislike process variables.

Since the service is Java … can't you just add a mandatory parameter to the service invocation?

logic3
Champ in-the-making
Champ in-the-making
I will try to provide some more information for what I am trying to achieve. I am trying to create an module that send maximum information about the running process. For this, I am using event listeners and implemented the BPMNParser class. I have service tasks that contain information about remote web services. A service task may look like:

<serviceTask activiti:class="org.myclass" id="servicetask1" name="ServiceTask">
      <extensionElements>
       <activiti:field name="type">
          <activiti:string>xyz</activiti:string>
        </activiti:field>
     
        <activiti:field name="input">
          <activiti:expression>${var0}</activiti:expression>
        </activiti:field>
    
        <activiti:field name="output">
          <activiti:string>${var1}</activiti:string>
        </activiti:field>
 
        <activiti:field name="op">
          <activiti:string>yuo</activiti:string>
        </activiti:field>
<activiti:field name="location">
          <activiti:string>http://localhost:xxxx/bmg?wsdl</activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>


As i mentioned, It need to collect the maximum information about a service and send it as an event. It should not only have the start and end time but also some other information such as the service task extension elements and perhaps invocation information. I tried sending the extension element information but failed because the start event goes out first and then the serviceTask activiti:class is executed. Thus, events only contain Null information. I think process variable could be used but I am not sure how. Also, my understanding is that process variable could only be used at process level.

It would be nice to do the maximum work at the event handler classes level. I could include some stuff to the serviceTask activiti:class to support the listeners. I am new to Activiti and therefore need some help and advise.

many thanks

jbarrez
Star Contributor
Star Contributor
Hmm, that's a pretty tricky use case you have there 😉

So if I understand you correctly, you need basically the XML information right?
If so, I would suggest looking at the bpmn-converter we introduced in Activiti 5.11. Those classes can transform the xml to a pojo, which you can then use in your events.

logic3
Champ in-the-making
Champ in-the-making
Thanks for your reply.

I will certainly look into the BPMN-converter but I am not sure if we are allowed to upgrade ourselves to 5.11. However, do you see any possibility of the event class to use the serviceTask activiti:class. I mean some logic that the start event after execution, collect information from serviceTask activiti:class. Currently, the event class is executed before the serviceTask activiti:class.

thanks,

jbarrez
Star Contributor
Star Contributor
However, do you see any possibility of the event class to use the serviceTask activiti:class. I mean some logic that the start event after execution, collect information from serviceTask activiti:class. Currently, the event class is executed before the serviceTask activiti:class.

No, I'm afraid there is currently not such functionality.
But wouldn't regular execution listeners [1] work for you? From the userguide, they allow you to capture

Start and ending of a process instance.
Taking a transition.
Start and ending of an activity.
Start and ending of a gateway.
Start and ending of intermediate events.
Ending an start event or starting an end event.


[1] http://activiti.org/userguide/index.html#executionListeners