You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Peter Klotz <pe...@blue-elephant-systems.com> on 2006/08/22 12:00:57 UTC

sendSync in EIP endpoint processing

Hi,

while we are hunting for sendSync() hangs we found the following code in the EIP
endpoint class that looked a bit strange


EIPEndpoint.java:380


   /* (non-Javadoc)
     * @see
org.apache.servicemix.common.ExchangeProcessor#process(javax.jbi.messaging.MessageExchange)
     */
    public void process(MessageExchange exchange) throws Exception {
        boolean txSync = exchange.isTransacted() &&
Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));
        if (txSync && exchange.getRole() == Role.PROVIDER &&
exchange.getStatus() == ExchangeStatus.ACTIVE) {
            processSync(exchange);
        } else {
            processAsync(exchange);
        }
    }



As we do not use transactions exchange.isTransacted() is false
but because we use sendSync() at the client side the SEND_SYNC flag is set and
the second part true.

Wouldn't be a || (or) be correct here instead of && (and)?
otherwise the method would use a send and not a sendSync and not wait or process
on the response?


Peter

Re: sendSync in EIP endpoint processing

Posted by Guillaume Nodet <gn...@gmail.com>.
It' s the desired behavior.
This is only to control the transaction boundaries.

If the consumer send an exchange synchronously, it means that it will wait
for the exchange to come back.  This is not related to how the producer
handle the exchange itself, as it can send a new exchange asynchronously
to another provider, and park the original exchange until the answer come
back (asynchronously).  This is the way it' s done in the EIP component.

Components should avoid using sendSync unless necessary to avoid
consuming threads.

On 8/22/06, Peter Klotz <pe...@blue-elephant-systems.com> wrote:
> Hi,
>
> while we are hunting for sendSync() hangs we found the following code in the EIP
> endpoint class that looked a bit strange
>
>
> EIPEndpoint.java:380
>
>
>    /* (non-Javadoc)
>      * @see
> org.apache.servicemix.common.ExchangeProcessor#process(javax.jbi.messaging.MessageExchange)
>      */
>     public void process(MessageExchange exchange) throws Exception {
>         boolean txSync = exchange.isTransacted() &&
> Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC));
>         if (txSync && exchange.getRole() == Role.PROVIDER &&
> exchange.getStatus() == ExchangeStatus.ACTIVE) {
>             processSync(exchange);
>         } else {
>             processAsync(exchange);
>         }
>     }
>
>
>
> As we do not use transactions exchange.isTransacted() is false
> but because we use sendSync() at the client side the SEND_SYNC flag is set and
> the second part true.
>
> Wouldn't be a || (or) be correct here instead of && (and)?
> otherwise the method would use a send and not a sendSync and not wait or process
> on the response?
>
>
> Peter
>
>


-- 
Cheers,
Guillaume Nodet