You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sven Bauhan <sv...@ast.dfs.de> on 2016/05/02 13:40:54 UTC

Re: How to implement AsyncCallback for AsyncProcessor?

On 04/29/16 21:29, Claus Ibsen wrote:
> On Wed, Apr 27, 2016 at 10:05 PM, Sven Bauhan <sv...@ast.dfs.de> wrote:
>> Hi,
>>
>> I found the explanation for an AsyncProcessor:
>> http://camel.apache.org/asynchronous-processing.html
>>
>> But I do not understand how to implement the corresponding AsyncCallback.
>> I did not find any example, how this can be done.
>>
>> As the done() method just gets the boolean flag, I do not know how the
>> exchange can be provided in this class.
>>
>> Can you give me a hint or an example?
>>
> If you have the Camel in Action book its covered in the concurrency chapter.
>
> There is a little example here
> https://github.com/camelinaction/camelinaction2/tree/master/chapter13/scalability
In this example, the interface AsyncCallback is not implemented at all. 
And it does not show how an AsyncCallback is used in a route definition.
> You can create an async callback class and provide the exchange as a
> constructor, or make the exchange final so you can refer to it from an
> anonoymous callback.
>
>
I do not understand how this could be done.
An exchange is not available at construction of class or in the route 
definition.
The route builder does not know anything about exchanges, so how could 
it provide one as a constructor parameter?

Thanks, Sven



Re: How to implement AsyncCallback for AsyncProcessor?

Posted by Sven Bauhan <sv...@ast.dfs.de>.
On 05/02/16 13:57, Claus Ibsen wrote:
> On Mon, May 2, 2016 at 1:54 PM, Sven Bauhan <sv...@ast.dfs.de> wrote:
>> I have context component to implement a protocol in our company.
>>
>> As the success of a transmission depends a response from the receiver, it
>> has to be handled asynchronously.
>>
>> Now I try to find a way to propagate a timeout exception, if no response is
>> received, out of the context component into the calling application route.
>>
> What whatever you have that triggers the timeout would then set an
> exception on the exchange and call the done(false) method on the async
> callback.
>
> Camel has a ExchangeTimeoutException you can use.
>
For example: exchng.setException(new MessageSendException());

I tried already, but it did not work yet.

Is there an example implementation for something like this?
How to use the ExchangeTimeoutException? Can I combine it with an 
aggregator?


Re: How to implement AsyncCallback for AsyncProcessor?

Posted by Sven Bauhan <sv...@ast.dfs.de>.
On 05/02/16 13:57, Claus Ibsen wrote:
> On Mon, May 2, 2016 at 1:54 PM, Sven Bauhan <sv...@ast.dfs.de> wrote:
>> I have context component to implement a protocol in our company.
>>
>> As the success of a transmission depends a response from the receiver, it
>> has to be handled asynchronously.
>>
>> Now I try to find a way to propagate a timeout exception, if no response is
>> received, out of the context component into the calling application route.
>>
> What whatever you have that triggers the timeout would then set an
> exception on the exchange and call the done(false) method on the async
> callback.
>
> Camel has a ExchangeTimeoutException you can use.
>
For example: exchng.setException(new MessageSendException());

I tried already, but it did not work yet.

Is there an example implementation for something like this?
How to use the ExchangeTimeoutException? Can I combine it with an 
aggregator?


Re: How to implement AsyncCallback for AsyncProcessor?

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, May 2, 2016 at 1:54 PM, Sven Bauhan <sv...@ast.dfs.de> wrote:
> I have context component to implement a protocol in our company.
>
> As the success of a transmission depends a response from the receiver, it
> has to be handled asynchronously.
>
> Now I try to find a way to propagate a timeout exception, if no response is
> received, out of the context component into the calling application route.
>

What whatever you have that triggers the timeout would then set an
exception on the exchange and call the done(false) method on the async
callback.

Camel has a ExchangeTimeoutException you can use.



