cancel
Showing results for 
Search instead for 
Did you mean: 

signal to a remote engine

nsi
Champ in-the-making
Champ in-the-making
Hi everybody!

I'm new, both in this forum and in activiti. So I'm sorry for asking what I suppose is a simple question, but I couldn't find any helpful answer anywhere.

I need to send a signal to a receive task running on a remote activiti engine. How can I do it?

My idea is the following: we run a activiti engine in a standard installation on tomcat with a very simple process, which is waiting for a signal when a manual task ist finished. The manual task ist done in a java swing application, which should send the signal on pressing a button. I am now looking for a code example that shows, what should happen after pressing the button

What ist the best way to do this? Can anybody help, please?

Thanks in advance
Norbert
9 REPLIES 9

trademak
Star Contributor
Star Contributor
You can use the Activiti REST API for that (http://activiti.org/userguide/index.html#N12DA3).
Note that we'll release a fully update REST API in the Activiti 5.13 release in a few days.

Best regards,

nsi
Champ in-the-making
Champ in-the-making
Thanx for the quick answer.

I didn't quite understand: /signal is already part of the 5.9 api?

My rest call is: http://localhost:8080/activiti-rest/process-instance/1539/signal
Is it correct? It doesn't seem to work (" 405 Method Not Allowed")

Thanks once more
Norbert

nsi
Champ in-the-making
Champ in-the-making
-

frederikherema1
Star Contributor
Star Contributor
What method are you using? You should use a HTTP POST. As of 5.13 (will be released this week), there are new methods available in the REST-api related to signaling.

fpuech
Champ in-the-making
Champ in-the-making
Hi !

I have kind of this problem I think.
I am working on activiti 5.12.1 and i would like to stay on this version if it is possible for my think.

I would like to signal a receivetask to a remote engine. I already tried to send a HTTP POST request. 
Here is my code.

         HashMap<String, String> var = new HashMap<String, String>();
  var.put("activityId ", "receivetask1");
  boolean isSignalOk = activitiClient.signalReceiveTask("102461", var);
                System.out.println(isSignalOk);

After that, the request is correctly sent but i have "false" as response. I do not understand why I never get "true".

Can you help me please. Ask me if you want more precisions.

Florent

frederikherema1
Star Contributor
Star Contributor
What is in the activitiClient.signalReceiveTask method? This is not something that is part of the Activiti code-base, so we cannot know what the method actually returns and why.

fpuech
Champ in-the-making
Champ in-the-making
I made a class ActivitiClient in which I have tyhe following method :

public Boolean signalReceiveTask(String processInstanceId, HashMap<String, String> var) throws IOException {
  String varStr = objectMapper.writeValueAsString(var);
  JsonNode jsonCompleteOk = HttpUtil.executePostJson(url + "process-instance/"+processInstanceId+"/signal", varStr, user, password);
  return jsonCompleteOk.get("success").asBoolean();
}

HTTPUtil.executePostJson is simply the call to the method post. I tested it with request such as /login and it works fine. "user" and "password" are "kermit" in my case.

frederikherema1
Star Contributor
Star Contributor
I see you're using the legacy REST-api. If you're on 5.13, consider using the new API, which uses status-codes for indicating errors and has better error-messaging (using response JSON-body).

Do you see any exceptions in your log? perhaps you're using the wrong process-instance id?

fpuech
Champ in-the-making
Champ in-the-making
Thanks for you help. I finally found my error.

var.put("activityId ", "receivetask1");

In the precedent instruction, i put a space after activityId so it did not know what it was I think.
After the errasing of this space, it works fine.