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);
}
}
Aggregations