runSync or call directly

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

runSync or call directly

ian tabangay
Hi. If I have a service written in java, why or why should I not call
another service (also written in java) directly?

-- start code --
public static Map serviceA(DispatchContext dctx, Map context) {
  ...
}

public static Map serviceB(DispatchContext dctx, Map context) {
  ...
}
-- end code --

For example, to call serviceB from serviceA, is it more advisable to access
it via
  dispatcher.runSync("serviceA", context)
or can I just call it directly like so:
  serviceB(dctx, context)


Thanks

~ ian
Reply | Threaded
Open this post in threaded view
|

Re: runSync or call directly

Jacopo Cappellato-3
Always use runSync: there is a small overhead but several advantages,  
one the most important ones is that you just refer to the service  
definition and not on the actual implementation details (Java method,  
Minilang method etc...).

Jacopo


On Sep 10, 2008, at 7:59 AM, ian tabangay wrote:

> Hi. If I have a service written in java, why or why should I not call
> another service (also written in java) directly?
>
> -- start code --
> public static Map serviceA(DispatchContext dctx, Map context) {
>  ...
> }
>
> public static Map serviceB(DispatchContext dctx, Map context) {
>  ...
> }
> -- end code --
>
> For example, to call serviceB from serviceA, is it more advisable to  
> access
> it via
>  dispatcher.runSync("serviceA", context)
> or can I just call it directly like so:
>  serviceB(dctx, context)
>
>
> Thanks
>
> ~ ian


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: runSync or call directly

ian tabangay
Ok thanks for the info.

~ ian

On Wed, Sep 10, 2008 at 3:23 PM, Jacopo Cappellato <
[hidden email]> wrote:

> Always use runSync: there is a small overhead but several advantages, one
> the most important ones is that you just refer to the service definition and
> not on the actual implementation details (Java method, Minilang method
> etc...).
>
> Jacopo
Reply | Threaded
Open this post in threaded view
|

Re: runSync or call directly

Jacques Le Roux
Administrator
In reply to this post by Jacopo Cappellato-3
From: "Jacopo Cappellato" <[hidden email]>
> Always use runSync: there is a small overhead but several advantages,  
> one the most important ones is that you just refer to the service  
> definition and not on the actual implementation details (Java method,  
> Minilang method etc...).

Also direct Java calls are not ECA aware and this is a very important part of OFBiz : its business workflow.

Jacques

> Jacopo
>
>
> On Sep 10, 2008, at 7:59 AM, ian tabangay wrote:
>
>> Hi. If I have a service written in java, why or why should I not call
>> another service (also written in java) directly?
>>
>> -- start code --
>> public static Map serviceA(DispatchContext dctx, Map context) {
>>  ...
>> }
>>
>> public static Map serviceB(DispatchContext dctx, Map context) {
>>  ...
>> }
>> -- end code --
>>
>> For example, to call serviceB from serviceA, is it more advisable to  
>> access
>> it via
>>  dispatcher.runSync("serviceA", context)
>> or can I just call it directly like so:
>>  serviceB(dctx, context)
>>
>>
>> Thanks
>>
>> ~ ian
>
>