// Persist in separate transaction so it is committed immediately, before the request is sent to the agent
DeleteResourceHistory persistedHistory = resourceFactoryManager.persistDeleteHistory(subject, resourceId);
// Package into transfer object
DeleteResourceRequest request = new DeleteResourceRequest(persistedHistory.getId(), resourceId);
try {
AgentClient agentClient = agentManager.getAgentClient(agent);
ResourceFactoryAgentService resourceFactoryAgentService = agentClient.getResourceFactoryAgentService();
resourceFactoryAgentService.deleteResource(request);