Search in sources :

Example 1 with ExperimentSubmitEvent

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);
    }
}
Also used : TException(org.apache.thrift.TException) Message(org.apache.airavata.model.messaging.event.Message) TBase(org.apache.thrift.TBase) ExperimentSubmitEvent(org.apache.airavata.model.messaging.event.ExperimentSubmitEvent) MessageContext(org.apache.airavata.messaging.core.MessageContext)

Example 2 with ExperimentSubmitEvent

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);
}
Also used : ExperimentSubmitEvent(org.apache.airavata.model.messaging.event.ExperimentSubmitEvent) MessageContext(org.apache.airavata.messaging.core.MessageContext)

Example 3 with ExperimentSubmitEvent

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);
}
Also used : ExperimentSubmitEvent(org.apache.airavata.model.messaging.event.ExperimentSubmitEvent) MessageContext(org.apache.airavata.messaging.core.MessageContext)

Aggregations

MessageContext (org.apache.airavata.messaging.core.MessageContext)3 ExperimentSubmitEvent (org.apache.airavata.model.messaging.event.ExperimentSubmitEvent)3 Message (org.apache.airavata.model.messaging.event.Message)1 TBase (org.apache.thrift.TBase)1 TException (org.apache.thrift.TException)1