X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.activemq%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjms%2FJmsAgentProxy.java;h=8c08519371afdfe06c246c96775b3fbbaf892ef7;hb=cffd700ca670610a1f81e021f82542dc6bf5c810;hp=7982bcd7aff7d7a06f10cc2ed99bb536cee84533;hpb=1fdb1b4e7b1d2b0cabb6483238301b857a6392fa;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgentProxy.java b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgentProxy.java index 7982bcd7a..8c0851937 100644 --- a/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgentProxy.java +++ b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsAgentProxy.java @@ -29,6 +29,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; import org.argeo.slc.execution.ExecutionModuleDescriptor; +import org.argeo.slc.execution.ExecutionProcess; import org.argeo.slc.msg.ExecutionAnswer; import org.argeo.slc.msg.MsgConstants; import org.argeo.slc.process.SlcExecution; @@ -53,6 +54,10 @@ public class JmsAgentProxy implements SlcAgent { this.jmsTemplate = jmsTemplate; } + public String getAgentUuid() { + return agentUuid; + } + public ExecutionModuleDescriptor getExecutionModuleDescriptor( final String moduleName, final String version) { return (ExecutionModuleDescriptor) sendReceive(new AgentMC( @@ -70,7 +75,15 @@ public class JmsAgentProxy implements SlcAgent { } public void runSlcExecution(SlcExecution slcExecution) { - sendReceive(new AgentMC("runSlcExecution", slcExecution)); + process(slcExecution); + } + + public void process(ExecutionProcess executionProcess) { + if (!(executionProcess instanceof SlcExecution)) + throw new SlcException("Unsupported process type " + + executionProcess.getClass()); + sendReceive(new AgentMC("runSlcExecution", + (SlcExecution) executionProcess)); } public boolean ping() { @@ -83,8 +96,23 @@ public class JmsAgentProxy implements SlcAgent { } } + public void kill(ExecutionProcess process) { + throw new UnsupportedOperationException(); + } + protected Object sendReceive(AgentMC messageCreator) { - return sendReceive(messageCreator, true); + long begin = System.currentTimeMillis(); + Object res; + try { + res = sendReceive(messageCreator, true); + } finally { + if (log.isTraceEnabled()) + log.trace("To agent #" + agentUuid + " in " + + (System.currentTimeMillis() - begin) + " ms, query '" + + messageCreator.getQuery() + "', correlationId " + + messageCreator.getCorrelationId()); + } + return res; } /** @@ -116,11 +144,6 @@ public class JmsAgentProxy implements SlcAgent { protected void send(AgentMC messageCreator) { jmsTemplate.send(requestDestination, messageCreator); - if (log.isTraceEnabled()) - log.debug("Sent query '" + messageCreator.getQuery() - + "' with correlationId " - + messageCreator.getCorrelationId() + " to agent " - + agentUuid); } protected Object processResponse(AgentMC messageCreator, @@ -145,10 +168,6 @@ public class JmsAgentProxy implements SlcAgent { else return null; } - if (log.isTraceEnabled()) - log.debug("Received response for query '" + query - + "' with correlationId " + correlationId + " from agent " - + agentUuid); try { return fromMessage(responseMsg);