method receives a message from Synergy Scheduler notifying of Job completion,
            builds up a list of dependant TreeNodes/Jobs and triggers their ManagedThreadHandlers, if applicable
            :param message: <MqTransmission> mq message
509858
def _mq_callback(self, message):
        
        try:
            self.logger.info('JobStatusListener {')

            mq_request = MqTransmission.from_json(message.body)
            job_record = self.job_dao.get_by_id(mq_request.process_name, mq_request.record_db_id)

            # step 1: identify dependant tree nodes
            tree_obj = self.timetable.get_tree(job_record.process_name)
            tree_node = tree_obj.get_node(job_record.process_name, job_record.timeperiod)
            dependant_nodes = self.timetable._find_dependant_tree_nodes(tree_node)

            # step 2: form list of handlers to trigger
            handlers_to_trigger = set()
            for node in dependant_nodes:
                state_machine = self.scheduler.state_machine_for(node.process_name)
                if state_machine.run_on_active_timeperiod:
                    # ignore dependant processes whose state machine can run on an active timeperiod
                    continue
                handlers_to_trigger.add(self.scheduler.managed_handlers[node.process_name])

            # step 3: iterate the list of handlers and trigger them
            for handler in handlers_to_trigger:
                assert isinstance(handler, ManagedThreadHandler)
                handler.trigger()

        except KeyError:
            self.logger.error('Access error for {0}'.format(message.body), exc_info=True)
        except Exception:
            self.logger.error('Error during ManagedThreadHandler.trigger call {0}'.format(message.body), exc_info=True)
        finally:
            self.consumer.acknowledge(message.delivery_tag)
            self.logger.info('JobStatusListener }')
1103349
def dispatch(self, message: Message) -> Iterator[Any]:
        
        if "text" in message:
            text = message["text"] or ""
        elif "message" in message:
            text = message["message"].get("text", "")
        else:
            text = ""

        msg_subtype = message.get("subtype")

        for subtype, matchs in itertools.chain(
            self._routes[message["channel"]].items(), self._routes["*"].items()
        ):
            if msg_subtype == subtype or subtype is None:
                for match, endpoints in matchs.items():
                    if match.search(text):
                        yield from endpoints
476622
private void deliverReadyTxns() {
        // First, pull all the sequenced messages, if any.
        VoltMessage m = m_replaySequencer.poll();
        while(m != null) {
            deliver(m);
            m = m_replaySequencer.poll();
        }
        // Then, try to pull all the drainable messages, if any.
        m = m_replaySequencer.drain();
        while (m != null) {
            if (m instanceof Iv2InitiateTaskMessage) {
                // Send IGNORED response for all SPs
                Iv2InitiateTaskMessage task = (Iv2InitiateTaskMessage) m;
                final InitiateResponseMessage response = new InitiateResponseMessage(task);
                response.setResults(new ClientResponseImpl(ClientResponse.UNEXPECTED_FAILURE,
                            new VoltTable[0],
                            ClientResponseImpl.IGNORED_TRANSACTION));
                m_mailbox.send(response.getInitiatorHSId(), response);
            }
            m = m_replaySequencer.drain();
        }
    }
613351
public int handleMessage(BaseMessage message)
    {
        Utility.getLogger().info("RemoteQueue handling message " + message);
        if (message.getProcessedByClientSession() == this.getParentSession())
            return DBConstants.NORMAL_RETURN;     // Do not process this message (the client has already taken care of it).
//?        if (message.getProcessedByClientSession() instanceof RemoteObject)
//?            if (this.getParentSession() instanceof RemoteObject) // Always
//?                if (((RemoteObject)this.getParentSession()).getRef().remoteEquals(((RemoteObject)message.getProcessedByClientSession()).getRef()))
//?                    return DBConstants.NORMAL_RETURN;   // Same client.
        if (message == m_messageLastMessage)
            return DBConstants.NORMAL_RETURN;   // Don't send a message to the same client twice.
        m_messageLastMessage = message;
        this.getMessageStack().sendMessage(message);
        return DBConstants.NORMAL_RETURN;
    }
624829
public void sendMessage(Message message)
    {
        try   {
            if (((RemoteMessageQueue)this.getMessageQueue()).isSendRemoteMessage((BaseMessage)message) == false)
                return;
            if (((BaseMessage)message).isProcessedByServer())
                return;     // Don't send back down (the server already processed it).
            if (((BaseMessage)message).isConsumed())
                return;     // Don't send if already handled.
            if (MessageConstants.LOCAL_QUEUE.equalsIgnoreCase(((BaseMessage)message).getMessageHeader().getQueueType()))
                return;     // Local queue only
            synchronized (m_sendQueue)
            {   // In case this is called from another task
                m_sendQueue.sendMessage(message);
            }
        } catch (RemoteException ex)    {
            ex.printStackTrace();
        }
    }
1202252
protected void notifyAllPendingSenders(String message) {
        for (ChannelFuture future : _futureMap.values()) {
            future.setFailure(new Error(message));
        }
    }
