List of usage examples for com.rabbitmq.client Envelope isRedeliver
public boolean isRedeliver()
From source file:com.caucho.v5.pipe.rabbit.RabbitPipeImpl.java
License:Open Source License
@Override protected void onInitReceive() { if (_consumerTag != null) { return;/* w w w . j a v a 2 s . c o m*/ } try { boolean isAutoAck = false; _consumerTag = _channel.basicConsume(_config.routingKey(), isAutoAck, new DefaultConsumer(_channel) { @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { RabbitMessage msg = RabbitMessage.newMessage().body(body).properties(properties) .redeliver(envelope.isRedeliver()); long deliveryTag = envelope.getDeliveryTag(); _self.onRabbitReceive(msg, (Void, e) -> { if (e != null) { _channel.basicReject(deliveryTag, false); } else { _channel.basicAck(deliveryTag, false); } }); } }); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.digispherecorp.enterprise.rabbitmq.ra.work.PublishSubcribeRabbitMQWork.java
@Override public void run() { try {/* w w w. ja v a2s .c om*/ Logger.getLogger(QueueRabbitMQWork.class.getName()).log(Level.INFO, "Work Schedule Polling started @ ".concat(uuid)); if (ipsm == null) { try { Class<?> className = Class .forName(((RabbitMQActivationSpec) activationSpec).getDestinationType()); ipsm = (IPublishSubscribeMessage) className.getConstructor().newInstance(); } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { Logger.getLogger(BootStrapRabbitMQWork.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } final Channel channel; RabbitMQConnectionFactoryFacade instance = RabbitMQConnectionFactoryFacade.getInstance(); if (instance.getConnectionRequestInfo(activationSpec) == null) { instance.setConnectionRequestInfo(activationSpec, new RabbitMQConnectionRequestInfo(((RabbitMQActivationSpec) activationSpec).getUser(), ((RabbitMQActivationSpec) activationSpec).getPassword(), ((RabbitMQActivationSpec) activationSpec).getHost(), ((RabbitMQActivationSpec) activationSpec).getPort(), ((RabbitMQActivationSpec) activationSpec).getVirtualHost())); } try { connection = instance.getConnection(); channel = connection.createChannel(); channel.exchangeDeclare(((RabbitMQActivationSpec) activationSpec).getExchangeName(), ipsm.getSubscribeType(), isExchangeDurabe(ipsm)); final Consumer consumer = new DefaultConsumer(channel) { @Override public void handleConsumeOk(String consumerTag) { super.handleConsumeOk(consumerTag); } @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { super.handleDelivery(consumerTag, envelope, properties, body); if (!envelope.isRedeliver()) { try { RabbitMQMessage mQMessage = new RabbitMQMessage(); mQMessage.getMessages().add(body); try { receiveMessages(mQMessage); } catch (ResourceException ex) { Logger.getLogger(QueueRabbitMQWork.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } finally { channel.basicAck(envelope.getDeliveryTag(), true); } } } }; channel.basicConsume(((RabbitMQActivationSpec) activationSpec).getQueueName(), false, consumer); } catch (IOException ex) { Logger.getLogger(RabbitMQResourceAdapter.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } catch (Exception ex) { Logger.getLogger(QueueRabbitMQWork.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }
From source file:com.digispherecorp.enterprise.rabbitmq.ra.work.QueueRabbitMQWork.java
@Override public void run() { try {/*from w w w . j a v a 2 s . c o m*/ Logger.getLogger(QueueRabbitMQWork.class.getName()).log(Level.INFO, "Work Schedule Polling started @ ".concat(uuid)); final Channel channel; RabbitMQConnectionFactoryFacade instance = RabbitMQConnectionFactoryFacade.getInstance(); if (instance.getConnectionRequestInfo(activationSpec) == null) { instance.setConnectionRequestInfo(activationSpec, new RabbitMQConnectionRequestInfo(((RabbitMQActivationSpec) activationSpec).getUser(), ((RabbitMQActivationSpec) activationSpec).getPassword(), ((RabbitMQActivationSpec) activationSpec).getHost(), ((RabbitMQActivationSpec) activationSpec).getPort(), ((RabbitMQActivationSpec) activationSpec).getVirtualHost())); } try { connection = instance.getConnection(); channel = connection.createChannel(); channel.queueDeclarePassive(((RabbitMQActivationSpec) activationSpec).getQueueName()); channel.basicQos(0); final Consumer consumer = new DefaultConsumer(channel) { @Override public void handleConsumeOk(String consumerTag) { super.handleConsumeOk(consumerTag); } @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { super.handleDelivery(consumerTag, envelope, properties, body); if (!envelope.isRedeliver()) { try { RabbitMQMessage mQMessage = new RabbitMQMessage(); mQMessage.getMessages().add(body); try { receiveMessages(mQMessage); } catch (ResourceException ex) { Logger.getLogger(QueueRabbitMQWork.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } finally { channel.basicAck(envelope.getDeliveryTag(), true); } } } }; channel.basicConsume(((RabbitMQActivationSpec) activationSpec).getQueueName(), false, consumer); } catch (IOException ex) { Logger.getLogger(RabbitMQResourceAdapter.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } catch (Exception ex) { Logger.getLogger(QueueRabbitMQWork.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }
From source file:com.shopwiki.roger.MessagingUtil.java
License:Apache License
public static String prettyPrint(Envelope envelope) { StringBuilder sb = new StringBuilder(); sb.append("\t" + "Exchange: " + envelope.getExchange() + "\n"); sb.append("\t" + "RoutingKey: " + envelope.getRoutingKey() + "\n"); sb.append("\t" + "DeliveryTag: " + envelope.getDeliveryTag() + "\n"); sb.append("\t" + "isRedeliver: " + envelope.isRedeliver()); return sb.toString(); }
From source file:com.streamsets.pipeline.stage.origin.rabbitmq.RabbitSource.java
License:Apache License
@Override public String produce(String lastSourceOffset, int maxBatchSize, BatchMaker batchMaker) throws StageException { if (!isConnected() && !conf.advanced.automaticRecoveryEnabled) { // If we don't have automatic recovery enabled and the connection is closed, we should stop the pipeline. throw new StageException(Errors.RABBITMQ_05); }//from w w w.j av a 2 s .c om long maxTime = System.currentTimeMillis() + conf.basicConfig.maxWaitTime; int maxRecords = Math.min(maxBatchSize, conf.basicConfig.maxBatchSize); int numRecords = 0; String nextSourceOffset = lastSourceOffset; while (System.currentTimeMillis() < maxTime && numRecords < maxRecords) { try { RabbitMessage message = messages.poll(conf.basicConfig.maxWaitTime, TimeUnit.MILLISECONDS); if (message == null) { continue; } String recordId = message.getEnvelope().toString(); List<Record> records = parseRabbitMessage(recordId, message.getBody()); for (Record record : records) { Envelope envelope = message.getEnvelope(); BasicProperties properties = message.getProperties(); Record.Header outHeader = record.getHeader(); if (envelope != null) { setHeaderIfNotNull(outHeader, "deliveryTag", envelope.getDeliveryTag()); setHeaderIfNotNull(outHeader, "exchange", envelope.getExchange()); setHeaderIfNotNull(outHeader, "routingKey", envelope.getRoutingKey()); setHeaderIfNotNull(outHeader, "redelivered", envelope.isRedeliver()); } setHeaderIfNotNull(outHeader, "contentType", properties.getContentType()); setHeaderIfNotNull(outHeader, "contentEncoding", properties.getContentEncoding()); setHeaderIfNotNull(outHeader, "deliveryMode", properties.getDeliveryMode()); setHeaderIfNotNull(outHeader, "priority", properties.getPriority()); setHeaderIfNotNull(outHeader, "correlationId", properties.getCorrelationId()); setHeaderIfNotNull(outHeader, "replyTo", properties.getReplyTo()); setHeaderIfNotNull(outHeader, "expiration", properties.getExpiration()); setHeaderIfNotNull(outHeader, "messageId", properties.getMessageId()); setHeaderIfNotNull(outHeader, "timestamp", properties.getTimestamp()); setHeaderIfNotNull(outHeader, "messageType", properties.getType()); setHeaderIfNotNull(outHeader, "userId", properties.getUserId()); setHeaderIfNotNull(outHeader, "appId", properties.getAppId()); Map<String, Object> inHeaders = properties.getHeaders(); if (inHeaders != null) { for (Map.Entry<String, Object> pair : inHeaders.entrySet()) { // I am concerned about overlapping with the above headers but it seems somewhat unlikely // in addition the behavior of copying these attributes in with no custom prefix is // how the jms origin behaves setHeaderIfNotNull(outHeader, pair.getKey(), pair.getValue()); } } batchMaker.addRecord(record); nextSourceOffset = outHeader.getAttribute("deliveryTag"); numRecords++; } } catch (InterruptedException e) { LOG.warn("Pipeline is shutting down."); } } return nextSourceOffset; }
From source file:org.apache.airavata.messaging.core.impl.ExperimentConsumer.java
License:Apache License
@Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { Message message = new Message(); try {// ww w . j a v a 2s . c o m 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); } }
From source file:org.apache.airavata.messaging.core.impl.ProcessConsumer.java
License:Apache License
@Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties basicProperties, byte[] body) throws IOException { Message message = new Message(); try {/* www . j a v a 2s .c o m*/ ThriftUtils.createThriftFromBytes(body, message); TBase event = null; String gatewayId = null; long deliveryTag = envelope.getDeliveryTag(); if (message.getMessageType().equals(MessageType.LAUNCHPROCESS)) { ProcessSubmitEvent processSubmitEvent = new ProcessSubmitEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), processSubmitEvent); log.info(" Message Received with message id '" + message.getMessageId() + " and with message type:" + message.getMessageType() + ", for processId:" + processSubmitEvent.getProcessId() + ", expId:" + processSubmitEvent.getExperimentId()); event = processSubmitEvent; gatewayId = processSubmitEvent.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); } }
From source file:org.apache.airavata.messaging.core.impl.RabbitMQProcessLaunchConsumer.java
License:Apache License
public String listen(final MessageHandler handler) throws AiravataException { try {/*from w ww .j ava 2s . c om*/ messageHandler = handler; Map<String, Object> props = handler.getProperties(); final Object routing = props.get(MessagingConstants.RABBIT_ROUTING_KEY); if (routing == null) { throw new IllegalArgumentException("The routing key must be present"); } List<String> keys = new ArrayList<String>(); if (routing instanceof List) { for (Object o : (List) routing) { keys.add(o.toString()); } } else if (routing instanceof String) { keys.add((String) routing); } String queueName = (String) props.get(MessagingConstants.RABBIT_QUEUE); String consumerTag = (String) props.get(MessagingConstants.RABBIT_CONSUMER_TAG); if (queueName == null) { if (!channel.isOpen()) { channel = connection.createChannel(); channel.basicQos(prefetchCount); // channel.exchangeDeclare(taskLaunchExchangeName, "fanout"); } queueName = channel.queueDeclare().getQueue(); } else { channel.queueDeclare(queueName, durableQueue, false, false, null); } final String id = getId(keys, queueName); if (queueDetailsMap.containsKey(id)) { throw new IllegalStateException("This subscriber is already defined for this Consumer, " + "cannot define the same subscriber twice"); } if (consumerTag == null) { consumerTag = "default"; } // bind all the routing keys // for (String routingKey : keys) { // channel.queueBind(queueName, taskLaunchExchangeName, routingKey); // } // autoAck=false, we will ack after task is done channel.basicConsume(queueName, false, consumerTag, new QueueingConsumer(channel) { @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) { Message message = new Message(); try { ThriftUtils.createThriftFromBytes(body, message); TBase event = null; String gatewayId = null; long deliveryTag = envelope.getDeliveryTag(); if (message.getMessageType().equals(MessageType.LAUNCHPROCESS)) { ProcessSubmitEvent processSubmitEvent = new ProcessSubmitEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), processSubmitEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' for experimentId:" + " " + processSubmitEvent.getProcessId()); event = processSubmitEvent; gatewayId = processSubmitEvent.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 Consumer. 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 and queueName " + id; log.warn(msg, e); } } @Override public void handleCancel(String consumerTag) throws IOException { super.handleCancel(consumerTag); log.info("Consumer cancelled : " + consumerTag); } }); // save the name for deleting the queue queueDetailsMap.put(id, new QueueDetails(queueName, keys)); return id; } catch (Exception e) { String msg = "could not open channel for exchange " + taskLaunchExchangeName; log.error(msg); throw new AiravataException(msg, e); } }
From source file:org.apache.airavata.messaging.core.impl.RabbitMQStatusConsumer.java
License:Apache License
public String listen(final MessageHandler handler) throws AiravataException { try {//ww w.ja va 2s.co m Map<String, Object> props = handler.getProperties(); final Object routing = props.get(MessagingConstants.RABBIT_ROUTING_KEY); if (routing == null) { throw new IllegalArgumentException("The routing key must be present"); } List<String> keys = new ArrayList<String>(); if (routing instanceof List) { for (Object o : (List) routing) { keys.add(o.toString()); } } else if (routing instanceof String) { keys.add((String) routing); } String queueName = (String) props.get(MessagingConstants.RABBIT_QUEUE); String consumerTag = (String) props.get(MessagingConstants.RABBIT_CONSUMER_TAG); if (queueName == null) { if (!channel.isOpen()) { channel = connection.createChannel(); channel.exchangeDeclare(exchangeName, "topic", false); } queueName = channel.queueDeclare().getQueue(); } else { channel.queueDeclare(queueName, true, false, false, null); } final String id = getId(keys, queueName); if (queueDetailsMap.containsKey(id)) { throw new IllegalStateException("This subscriber is already defined for this Consumer, " + "cannot define the same subscriber twice"); } if (consumerTag == null) { consumerTag = "default"; } // bind all the routing keys for (String routingKey : keys) { channel.queueBind(queueName, exchangeName, routingKey); } channel.basicConsume(queueName, true, consumerTag, new DefaultConsumer(channel) { @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) { Message message = new Message(); try { ThriftUtils.createThriftFromBytes(body, message); TBase event = null; String gatewayId = null; if (message.getMessageType().equals(MessageType.EXPERIMENT)) { ExperimentStatusChangeEvent experimentStatusChangeEvent = new ExperimentStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), experimentStatusChangeEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' with status " + experimentStatusChangeEvent.getState()); event = experimentStatusChangeEvent; gatewayId = experimentStatusChangeEvent.getGatewayId(); } else if (message.getMessageType().equals(MessageType.PROCESS)) { ProcessStatusChangeEvent processStatusChangeEvent = new ProcessStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), processStatusChangeEvent); log.debug("Message Recieved with message id :" + message.getMessageId() + " and with " + "message type " + message.getMessageType() + " with status " + processStatusChangeEvent.getState()); event = processStatusChangeEvent; gatewayId = processStatusChangeEvent.getProcessIdentity().getGatewayId(); } else if (message.getMessageType().equals(MessageType.TASK)) { TaskStatusChangeEvent taskStatusChangeEvent = new TaskStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskStatusChangeEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' with status " + taskStatusChangeEvent.getState()); event = taskStatusChangeEvent; gatewayId = taskStatusChangeEvent.getTaskIdentity().getGatewayId(); } else if (message.getMessageType() == MessageType.PROCESSOUTPUT) { TaskOutputChangeEvent taskOutputChangeEvent = new TaskOutputChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskOutputChangeEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType()); event = taskOutputChangeEvent; gatewayId = taskOutputChangeEvent.getTaskIdentity().getGatewayId(); } else if (message.getMessageType().equals(MessageType.JOB)) { JobStatusChangeEvent jobStatusChangeEvent = new JobStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), jobStatusChangeEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' with status " + jobStatusChangeEvent.getState()); event = jobStatusChangeEvent; gatewayId = jobStatusChangeEvent.getJobIdentity().getGatewayId(); } else if (message.getMessageType().equals(MessageType.LAUNCHPROCESS)) { TaskSubmitEvent taskSubmitEvent = new TaskSubmitEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskSubmitEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' for experimentId: " + taskSubmitEvent.getExperimentId() + "and taskId: " + taskSubmitEvent.getTaskId()); event = taskSubmitEvent; gatewayId = taskSubmitEvent.getGatewayId(); } else if (message.getMessageType().equals(MessageType.TERMINATEPROCESS)) { TaskTerminateEvent taskTerminateEvent = new TaskTerminateEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskTerminateEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' for experimentId: " + taskTerminateEvent.getExperimentId() + "and taskId: " + taskTerminateEvent.getTaskId()); event = taskTerminateEvent; gatewayId = null; } MessageContext messageContext = new MessageContext(event, message.getMessageType(), message.getMessageId(), gatewayId); messageContext.setUpdatedTime(AiravataUtils.getTime(message.getUpdatedTime())); messageContext.setIsRedeliver(envelope.isRedeliver()); handler.onMessage(messageContext); } catch (TException e) { String msg = "Failed to de-serialize the thrift message, from routing keys and queueName " + id; log.warn(msg, e); } } }); // save the name for deleting the queue queueDetailsMap.put(id, new QueueDetails(queueName, keys)); return id; } catch (Exception e) { String msg = "could not open channel for exchange " + exchangeName; log.error(msg); throw new AiravataException(msg, e); } }
From source file:org.apache.airavata.messaging.core.impl.StatusConsumer.java
License:Apache License
@Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { Message message = new Message(); try {/*ww w .ja v a 2 s . c om*/ ThriftUtils.createThriftFromBytes(body, message); TBase event = null; String gatewayId = null; if (message.getMessageType().equals(MessageType.EXPERIMENT)) { ExperimentStatusChangeEvent experimentStatusChangeEvent = new ExperimentStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), experimentStatusChangeEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' with status " + experimentStatusChangeEvent.getState()); event = experimentStatusChangeEvent; gatewayId = experimentStatusChangeEvent.getGatewayId(); } else if (message.getMessageType().equals(MessageType.PROCESS)) { ProcessStatusChangeEvent processStatusChangeEvent = new ProcessStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), processStatusChangeEvent); log.debug("Message Recieved with message id :" + message.getMessageId() + " and with " + "message type " + message.getMessageType() + " with status " + processStatusChangeEvent.getState()); event = processStatusChangeEvent; gatewayId = processStatusChangeEvent.getProcessIdentity().getGatewayId(); } else if (message.getMessageType().equals(MessageType.TASK)) { TaskStatusChangeEvent taskStatusChangeEvent = new TaskStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskStatusChangeEvent); log.debug( " Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' with status " + taskStatusChangeEvent.getState()); event = taskStatusChangeEvent; gatewayId = taskStatusChangeEvent.getTaskIdentity().getGatewayId(); } else if (message.getMessageType() == MessageType.PROCESSOUTPUT) { TaskOutputChangeEvent taskOutputChangeEvent = new TaskOutputChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskOutputChangeEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType()); event = taskOutputChangeEvent; gatewayId = taskOutputChangeEvent.getTaskIdentity().getGatewayId(); } else if (message.getMessageType().equals(MessageType.JOB)) { JobStatusChangeEvent jobStatusChangeEvent = new JobStatusChangeEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), jobStatusChangeEvent); log.debug( " Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' with status " + jobStatusChangeEvent.getState()); event = jobStatusChangeEvent; gatewayId = jobStatusChangeEvent.getJobIdentity().getGatewayId(); } else if (message.getMessageType().equals(MessageType.LAUNCHPROCESS)) { TaskSubmitEvent taskSubmitEvent = new TaskSubmitEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskSubmitEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' for experimentId: " + taskSubmitEvent.getExperimentId() + "and taskId: " + taskSubmitEvent.getTaskId()); event = taskSubmitEvent; gatewayId = taskSubmitEvent.getGatewayId(); } else if (message.getMessageType().equals(MessageType.TERMINATEPROCESS)) { TaskTerminateEvent taskTerminateEvent = new TaskTerminateEvent(); ThriftUtils.createThriftFromBytes(message.getEvent(), taskTerminateEvent); log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType() + "' for experimentId: " + taskTerminateEvent.getExperimentId() + "and taskId: " + taskTerminateEvent.getTaskId()); event = taskTerminateEvent; gatewayId = null; } MessageContext messageContext = new MessageContext(event, message.getMessageType(), message.getMessageId(), gatewayId); messageContext.setUpdatedTime(AiravataUtils.getTime(message.getUpdatedTime())); messageContext.setIsRedeliver(envelope.isRedeliver()); handler.onMessage(messageContext); } catch (TException e) { String msg = "Failed to de-serialize the thrift message, from routing keys: " + envelope.getRoutingKey(); log.warn(msg, e); } }