how to get variable that are updated using VARIABLE_UPDATED event
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2015 02:37 PM
I'm trying to listen to VARIABLE_UPDATED event and want to do some processing with the variables that are updated. For that I have implemented ActivitiEventListener and in the onEvent method trying to find the variables that are updated using the parameter variable ActivitiEvent, but I dont see any methods in ActivitiEvent that can give that information.
Can you please let me know how to get the variables that are updated using the event handler. I tried in activiti user guide but I don't see anywhere or may be I'm missing.
Can you please let me know how to get the variables that are updated using the event handler. I tried in activiti user guide but I don't see anywhere or may be I'm missing.
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2015 04:12 AM
Hi,
Regards
Martin
org.activiti.engine.test.api.event.VariableEventsTest#testProcessInstanceVariableEvents
event.getVariableName();
event.getVariableValue();
Regards
Martin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2015 11:10 AM
Does VARIABLE_UPDATED event will fire just as soon as any variable updated for process/task ? or does it have any exceptional cases where only on those cases it will fire? Because I was testing to listen to this event by updating the variable using the following call
taskService.setVariables(task.getId(), processVaraibles);
With the above call the variable values are getting updated but I'm not receiving any event.
Here is my configuration:
<code>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="databaseType" value="oracle" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="false" />
<property name="jobExecutorActivate" value="false" />
<property name="enableDatabaseEventLogging" value="false" />
<property name="idGenerator">
<bean class="org.activiti.engine.impl.persistence.StrongUuidGenerator" />
</property>
<property name="typedEventListeners">
<map>
<entry key="VARIABLE_UPDATED" >
<list>
<ref bean="variableUpdateEventListner"/>
<!–<bean class="com.uprr.netcontrol.workflow.event.listeners.VariableUpdateEventListener"></bean>
–></list>
</entry>
</map>
</property>
</bean>
<code>
And listener class:
<code>
public class VariableUpdateEventListener implements ActivitiEventListener {
protected static final transient Logger LOGGER = LoggerFactory.getLogger(VariableUpdateEventListener.class);
private EventPublisher eventPublisher;
@Override
public final boolean isFailOnException() {
return false;
}
@Override
public final void onEvent(final ActivitiEvent event) {
switch (event.getType()) {
case VARIABLE_UPDATED:
LOGGER.INFO("variable update event fired for process id {}", event.getProcessInstanceId());
break;
default:
break;
}
}
}
<code>
taskService.setVariables(task.getId(), processVaraibles);
With the above call the variable values are getting updated but I'm not receiving any event.
Here is my configuration:
<code>
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
<property name="databaseType" value="oracle" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="false" />
<property name="jobExecutorActivate" value="false" />
<property name="enableDatabaseEventLogging" value="false" />
<property name="idGenerator">
<bean class="org.activiti.engine.impl.persistence.StrongUuidGenerator" />
</property>
<property name="typedEventListeners">
<map>
<entry key="VARIABLE_UPDATED" >
<list>
<ref bean="variableUpdateEventListner"/>
<!–<bean class="com.uprr.netcontrol.workflow.event.listeners.VariableUpdateEventListener"></bean>
–></list>
</entry>
</map>
</property>
</bean>
<code>
And listener class:
<code>
public class VariableUpdateEventListener implements ActivitiEventListener {
protected static final transient Logger LOGGER = LoggerFactory.getLogger(VariableUpdateEventListener.class);
private EventPublisher eventPublisher;
@Override
public final boolean isFailOnException() {
return false;
}
@Override
public final void onEvent(final ActivitiEvent event) {
switch (event.getType()) {
case VARIABLE_UPDATED:
LOGGER.INFO("variable update event fired for process id {}", event.getProcessInstanceId());
break;
default:
break;
}
}
}
<code>

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2015 02:03 PM
Are you sure it's variable update and not variable create?
If so, could you create a unit test showing the issue and create a JIRA issue for it?
Thanks,
If so, could you create a unit test showing the issue and create a JIRA issue for it?
Thanks,
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2015 10:17 AM
Yes, it is for variable update.
I tried to reproduce by creating a unit test but there it is working. Might be guessing something wrong in my configuration
I tried to reproduce by creating a unit test but there it is working. Might be guessing something wrong in my configuration
