Access data across service runs

Hello All,

Is there a way in Moqui that we can access some data values across the service runs without passing them as parameters.
For example, say my custom service calls the OOTB receive#IncomingSystemMessage service and I want to save some value like an identifier for each System Message which will be further used to prepare the unique sendPath to send the System Message text to SFTP.
I tried exploring the context that if it is possible to use shared context between services where we can maybe put a value in the context in 1 service and try to access it another service from the same context.
But after further analysis, found that the context is local to the service run and not accessible across service runs. (Please correct my understanding if not correct here)

Other way is to extend the entity say SystemMessage, then I need to extend the receive#IncomingSystemMessage interface as well, and pass the desired values in the custom service implementation which calls the receive#IncomingSystemMessage service.

Is there any other recommended way to achieve this?

Thanks in advance.

What problem are you trying to solve with this? Understanding the context to your question might help you solve the problem instead of doing something that may not make sense to actually do.

If you are writing the code that is calling receive#IncomingSystemMessage and you have a custom receive service, then just don’t use the receive#IncomingSystemMessage service and call your receive service directly. The calling code could then call the consume#ReceivedSystemMessage service, or you could change your receive service to do that. The other option is don’t call the consume and let the consume retry job pick it up.

3 Likes

Thanks Michael and David for your response.

@michael
Here my scenario is to store a custom value/identifier for each SystemMessage records as the business requirement is to further filter these records based on the identifier values.(later perform some operations on them)
The custom value is passed as a parameter to a service/job parameter initially, and I wanted to pass this value in the flow of receive to consume System Message services so that it gets saved in System Message records.
And I wanted to check if there is a way to access the value across services without extending the System Message entity and related services, maybe somehow access it from context if possible.

For now I proceeded by extending the required entity, and passing values in custom System Message services.

3 Likes