AW: [camunda-bpm-users] Messaging between two processes by using camel

534 views
Skip to first unread message

Bernd Rücker (camunda)

unread,
Oct 22, 2013, 6:57:09 AM10/22/13
to camunda-...@googlegroups.com

Hi Carolin.

 

Strange – did not find this thread on google groups anymore? I wanted to ask if this is solved in the meanwhile?

 

Cheers

Bernd

 

Von: camunda-...@googlegroups.com [mailto:camunda-...@googlegroups.com] Im Auftrag von Carolin Dettling
Gesendet: Montag, 7. Oktober 2013 17:33
An: camunda-...@googlegroups.com
Betreff: [camunda-bpm-users] Messaging between two processes by using camel

 

Hi at all,

I've got a question about sending messages between two processes. I did the following in my Camel-Route-Builder:

        from("direct://direct1")
               
.routeId("direct1")
               
.to("log:com.via.camunda.bpm.camel?level=INFO&showAll=true&multiline=true")
               
.process(new Processor() {
                   
public void process(Exchange arg0) throws Exception {
                        processInstanceIdProcess1
= (String) arg0.getProperties().get("CamundaBpmProcessInstanceId");
                        log
.info("\"ProcessInstanceId\" von routeId=" + arg0.getFromRouteId() + " ist: "+ processInstanceIdProcess1);
                   
}
               
})
               
.to("camunda-bpm:start?processDefinitionKey=process2&copyBodyAsVariable=ask&waitForTaskToComplete=Never")
               
.end().process(new Processor() {
                   
public void process(Exchange arg1) throws Exception {
                        processInstanceIdProcess2
= (String) arg1.getProperties().get("CamundaBpmProcessInstanceId");
                        log
.info("\"ProcessInstanceId\" von Process2 ist: " + processInstanceIdProcess2);
                   
}
               
});

       
from("direct://direct2")
               
.routeId("direct2")
               
.to("seda:direct3?waitForTaskToComplete=Never");

       
from("seda://direct3")
               
.routeId("direct3")
               
.process(new Processor() {
                   
public void process(Exchange arg0) throws Exception {
                        runtimeService
= ProcessEngines.getDefaultProcessEngine().getRuntimeService();
                       
ProcessInstance pi = runtimeService.startProcessInstanceById(processInstanceIdProcess1);
                        log
.info("Process Instance: " + pi);
                   
}
               
})
               
.to("camunda-bpm:message?messageName=procss1.answer&processDefinitionKey=process1");


The first route does work fine and starts the second process. But I don't know, how to send the answer in the correct way. The first process is waiting for an (intermediate catch) message event.
By sending the answer, I get the following stacktrace:

INFO  bpm.camel - Exchange[
, Id: xxx
, ExchangePattern: InOut
, Properties: {CamelCreatedTimestamp=Mon Oct 07 17:09:54 CEST 2013, CamelMessageHistory=[DefaultMessageHistory[routeId=direct1, node=to6]], CamelToEndpoint=log://com.via.camunda.bpm.camel?level=INFO&multiline=true&showAll=true, CamundaBpmProcessInstanceId=810f97a4-2f62-11e3-b62e-0022190e09a4}
, Headers: {breadcrumbId=xxx}
, BodyType: java.util.HashMap
, Body: {}
, Out: null:
]
Okt 07, 2013 5:09:54 PM com.via.camunda.bpm.camel.MyCamelRouteBuilder$4 process
INFO
: "ProcessInstanceId" von routeId=direct1 ist: 810f97a4-2f62-11e3-b62e-0022190e09a4
Okt 07, 2013 5:09:54 PM org.camunda.bpm.engine.impl.bpmn.deployer.BpmnDeployer deploy
...
Okt 07, 2013 5:09:54 PM com.via.camunda.bpm.camel.MyCamelRouteBuilder$3 process
INFO
: "ProcessInstanceId" von Process2 ist: 1
ERROR processor
.DefaultErrorHandler - Failed delivery for (MessageId: ... on ExchangeId: xxx). Exhausted after delivery attempt: 1 caught: org.camunda.bpm.engine.ProcessEngineException: no deployed process definition found with id '810f97a4-2f62-11e3-b62e-0022190e09a4'

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[direct3           ] [direct3           ] [seda://direct3                                                                ] [        14]
[direct2           ] [to8               ] [seda:direct3?waitForTaskToComplete=Never                                      ] [         1]
[direct3           ] [process5          ] [com.via.camunda.bpm.camel.MyCamelRouteBuilder$5@1ce5f5a4                      ] [         9]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
   
Id                  xxx
   
ExchangePattern     InOut
   
Headers             {breadcrumbId=xxx, CamelRedelivered=false, CamelRedeliveryCounter=0}
   
BodyType            java.util.HashMap
   
Body                {process1.answer=answer, CamundaBpmProcessInstanceId=810f97a4-2f62-11e3-b62e-0022190e09a4}
]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org
.camunda.bpm.engine.ProcessEngineException: no deployed process definition found with id '810f97a4-2f62-11e3-b62e-0022190e09a4'
....
Exchange[Message: {process1.answer=answer, CamundaBpmProcessInstanceId=810f97a4-2f62-11e3-b62e-0022190e09a4}]. Caused by: [org.camunda.bpm.engine.ProcessEngineException - no deployed process definition found with id '810f97a4-2f62-11e3-b62e-0022190e09a4']


If I change the route from direct3 like this:

        from("seda://direct3")
               
.routeId("direct3")
               
.to("camunda-bpm:message?messageName=procss1.answer&processDefinitionKey=process1");


The stack says this:

INFO: "ProcessInstanceId" von routeId=direct1 ist: 0dbdc63a-2f65-11e3-b62e-0022190e09a4
...
INFO
: "ProcessInstanceId" von Process2 ist: 101
...
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java
.lang.RuntimeException: Couldn't find waiting process instance with id '101' for message 'procss1.answer'



Does anybody know/find my mistake?

Thanks and Cheers,
Caro

--
You received this message because you are subscribed to the Google Groups "camunda BPM users & process application developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/camunda-bpm-users/2a1418c9-c20e-478e-94a0-1267907f2e1e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Carolin Dettling

unread,
Oct 23, 2013, 3:13:42 AM10/23/13
to camunda-...@googlegroups.com
Hi Bernd,

yes, it's solved, therefore I deleted this post.

Thanks for asking.
Cheers, Carolin


java
.lang.RuntimeException: Couldn<span cl

...

Carolin Dettling

unread,
Oct 23, 2013, 3:22:47 AM10/23/13
to camunda-...@googlegroups.com
Hi Bernd,

but... It works only, by using the method "correlateMessage". I'm not sure, if I use this construct "camunda-bpm:message?messageName=procss1.answer&processDefinitionKey=process1" the right way or if it dosn'nt work correct.
This would be still nice to know.

Cheers Caro

Bernd Rücker (camunda)

unread,
Oct 23, 2013, 3:32:41 AM10/23/13
to camunda-...@googlegroups.com

Hi Carolin.

 

OK – perfect – thanks for the feedback.

 

And maybe  it would be better to quickly answer that is was solved next time (maybe even with some information how if anybody else experiences the same problem).

 

Thanks and Cheers

Bernd

--

You received this message because you are subscribed to the Google Groups "camunda BPM users & process application developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.

Bernd Rücker (camunda)

unread,
Oct 23, 2013, 3:33:56 AM10/23/13
to camunda-...@googlegroups.com

Could you then repost the question? I think it got lost by deleting it (and I deleted the mail locally in the meantime ;-)).

--

You received this message because you are subscribed to the Google Groups "camunda BPM users & process application developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.

Carolin Dettling