727094
public static void queueMessage(final String level, final String message) {
		try {
			LogAppender<LogEvent> appender = LogManager.getAppender();

			if (appender != null) {
				LogEvent.Builder builder = LogEvent.newBuilder();
				builder.level(level);
				builder.message(message);
				
				if ((level != null) && ("ERROR".equals(level.toUpperCase()))) {
					StackTraceElement[] stackTrace = new Throwable().getStackTrace();

					if ((stackTrace != null) && (1 < stackTrace.length)) {
						StackTraceElement caller = stackTrace[1];
						builder.className(caller.getClassName());
						builder.methodName(caller.getMethodName());
						builder.lineNumber(caller.getLineNumber());						
					}
				}
				
				appender.append(builder.build());
			}
		} catch (Throwable t) {
			LOGGER.info("Unable to queue message to Stackify Log API service: {} {}", level, message, t);
		}
	}
1031942
def HandleMessage(self, message):
    
    self._is_active = True
    try:
      action_cls = actions.ActionPlugin.classes.get(message.name)
      if action_cls is None:
        raise RuntimeError("Client action %r not known" % message.name)

      action = action_cls(grr_worker=self)

      # Write the message to the transaction log.
      self.transaction_log.Write(message)

      # Heartbeat so we have the full period to work on this message.
      action.Progress()
      action.Execute(message)

      # If we get here without exception, we can remove the transaction.
      self.transaction_log.Clear()
    finally:
      self._is_active = False
      # We want to send ClientStats when client action is complete.
      self.stats_collector.RequestSend()
984003
@Override
    public void handleMessage(Message msg) {
        if (msg.what == ASYNC) {
            mAsyncDispatcher.dispatch();
        } else if (msg.what == SYNC) {
            mSyncDispatcher.dispatch();
        } else super.handleMessage(msg);
    }
383064
function collectMessage(message, processingQueue, cb) {
        const threshold = message.getRetryThreshold();
        const messageRetryThreshold = typeof threshold === 'number' ? threshold : dispatcher.getMessageRetryThreshold();

        const delay = message.getRetryDelay();
        const messageRetryDelay = typeof delay === 'number' ? delay : dispatcher.getMessageRetryDelay();

        let destQueueName = null;
        let delayed = false;
        let requeued = false;

        const multi = client.multi();

        /**
         * Only exceptions from non periodic messages are handled.
         * Periodic messages are ignored once they are delivered to a consumer.
         */
        if (!dispatcher.isPeriodic(message)) {
            const uuid = message.getId();

            /**
             * Attempts
             */
            const attempts = increaseAttempts(message);

            /**
             *
             */
            if (attempts < messageRetryThreshold) {
                debug(`Trying to consume message ID [${uuid}] again (attempts: [${attempts}]) ...`);
                if (messageRetryDelay) {
                    debug(`Scheduling message ID [${uuid}]  (delay: [${messageRetryDelay}])...`);
                    message.setScheduledDelay(messageRetryDelay);
                    dispatcher.schedule(message, multi);
                    delayed = true;
                } else {
                    debug(`Message ID [${uuid}] is going to be enqueued immediately...`);
                    destQueueName = keyQueueName;
                    requeued = true;
                }
            } else {
                debug(`Message ID [${uuid}] has exceeded max retry threshold...`);
                destQueueName = keyQueueNameDead;
            }

            /**
             *
             */
            if (destQueueName) {
                debug(`Moving message [${uuid}] to queue [${destQueueName}]...`);
                multi.lpush(destQueueName, message.toString());
            }
            multi.rpop(processingQueue);
            multi.exec((err) => {
                if (err) cb(err);
                else {
                    if (dispatcher.isTest()) {
                        if (requeued) dispatcher.emit(events.MESSAGE_REQUEUED, message);
                        else if (delayed) dispatcher.emit(events.MESSAGE_DELAYED, message);
                        else dispatcher.emit(events.MESSAGE_DEAD_LETTER, message);
                    }
                    cb();
                }
            });
        } else {
            client.rpop(processingQueue, cb);
        }
    }
91493
function handleMessageFromMainThread(message) {
    var kind = message.data.kind;
    var payload = message.data.payload;

    if (kind === messageKind.init) {
      graph = fromjson(payload.graph);
      var options = JSON.parse(payload.options);

      init(graph, options);
    } else if (kind === messageKind.step) {
      step();
    } else if (kind === messageKind.pinNode) {
      pinNode(payload.nodeId, payload.isPinned);
    } else if (kind === messageKind.setNodePosition) {
      setNodePosition(payload.nodeId, payload.x, payload.y, payload.z);
    }
    // TODO: listen for graph changes from main thread and update layout here.
  }
1065821
private QYBaseRespMsg processMessageHandle(QYBaseReqMsg msg){
        if(CollectionUtil.isEmpty(messageHandles)){
            synchronized (LOCK){
                messageHandles = this.initMessageHandles();
            }
        }
        if(CollectionUtil.isNotEmpty(messageHandles)){
            for(QYMessageHandle messageHandle : messageHandles){
                QYBaseRespMsg resultMsg = null;
                boolean result;
                try{
                    result = messageHandle.beforeHandle(msg);
                }catch (Exception e){
                    result = false;
                }
                if(result){
                    resultMsg = messageHandle.handle(msg);
                }
                if(BeanUtil.nonNull(resultMsg)){
                    return resultMsg;
                }
            }
        }
        return null;
    }
