Search in sources :

Example 6 with Message

use of org.apache.airavata.model.messaging.event.Message in project airavata by apache.

the class RabbitMQPublisher method publish.

@Override
public void publish(MessageContext messageContext) throws AiravataException {
    try {
        byte[] body = ThriftUtils.serializeThriftObject(messageContext.getEvent());
        Message message = new Message();
        message.setEvent(body);
        message.setMessageId(messageContext.getMessageId());
        message.setMessageType(messageContext.getType());
        message.setUpdatedTime(messageContext.getUpdatedTime().getTime());
        String routingKey = routingKeySupplier.apply(messageContext);
        // log.info("publish messageId:" + messageContext.getMessageId() + ", messageType:" + messageContext.getType() + ", to routingKey:" + routingKey);
        byte[] messageBody = ThriftUtils.serializeThriftObject(message);
        send(messageBody, routingKey);
    } catch (TException e) {
        String msg = "Error while deserializing the object";
        log.error(msg, e);
        throw new AiravataException(msg, e);
    } catch (Exception e) {
        String msg = "Error while sending to rabbitmq";
        log.error(msg, e);
        throw new AiravataException(msg, e);
    }
}
Also used : TException(org.apache.thrift.TException) Message(org.apache.airavata.model.messaging.event.Message) TException(org.apache.thrift.TException) IOException(java.io.IOException) ShutdownSignalException(com.rabbitmq.client.ShutdownSignalException) AiravataException(org.apache.airavata.common.exception.AiravataException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Aggregations

Message (org.apache.airavata.model.messaging.event.Message)6 TException (org.apache.thrift.TException)6 MessageContext (org.apache.airavata.messaging.core.MessageContext)4 TBase (org.apache.thrift.TBase)3 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)2 IOException (java.io.IOException)2 AiravataException (org.apache.airavata.common.exception.AiravataException)2 DBEventMessage (org.apache.airavata.model.dbevent.DBEventMessage)1 DBEventMessageContext (org.apache.airavata.model.dbevent.DBEventMessageContext)1 ExperimentStatusChangeEvent (org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent)1 ExperimentSubmitEvent (org.apache.airavata.model.messaging.event.ExperimentSubmitEvent)1 JobStatusChangeEvent (org.apache.airavata.model.messaging.event.JobStatusChangeEvent)1 ProcessStatusChangeEvent (org.apache.airavata.model.messaging.event.ProcessStatusChangeEvent)1 ProcessSubmitEvent (org.apache.airavata.model.messaging.event.ProcessSubmitEvent)1 TaskOutputChangeEvent (org.apache.airavata.model.messaging.event.TaskOutputChangeEvent)1 TaskStatusChangeEvent (org.apache.airavata.model.messaging.event.TaskStatusChangeEvent)1 TaskSubmitEvent (org.apache.airavata.model.messaging.event.TaskSubmitEvent)1 TaskTerminateEvent (org.apache.airavata.model.messaging.event.TaskTerminateEvent)1