unread,
Oct 23, 2013, 4:52:04 AM10/23/13
to camunda-...@googlegroups.com
Repost of my earlier question:

java
.lang.RuntimeException: Couldn't find waiting process instance with id '101' for message 'procss1.answer'


Does anybody know/find my mistake?

Thanks and Cheers,
Caro

==================================
==================================

In the meanwhile I could fix this problem by inserting in the route from direct3 the following:
// correlate with message
ProcessEngines.getDefaultProcessEngine().getRuntimeService().correlateMessage(procss1.answer);

So the processes interact with each other, but not by using the camunda BPM Camel component. For this line:
.to("camunda-bpm:message?messageName=procss1.answer&processDefinitionKey=process1");

I still get the same stacktrace like before.

Thanks and Cheers,
Carolin

Alfonso Mateos Alarcón

unread,
Mar 6, 2014, 11:15:46 AM3/6/14
to camunda-...@googlegroups.com
It doesn't work for me, even when I use correlateMessage...

I call a MessageTask that has the "asynchronous" checbox set to true, and calls a Camel route with this expression:

camunda:expression="#{camel.sendTo('direct:generateAfiFile')}"

That MessageTask is followed by an intermediate catch event that waits for a message named "AFI_GENERATED".

The camel route invoked asynchronously from the service tasks calls back to Camunda by trying to use the correlateMessage method... but without success.


In my BPMN I've got:
 

  <bpmn2:message id="Message_3" name="AFI_GENERATED"/>

and: 

    <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_2">

      <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>

      <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>

      <bpmn2:messageEventDefinition id="_MessageEventDefinition_2" messageRef="Message_3"/>

    </bpmn2:intermediateCatchEvent>


Then I use from my Camel route this processor to try to send my message back to my process:

        .process(new Processor() {

          @Override

          public void process(Exchange exchange) throws Exception {

            ProcessEngines.getDefaultProcessEngine().getRuntimeService().correlateMessage("AFI_GENERATED");

          }

        });

But It gives me this error now:

org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message AFI_GENERATED: No process definition or execution matches the parameters

I made sure that the header CamundaBpmProcessInstanceId is in place:

Headers:{CamundaBpmProcessInstanceId=8101, channelId=null, breadcrumbId=ID-alfonso-mbp-2-local-50518-1394121195821-0-9, fileName=afiliacion.afi}

What else am I missing?

Thanks in advance...




Bernd Rücker (camunda)

unread,
Mar 6, 2014, 11:21:16 AM3/6/14
to camunda-...@googlegroups.com

Hi Alfonso.

 

If you write your own Processer (and not use the pre-built endpoint “camunda-bpm://message”) you have to call the correct API:

 

corrleateMessage takes a second parameter with the correlation parameters. This is important to get going.

 

In the endpoint we implemented it like this: https://github.com/camunda/camunda-bpm-camel/blob/master/camunda-bpm-camel-common/src/main/java/org/camunda/bpm/camel/component/producer/MessageProducer.java#L100

 

Von: camunda-...@googlegroups.com [mailto:camunda-...@googlegroups.com] Im Auftrag von Alfonso Mateos Alarcón
Gesendet: Donnerstag, 6. März 2014 17:16
An: camunda-...@googlegroups.com
Betreff: Re: [camunda-bpm-users] Messaging between two processes by using camel

 

It doesn't work for me, even when I use correlateMessage...

--
You received this message because you are subscribed to the Google Groups "camunda BPM users" group.


To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.

Bernd Rücker (camunda)

unread,
Mar 6, 2014, 11:22:02 AM3/6/14
to camunda-...@googlegroups.com

Sorry – wrong shortcut – sent the message without finishing it ;-) But I hope that already helps?

 

--

Cheers

Bernd

Consultant & Evangelist (www.camunda.org/community/team.html)

We are hiring: http://www.camunda.org/community/jobs.html

Reply all
Reply to author
Forward
0 new messages