428076
def _process_message(self, msg):
        
        self._logger.info(
            'Processing Message(topic={}, partition={}, offset={}) ...'
            .format(msg.topic, msg.partition, msg.offset))
        try:
            job = self._deserializer(msg.value)
            job_repr = get_call_repr(job.func, *job.args, **job.kwargs)

        except Exception as err:
            self._logger.exception('Job was invalid: {}'.format(err))
            self._execute_callback('invalid', msg, None, None, None, None)
        else:
            self._logger.info('Executing job {}: {}'.format(job.id, job_repr))

            if job.timeout:
                timer = threading.Timer(job.timeout, _thread.interrupt_main)
                timer.start()
            else:
                timer = None
            try:
                res = job.func(*job.args, **job.kwargs)
            except KeyboardInterrupt:
                self._logger.error(
                    'Job {} timed out or was interrupted'.format(job.id))
                self._execute_callback('timeout', msg, job, None, None, None)
            except Exception as err:
                self._logger.exception(
                    'Job {} raised an exception:'.format(job.id))
                tb = traceback.format_exc()
                self._execute_callback('failure', msg, job, None, err, tb)
            else:
                self._logger.info('Job {} returned: {}'.format(job.id, res))
                self._execute_callback('success', msg, job, res, None, None)
            finally:
                if timer is not None:
                    timer.cancel()
1209315
@SuppressWarnings("checkstyle:illegalcatch")
  private void deliverMessageToTask(final byte[] message) throws TaskMessageHandlerFailure {
    try {
      this.fMessageHandler.get().onNext(new DriverMessageImpl(message));
    } catch (final Throwable throwable) {
      throw new TaskMessageHandlerFailure(throwable);
    }
  }
507931
public synchronized boolean receive(Tree message) {

		// Update timestamp
		if (timeoutMillis > 0) {
			timeoutAt = System.currentTimeMillis() + timeoutMillis;
		}

		// Check sequence number
		long seq = message.get("seq", -1);
		if (seq > -1) {
			if (seq - 1 == prevSeq) {
				prevSeq = seq;
			} else {

				// Process later
				pool.put(seq, message);
				return false;
			}
		} else {
			prevSeq = -1;
		}

		// Process current message
		boolean close = processMessage(message);

		// Process pooled messages
		long nextSeq = prevSeq;
		while (true) {
			Tree nextMessage = pool.remove(++nextSeq);
			if (nextMessage == null) {
				break;
			}
			prevSeq = nextSeq;
			if (processMessage(nextMessage)) {
				close = true;
			}
		}

		// True = remove stream from registry
		return close;
	}
1345845
private void dispatchMessage(PushMessageListener listener, RemoteMessage message) {
        if (listener != null) {
            mainThreadHandler.post(() -> listener.onMessageReceived(message));
        }
    }
486086
def _mq_callback(self, message):
        
        try:
            raw_data = RawData.from_json(message.body)
            try:
                session = self.ss_dao.find_by_session_id(raw_data.domain_name, raw_data.session_id)

                # update the click_xxx info
                session = self.update_session_body(raw_data, session)

                epoch_current = calendar.timegm(raw_data.timestamp.replace(tzinfo=None).utctimetuple())
                epoch_start = time_helper.session_to_epoch(session.timeperiod)
                session.browsing_history.total_duration = (epoch_current - epoch_start) / 1000

                index = session.browsing_history.number_of_entries
                self.add_entry(session, index, raw_data)
                self.performance_tracker.update.increment_success()
            except LookupError:
                # insert the record
                session = SingleSession()

                # input data constraints - both session_id and user_id must be present in MQ message
                session.key = (raw_data.domain_name,
                               time_helper.datetime_to_synergy(QUALIFIER_HOURLY, raw_data.timestamp),
                               raw_data.session_id)
                session.ip = raw_data.ip
                session.total_duration = 0

                session = self.update_session_body(raw_data, session)
                self.add_entry(session, 0, raw_data)
                self.performance_tracker.insert.increment_success()

            self.ss_dao.update(session)
            self.consumer.acknowledge(message.delivery_tag)
        except AutoReconnect as e:
            self.logger.error('MongoDB connection error: {0}\nRe-queueing message & exiting the worker'.format(e))
            self.consumer.reject(message.delivery_tag)
            raise e
        except (KeyError, IndexError) as e:
            self.logger.error('Error is considered Unrecoverable: {0}\nCancelled message: {1}'.format(e, message.body))
            self.consumer.cancel(message.delivery_tag)
        except Exception as e:
            self.logger.error('Error is considered Recoverable: {0}\nRe-queueing message: {1}'.format(e, message.body))
            self.consumer.reject(message.delivery_tag)