Appropriate use of service action.
Application Type
Reactive

Hi,

We are planning to convert all the server action to service action as we don't have tightly coupled architecture kind of functionalities.

So I just wanted to know which are the things which is not possible using service action apart form the function ability.

I want to create wrapper of client action into the service action to use as a function, Is this a appropriate use of service action?


Thanks

Rajendra Singh

Solution

One of the main characteristics of Service Actions is that it creates a weak dependency between consumer and producer modules. This is a plus for modules in different domains, since it gives you autonomy between dev teams and domains. Within the same domain can be more troublesome than helpful.


Service Actions are REST APIs (automatically generated by the platform), this means that you now might have different transactions within the same request - which does not happen with Public Server Actions. Because of that it means that additional logic to handle failures must be implemented in the consumers, this comes with an extra effort that wouldn't be justifiable within the same domain.


Take a look at these two articles, hopefully it can help you. Understand Strong and Weak Dependencies and Use Services to Expose Functionality

Hi Rajendra,

check this session talking about service actions to understand the pros and cons:

[APAC Regional] Domains and Services & Automated UI Testing (English) | Recording

 


Thanks José Gonçalves,

I went through the recording but still it doesn't clear my doubts. actually my question is-

->Can we achieve everything using service action which can be achieved by server action. (Partially got the answer from the recording)

->Is this the appropriate use of service action(I want to create wrapper of client action into the service action to use as a function )


Thanks

Rajendra Singh


Like Srinivas said, it's not possible to include a client action inside a service action. Service actions are exclusive of Service Modules and they don't allow the creation of client actions neither reference them from external modules.

All the rest is possible, just don't start calling service actions like crazy due to network issues and always pay attention to the fact that calling a service action means another transaction. In case of failing, it will not rollback what happened before service action was called.

Hi Rajendra

A Client Action is executed at client side and a Service Action is in fact an automatic generated rest api at the server side, that is exposed and handled transparently by the platform. So you can't wrap a client action inside a service action.

Can you please explain your use case and why you need the wrapper?

Cheers,

Davide

HI, 


Yes you can do all thing in service action like server action, but u cannot call the client action in service action as mentioned above 

This image helps when to create service and server action 



why only can use service action when another domain?

Solution

One of the main characteristics of Service Actions is that it creates a weak dependency between consumer and producer modules. This is a plus for modules in different domains, since it gives you autonomy between dev teams and domains. Within the same domain can be more troublesome than helpful.


Service Actions are REST APIs (automatically generated by the platform), this means that you now might have different transactions within the same request - which does not happen with Public Server Actions. Because of that it means that additional logic to handle failures must be implemented in the consumers, this comes with an extra effort that wouldn't be justifiable within the same domain.


Take a look at these two articles, hopefully it can help you. Understand Strong and Weak Dependencies and Use Services to Expose Functionality

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.