use of org.apache.airavata.model.messaging.event.ExperimentSubmitEvent in project airavata by apache.
the class ExperimentConsumer method handleDelivery.
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
Message message = new Message();
try {
ThriftUtils.createThriftFromBytes(body, message);
long deliveryTag = envelope.getDeliveryTag();
if (message.getMessageType() == MessageType.EXPERIMENT || message.getMessageType() == MessageType.EXPERIMENT_CANCEL) {
TBase event = null;
String gatewayId = null;
ExperimentSubmitEvent experimentEvent = new ExperimentSubmitEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), experimentEvent);
log.info(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' for experimentId:" + " " + experimentEvent.getExperimentId());
event = experimentEvent;
gatewayId = experimentEvent.getGatewayId();
MessageContext messageContext = new MessageContext(event, message.getMessageType(), message.getMessageId(), gatewayId, deliveryTag);
messageContext.setUpdatedTime(AiravataUtils.getTime(message.getUpdatedTime()));
messageContext.setIsRedeliver(envelope.isRedeliver());
handler.onMessage(messageContext);
} else {
log.error("{} message type is not handle in ProcessLaunch Subscriber. Sending ack for " + "delivery tag {} ", message.getMessageType().name(), deliveryTag);
sendAck(deliveryTag);
}
} catch (TException e) {
String msg = "Failed to de-serialize the thrift message, from routing keys:" + envelope.getRoutingKey();
log.warn(msg, e);
}
}
use of org.apache.airavata.model.messaging.event.ExperimentSubmitEvent in project airavata by apache.
the class AiravataServerHandler method submitCancelExperiment.
private void submitCancelExperiment(String gatewayId, String experimentId) throws AiravataException {
ExperimentSubmitEvent event = new ExperimentSubmitEvent(experimentId, gatewayId);
MessageContext messageContext = new MessageContext(event, MessageType.EXPERIMENT_CANCEL, "CANCEL.EXP-" + UUID.randomUUID().toString(), gatewayId);
messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
experimentPublisher.publish(messageContext);
}
use of org.apache.airavata.model.messaging.event.ExperimentSubmitEvent in project airavata by apache.
the class AiravataServerHandler method submitExperiment.
private void submitExperiment(String gatewayId, String experimentId) throws AiravataException {
ExperimentSubmitEvent event = new ExperimentSubmitEvent(experimentId, gatewayId);
MessageContext messageContext = new MessageContext(event, MessageType.EXPERIMENT, "LAUNCH.EXP-" + UUID.randomUUID().toString(), gatewayId);
messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
experimentPublisher.publish(messageContext);
}
Aggregations