use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.
the class MessageConsumer method handleDelivery.
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
Message message = new Message();
try {
logger.info("handleDelivery() -> Handling message delivery. Consumer Tag : " + consumerTag);
ThriftUtils.createThriftFromBytes(body, message);
DBEventMessage dBEventMessage = new DBEventMessage();
ThriftUtils.createThriftFromBytes(message.getEvent(), dBEventMessage);
MessageContext messageContext = new MessageContext((TBase) dBEventMessage, message.getMessageType(), message.getMessageId(), "gatewayId", envelope.getDeliveryTag());
handler.onMessage(messageContext);
// sendAck(deliveryTag);
} catch (TException e) {
logger.error("handleDelivery() -> Error handling delivery. Consumer Tag : " + consumerTag, e);
}
}
use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.
the class GFACPassiveJobSubmitter method terminate.
/**
* Submit the experiment the terminate.queue job queue and remove the experiment from shared launch.queue
* @param experimentId
* @param processId
* @return
* @throws OrchestratorException
*/
public boolean terminate(String experimentId, String processId, String tokenId) throws OrchestratorException {
String gatewayId = null;
try {
CredentialReader credentialReader = GFacUtils.getCredentialReader();
if (credentialReader != null) {
try {
gatewayId = credentialReader.getGatewayID(tokenId);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
}
}
if (gatewayId == null || gatewayId.isEmpty()) {
gatewayId = ServerSettings.getDefaultUserGateway();
}
ProcessTerminateEvent processTerminateEvent = new ProcessTerminateEvent(processId, gatewayId, tokenId);
MessageContext messageContext = new MessageContext(processTerminateEvent, MessageType.TERMINATEPROCESS, "LAUNCH.TERMINATE-" + UUID.randomUUID().toString(), gatewayId);
messageContext.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
publisher.publish(messageContext);
return true;
} catch (Exception e) {
throw new OrchestratorException(e);
}
}
use of org.apache.airavata.messaging.core.MessageContext in project airavata by apache.
the class SharingServiceDBEventMessagingFactory method registerSharingServiceWithPublishers.
/**
* Register sharing service with stated publishers
* @param publishers
* @return
* @throws AiravataException
*/
public static boolean registerSharingServiceWithPublishers(List<String> publishers) throws AiravataException {
for (String publisher : publishers) {
log.info("Sending service discovery message. Publisher : " + publisher + ", Subscriber : " + DBEventService.SHARING.toString());
DBEventSubscriber dbEventSubscriber = new DBEventSubscriber(DBEventService.SHARING.toString());
DBEventMessageContext dbEventMessageContext = new DBEventMessageContext();
dbEventMessageContext.setSubscriber(dbEventSubscriber);
DBEventMessage dbEventMessage = new DBEventMessage(DBEventType.SUBSCRIBER, dbEventMessageContext, publisher);
MessageContext messageContext = new MessageContext(dbEventMessage, MessageType.DB_EVENT, "", "");
getDBEventPublisher().publish(messageContext, DBEventManagerConstants.getRoutingKey(DBEventService.DB_EVENT.toString()));
}
return true;
}
use of org.apache.airavata.messaging.core.MessageContext 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.messaging.core.MessageContext 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