>
> On 05/02/16 13:48, Claus Ibsen wrote:
>>
>> AsyncCallback is an implementation detail for component developers,
>> and the EIPs that are shipped in Camel.
>>
>> What is your use-case?
>>
>>
>> On Mon, May 2, 2016 at 1:40 PM, Sven Bauhan <sv...@ast.dfs.de>
>> wrote:
>>>
>>> On 04/29/16 21:29, Claus Ibsen wrote:
>>>>
>>>> On Wed, Apr 27, 2016 at 10:05 PM, Sven Bauhan <sv...@ast.dfs.de>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I found the explanation for an AsyncProcessor:
>>>>> http://camel.apache.org/asynchronous-processing.html
>>>>>
>>>>> But I do not understand how to implement the corresponding
>>>>> AsyncCallback.
>>>>> I did not find any example, how this can be done.
>>>>>
>>>>> As the done() method just gets the boolean flag, I do not know how the
>>>>> exchange can be provided in this class.
>>>>>
>>>>> Can you give me a hint or an example?
>>>>>
>>>> If you have the Camel in Action book its covered in the concurrency
>>>> chapter.
>>>>
>>>> There is a little example here
>>>>
>>>>
>>>> https://github.com/camelinaction/camelinaction2/tree/master/chapter13/scalability
>>>
>>> In this example, the interface AsyncCallback is not implemented at all.
>>> And
>>> it does not show how an AsyncCallback is used in a route definition.
>>>>
>>>> You can create an async callback class and provide the exchange as a
>>>> constructor, or make the exchange final so you can refer to it from an
>>>> anonoymous callback.
>>>>
>>>>
>>> I do not understand how this could be done.
>>> An exchange is not available at construction of class or in the route
>>> definition.
>>> The route builder does not know anything about exchanges, so how could it
>>> provide one as a constructor parameter?
>>>
>>> Thanks, Sven
>>>
>>>
>>
>>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: How to implement AsyncCallback for AsyncProcessor?

Posted by Sven Bauhan <sv...@ast.dfs.de>.
I have context component to implement a protocol in our company.

As the success of a transmission depends a response from the receiver, 
it has to be handled asynchronously.

Now I try to find a way to propagate a timeout exception, if no response 
is received, out of the context component into the calling application 
route.

On 05/02/16 13:48, Claus Ibsen wrote:
> AsyncCallback is an implementation detail for component developers,
> and the EIPs that are shipped in Camel.
>
> What is your use-case?
>
>
> On Mon, May 2, 2016 at 1:40 PM, Sven Bauhan <sv...@ast.dfs.de> wrote:
>> On 04/29/16 21:29, Claus Ibsen wrote:
>>> On Wed, Apr 27, 2016 at 10:05 PM, Sven Bauhan <sv...@ast.dfs.de>
>>> wrote:
>>>> Hi,
>>>>
>>>> I found the explanation for an AsyncProcessor:
>>>> http://camel.apache.org/asynchronous-processing.html
>>>>
>>>> But I do not understand how to implement the corresponding AsyncCallback.
>>>> I did not find any example, how this can be done.
>>>>
>>>> As the done() method just gets the boolean flag, I do not know how the
>>>> exchange can be provided in this class.
>>>>
>>>> Can you give me a hint or an example?
>>>>
>>> If you have the Camel in Action book its covered in the concurrency
>>> chapter.
>>>
>>> There is a little example here
>>>
>>> https://github.com/camelinaction/camelinaction2/tree/master/chapter13/scalability
>> In this example, the interface AsyncCallback is not implemented at all. And
>> it does not show how an AsyncCallback is used in a route definition.
>>> You can create an async callback class and provide the exchange as a
>>> constructor, or make the exchange final so you can refer to it from an
>>> anonoymous callback.
>>>
>>>
>> I do not understand how this could be done.
>> An exchange is not available at construction of class or in the route
>> definition.
>> The route builder does not know anything about exchanges, so how could it
>> provide one as a constructor parameter?
>>
>> Thanks, Sven
>>
>>
>
>


Re: How to implement AsyncCallback for AsyncProcessor?

Posted by Claus Ibsen <cl...@gmail.com>.
AsyncCallback is an implementation detail for component developers,
and the EIPs that are shipped in Camel.

What is your use-case?


On Mon, May 2, 2016 at 1:40 PM, Sven Bauhan <sv...@ast.dfs.de> wrote:
> On 04/29/16 21:29, Claus Ibsen wrote:
>>
>> On Wed, Apr 27, 2016 at 10:05 PM, Sven Bauhan <sv...@ast.dfs.de>
>> wrote:
>>>
>>> Hi,
>>>
>>> I found the explanation for an AsyncProcessor:
>>> http://camel.apache.org/asynchronous-processing.html
>>>
>>> But I do not understand how to implement the corresponding AsyncCallback.
>>> I did not find any example, how this can be done.
>>>
>>> As the done() method just gets the boolean flag, I do not know how the
>>> exchange can be provided in this class.
>>>
>>> Can you give me a hint or an example?
>>>
>> If you have the Camel in Action book its covered in the concurrency
>> chapter.
>>
>> There is a little example here
>>
>> https://github.com/camelinaction/camelinaction2/tree/master/chapter13/scalability
>
> In this example, the interface AsyncCallback is not implemented at all. And
> it does not show how an AsyncCallback is used in a route definition.
>>
>> You can create an async callback class and provide the exchange as a
>> constructor, or make the exchange final so you can refer to it from an
>> anonoymous callback.
>>
>>
> I do not understand how this could be done.
> An exchange is not available at construction of class or in the route
> definition.
> The route builder does not know anything about exchanges, so how could it
> provide one as a constructor parameter?
>
> Thanks, Sven
>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2