Question about Receive Task

I have this problem.

I have a process waiting in a receive task.

I deployed a servlet in the same app server that camunda is running. This servlet is basically this

public class SignalerServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String uri = req.getRequestURI();
        resp.getWriter().println("Processing url "+ uri);
        String processInstanceId = uri.substring(uri.lastIndexOf('/') + 1);
        resp.getWriter().println("processInstanceId is "+ processInstanceId);
        List<Execution> list = getRuntimeService().createExecutionQuery().processInstanceId(processInstanceId).list();
        Execution execution = list.get(0);
        String id = execution.getId();
        resp.getWriter().println("processInstanceId is "+ id);
        getRuntimeService().signal(id);

    }

    private RuntimeService getRuntimeService() {
        return getDefaultProcessEngine().getRuntimeService();
    }
}

Immediately after this I get the following exception

03-Feb-2019 19:36:18.365 ERROR [o.c.b.engine.context] : ENGINE-16004 Exception while closing command context: cannot signal execution 9c3b0cbc-27da-11e9-ae94-0242ac140004: it has no current activity
org.camunda.bpm.engine.impl.pvm.PvmException: cannot signal execution 9c3b0cbc-27da-11e9-ae94-0242ac140004: it has no current activity
        at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.signal(PvmExecutionImpl.java:716)
        at org.camunda.bpm.engine.impl.cmd.SignalCmd.execute(SignalCmd.java:63)
        at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
        at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104)
        at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
        at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
        at org.camunda.bpm.engine.impl.RuntimeServiceImpl.signal(RuntimeServiceImpl.java:423)
        at systems.appollo.ams.camunda.signaler.SignalerServlet.doGet(SignalerServlet.java:26)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

What exactly are you trying to do?
Usually if you want to send a message you wouldn’t using the process instance id or the exectuion id or the signal method.

Usually you just need a message name and maybe a business key.

	  processEngine.getRuntimeService().createMessageCorrelation("SomeMessageName")
	  .processInstanceBusinessKey("BusinessKey")
	  .correlate();

Hi,

What I’m trying to do is invoking first an external system and wait until that external system completes it’s task.

The process is waiting in a receive task.

I assumed using signal was the way of unblocking it.

In what case should I use signal?

About the correlate method: What BPMN element should be used so that it responds to it, and where in this element I should put the business key or the message name?

Best regards,

Ariel

I think a lot of these questions will be answered in the Tutorial Videos. Specifically the one on communication

Thank you very much Niall.