One solution to this would be to instead create an object that represents the parameters and on that execution after 5 minutes, obtain that object and use the internal state as a representation of the parameters. You have to ensure that MyEventService contains a reference to Event before the execution every 5 minutes. Without more input on the original post it's impossible to know how/when you're doing this.
If the parameters never change then I suggest making the service immutable, and removing the event class, and just providing the values via properties using @Value.
class Event {
private final String myString;
// constructor, getter
}
@Service
public class MyEventService {
private Event event;
// constructor, setter, getter
}
class MyScheduledTask {
@Autowired
private MyEventService eventService;
@Scheduled(fixedDelay = 300_000)
public void execute() {
Event event = eventService.getEvent();
if (event == null) {
throw new IllegalStateException("No event to process.");
}
// process event
}
}