Block Rest Request Until Message Arrives On Other Route

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Block Rest Request Until Message Arrives On Other Route

noone100

Hi

I would like to implement a request/reply pattern for MQTT 3.1.1, which
does not support InOut exchange pattern. I have a constant topic for the
request and a constant topic for the response as follows:

// ROUTE DEFINITION START

rest()
  .routeId("request")
  .post("path")
  .to("mqtt:requestTopic")
// wait for reply on another route (aggregate?, enrich?)
  .endRest

from("mqtt:responseTopic")
.to("notify routeId request")

// ROUTE DEFINITION END

neither aggregate() nor enrich() are blocking. Therefore the rest call
terminates before the response arrives.

Any advice would be highly appreciated
Reply | Threaded
Open this post in threaded view
|

Re: Block Rest Request Until Message Arrives On Other Route

Claus Ibsen-2
You can try with pollEnrich as it will consume from an endpoint.

Also poll enrich supports a timeout if the response is not arriving
after X time.

Also you can also use a processor / bean and write some code that
waits for the message from MQTT and then adds that as the response on
the Camel Message

On Mon, Aug 12, 2019 at 11:12 AM Michael Zaugg <[hidden email]> wrote:

>
>
> Hi
>
> I would like to implement a request/reply pattern for MQTT 3.1.1, which
> does not support InOut exchange pattern. I have a constant topic for the
> request and a constant topic for the response as follows:
>
> // ROUTE DEFINITION START
>
> rest()
>   .routeId("request")
>   .post("path")
>   .to("mqtt:requestTopic")
> // wait for reply on another route (aggregate?, enrich?)
>   .endRest
>
> from("mqtt:responseTopic")
> .to("notify routeId request")
>
> // ROUTE DEFINITION END
>
> neither aggregate() nor enrich() are blocking. Therefore the rest call
> terminates before the response arrives.
>
> Any advice would be highly appreciated



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Block Rest Request Until Message Arrives On Other Route

noone100
Thanks for your suggestions!

I unfortunately need a correlation id, which I can't set up in
pollEnrich(...). So I think I have to use the 2nd approach.


On 12.08.19 11:56, Claus Ibsen wrote:

> You can try with pollEnrich as it will consume from an endpoint.
>
> Also poll enrich supports a timeout if the response is not arriving
> after X time.
>
> Also you can also use a processor / bean and write some code that
> waits for the message from MQTT and then adds that as the response on
> the Camel Message
>
> On Mon, Aug 12, 2019 at 11:12 AM Michael Zaugg <[hidden email]> wrote:
>>
>>
>> Hi
>>
>> I would like to implement a request/reply pattern for MQTT 3.1.1, which
>> does not support InOut exchange pattern. I have a constant topic for the
>> request and a constant topic for the response as follows:
>>
>> // ROUTE DEFINITION START
>>
>> rest()
>>   .routeId("request")
>>   .post("path")
>>   .to("mqtt:requestTopic")
>> // wait for reply on another route (aggregate?, enrich?)
>>   .endRest
>>
>> from("mqtt:responseTopic")
>> .to("notify routeId request")
>>
>> // ROUTE DEFINITION END
>>
>> neither aggregate() nor enrich() are blocking. Therefore the rest call
>> terminates before the response arrives.
>>
>> Any advice would be highly appreciated
>
>
>

--
Michael Zaugg
Softwareingenieur

Puzzle ITC GmbH
www.puzzle.ch

Telefon +41 31 370 22 00
Direkt  +41 31 370 22 15
Mobile  +41 79 289 65 88
Fax     +41 31 370 22 01

Werfen Sie einen Blick in unseren Blog:
<http://www.puzzle.ch/blog>