Yes, this problem again...
I have designed a batch system which calls notify method of ActionService and within notify method, depends on how it is called, there is a call to create method of batch service.
Example code blocks looks like this;
@Service
public class BatchService{
private final BatchRepository batchRepository;
private final ActionService actionService;
public Batch create(Batch batch){
return batchRepository.save(batch);
}
public void triggerNotifiers(){
...
actionService.notify(...);
...
}
}
@Service
public class ActionService{
private final ActionRepository actionRepository;
private final BatchService batchService;
public void notify(...){
...
if(/*some special cases*/)
batchService.create(...);
...
}
}
The functionality of batch service is to call notify method of Action service. Action service can create future notifiers depends on the incoming notification data.
So they are pretty dependent to each other.
Do you think is there a better way/logic/design to do this?