X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.activemq%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjms%2FJmsSlcExecutionNotifier.java;h=45db072b9be17450342dca5cc90c000eccc28939;hb=1fdb1b4e7b1d2b0cabb6483238301b857a6392fa;hp=5bdefc823fca1fcca954c2a7d448d533aa10ee65;hpb=693cc53b426d088e49d746585bf7c5e197fc3998;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsSlcExecutionNotifier.java b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsSlcExecutionNotifier.java index 5bdefc823..45db072b9 100644 --- a/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsSlcExecutionNotifier.java +++ b/runtime/org.argeo.slc.support.activemq/src/main/java/org/argeo/slc/jms/JmsSlcExecutionNotifier.java @@ -1,33 +1,58 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.jms; import java.util.List; import javax.jms.Destination; -import org.argeo.slc.SlcException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.argeo.slc.UnsupportedException; import org.argeo.slc.msg.process.SlcExecutionStatusRequest; +import org.argeo.slc.msg.process.SlcExecutionStepsRequest; import org.argeo.slc.process.SlcExecution; import org.argeo.slc.process.SlcExecutionNotifier; import org.argeo.slc.process.SlcExecutionStep; +import org.springframework.jms.JmsException; import org.springframework.jms.core.JmsTemplate; public class JmsSlcExecutionNotifier implements SlcExecutionNotifier { + private final static Log log = LogFactory + .getLog(JmsSlcExecutionNotifier.class); private JmsTemplate jmsTemplate; - private Destination updateStatusDestination; + private Destination executionEventDestination; + + // private Destination updateStatusDestination; public void updateStatus(SlcExecution slcExecution, String oldStatus, String newStatus) { SlcExecutionStatusRequest req = new SlcExecutionStatusRequest( slcExecution.getUuid(), newStatus); - jmsTemplate.convertAndSend(updateStatusDestination, req); + convertAndSend(req); } public void addSteps(SlcExecution slcExecution, List additionalSteps) { - throw new UnsupportedException(); + SlcExecutionStepsRequest req = new SlcExecutionStepsRequest( + slcExecution.getUuid(), additionalSteps); + convertAndSend(req); } public void newExecution(SlcExecution slcExecution) { @@ -42,8 +67,19 @@ public class JmsSlcExecutionNotifier implements SlcExecutionNotifier { this.jmsTemplate = jmsTemplate; } - public void setUpdateStatusDestination(Destination updateStatusDestination) { - this.updateStatusDestination = updateStatusDestination; + public void setExecutionEventDestination( + Destination executionEventDestination) { + this.executionEventDestination = executionEventDestination; } + protected void convertAndSend(Object req) { + try { + jmsTemplate.convertAndSend(executionEventDestination, req); + } catch (JmsException e) { + log.warn("Send request " + req.getClass() + " to server: " + + e.getMessage()); + if (log.isTraceEnabled()) + log.debug("Original error.", e); + } + } }