Process a queue message from activity channel.
962589
def _process_queue_message(self, message_queue, new_queue_found, batch_exit,
                               start_time, timeout, batch_timeout):
        """"""

        for queue in self._filter_queues([message_queue]):
            if queue not in self._queue_set:
                if not new_queue_found:
                    new_queue_found = True
                    batch_exit = time.time() + batch_timeout
                    # Limit batch_exit to max timeout
                    if batch_exit > start_time + timeout:
                        batch_exit = start_time + timeout
                self._queue_set.add(queue)
                self.log.debug('new queue', queue=queue)

        return new_queue_found, batch_exit
1237528
def get(self, queue, no_ack=False):
        
        raw_message = self.channel.basic_get(queue, no_ack=no_ack)
        if not raw_message:
            return None
        return self.message_to_python(raw_message)
1370116
public void execute() throws ActivityException {
        EventWaitInstance received = registerWaitEvents(false, true);
        if (received!=null) {
            setReturnCodeAndExitStatus(received.getCompletionCode());
            processMessage(getExternalEventInstanceDetails(received.getMessageDocumentId()));
            boolean toFinish = handleCompletionCode();
            if (toFinish && exitStatus==null)
                exitStatus = WorkStatus.STATUS_COMPLETED;
        } else {
            exitStatus = WorkStatus.STATUS_COMPLETED;
            setReturnCode(null);
        }
    }
325572
def QueueResponse(self, message, blocking=True):
    """"""
    self._out_queue.Put(message, block=blocking)
1226467
def process_next_message(self, timeout):
        """"""
        message = self.worker_manager.receive(timeout)

        if isinstance(message, Acknowledgement):
            self.task_manager.task_start(message.task, message.worker)
        elif isinstance(message, Result):
            self.task_manager.task_done(message.task, message.result)
202467
def process_messages_loop_internal(self):
        
        while self.receiving_messages:
            # connect to AMQP server and listen for 1 message then disconnect
            self.work_request = None
            self.connection.receive_loop_with_callback(self.queue_name, self.save_work_request_and_close)
            if self.work_request:
                self.process_work_request()
118122
void handlerProcessTask(Task task) {
		assertDispatcherThread();
		
		SerialTaskQueue taskQueue = mQueuesMap.get(task.subscriberCallback.queue);
		if (taskQueue == null) {
			taskQueue = new SerialTaskQueue(task.subscriberCallback.queue);
			mQueuesMap.put(task.subscriberCallback.queue, taskQueue);
			mQueuesList.add(taskQueue);
		}
		taskQueue.offer(task);

		processNextTask();
	}
116493
def _process_msg(self, client, state, reward, isOver):
        
        # in the first message, only state is valid,
        # reward&isOver should be discarded
        if len(client.memory) > 0:
            client.memory[-1].reward = reward
            if isOver:
                # should clear client's memory and put to queue
                self._parse_memory(0, client, True)
            else:
                if len(client.memory) == LOCAL_TIME_MAX + 1:
                    R = client.memory[-1].value
                    self._parse_memory(R, client, False)
        # feed state and return action
        self._on_state(state, client)
939126
def packet_queue(self, pkt):
        """"""
        
        pkt.pos = 0
        pkt.to_process = pkt.packet_length
        
        self.out_packet.append(pkt)
        return NC.ERR_SUCCESS
566
public void queueEvent(Runnable r) {
                synchronized (this) {
                        mEventQueue.add(r);
                        synchronized (sGLThreadManager) {
                                mEventsWaiting = true;
                                sGLThreadManager.notifyAll();
                        }
                }
        }
328778
private void doQueueClear(final Message<JsonObject> message) {
    final String name = message.body().getString("name");
    if (name == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No name specified."));
      return;
    }

    context.execute(new Action<Void>() {
      @Override
      public Void perform() {
        data.getQueue(formatKey(name)).clear();
        return null;
      }
    }, new Handler<AsyncResult<Void>>() {
      @Override
      public void handle(AsyncResult<Void> result) {
        if (result.failed()) {
          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
        } else {
          message.reply(new JsonObject().putString("status", "ok"));
        }
      }
    });
  }
1207967
private void handleChannelCallback(final String message) {
		// Channel callback
		updateConnectionHeartbeat();

		// JSON callback
		final JSONArray jsonArray = new JSONArray(new JSONTokener(message));

		if(connectionFeatureManager.isConnectionFeatureActive(BitfinexConnectionFeature.SEQ_ALL)) {
			sequenceNumberAuditor.auditPackage(jsonArray);
		}

		final int channel = jsonArray.getInt(0);
		final ChannelCallbackHandler channelCallbackHandler = channelIdToHandlerMap.get(channel);
		if (channelCallbackHandler == null) {
			logger.error("Unable to determine symbol for channel {} / data is {} ", channel, jsonArray);
			reconnect();
			return;
		}
		String action = null;
		final JSONArray payload;
		if (jsonArray.get(1) instanceof String) {
			action = jsonArray.getString(1);
			payload = jsonArray.optJSONArray(2);
		} else {
			payload = jsonArray.optJSONArray(1);
		}
		if (Objects.equals(action, "hb")) {
			quoteManager.updateChannelHeartbeat(channelCallbackHandler.getSymbol());
		}
		try {
			if (payload == null) {
				return;
			}
			channelCallbackHandler.handleChannelData(action, payload);
		} catch (final BitfinexClientException e) {
			logger.error("Got exception while handling callback", e);
		}
	}
623183
private void acknowledgeQueueMessage(String messageId) {
        try {
            _queueService.acknowledge(_queueName, ImmutableList.of(messageId));
        } catch (Exception e) {
            _log.error("Failed to acknowledge message: [messageId={}]", messageId, e);
        }
    }
1122487
def QueueMessages(self, messages):
    """"""
    # Push all the messages to our input queue
    for message in messages:
      self._in_queue.put(message, block=True)
70953
public void onReceive(Object message) {

        // Start all workers
        if (message instanceof RequestToBatchSenderAsstManager) {

            // clear responseMap

            RequestToBatchSenderAsstManager request = (RequestToBatchSenderAsstManager) message;
            originalManager = getSender();
            taskId = request.getTaskId();
            asstManagerRetryIntervalMillis = request
                    .getAsstManagerRetryIntervalMillis();
            // assumption: at least 12
            taskIdTrim = taskId.length() <= 12 ? taskId
                    : taskId.substring(taskId.length() - 12,
                            taskId.length());
            workers = request.getWorkers();
            maxConcurrencyAdjusted = request.getMaxConcurrency();

            requestTotalCount = workers.size();

            sendMessageUntilStopCount(maxConcurrencyAdjusted);

            // if not completed; will schedule a continue send msg
            if (processedWorkerCount < requestTotalCount) {

                waitAndRetry();
                return;
            } else {
                logger.info("Now finished sending all needed messages. Done job of ASST Manager at "
                        + PcDateUtils.getNowDateTimeStrStandard());
                return;
            }
        } else if (message instanceof ContinueToSendToBatchSenderAsstManager) {

            // now reaching the end; have processed all of them, just waiting
            // the response to come back
            int notProcessedNodeCount = requestTotalCount
                    - processedWorkerCount;
            if (notProcessedNodeCount <= 0) {
                logger.info("!Finished sending all msg in ASST MANAGER at "
                        + PcDateUtils.getNowDateTimeStrStandard()

                        + " STOP doing wait and retry.");
                return;
            }

            int extraSendCount = maxConcurrencyAdjusted
                    - (processedWorkerCount - responseCount);

            if (extraSendCount > 0) {
                logger.info("HAVE ROOM to send extra of : " + extraSendCount
                        + " MSG. now Send at "
                        + PcDateUtils.getNowDateTimeStrStandard());

                sendMessageUntilStopCount(processedWorkerCount + extraSendCount);
                waitAndRetry();
            } else {
                logger.info("NO ROOM to send extra. Windowns is full. extraSendCount is negative: "
                        + extraSendCount
                        + " reschedule now at "
                        + PcDateUtils.getNowDateTimeStrStandard());
                waitAndRetry();

            }
        } else if (message instanceof ResponseCountToBatchSenderAsstManager) {

            responseCount = ((ResponseCountToBatchSenderAsstManager) message)
                    .getResponseCount();

            logger.debug("RECV IN batchSenderAsstManager FROM ExecutionManager responseCount: "
                    + responseCount);

        }
    }
252683
def event_handler(self):
        """"""

        if not self._notify_queue:
            LOG.error('event_handler: no notification queue for %s',
                      self._service_name)
            return

        LOG.debug('calling event handler for %s', self)
        self.start()
        self.wait()
376703
private void handleQueueEntryEvent(QueueEntryEvent event)
    {
        final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue());
        final AsteriskChannelImpl channel = channelManager.getChannelImplByName(event.getChannel());

        if (queue == null)
        {
            logger.error("Ignored QueueEntryEvent for unknown queue " + event.getQueue());
            return;
        }
        if (channel == null)
        {
            logger.error("Ignored QueueEntryEvent for unknown channel " + event.getChannel());
            return;
        }

        if (queue.getEntry(event.getChannel()) != null)
        {
            logger.debug("Ignored duplicate queue entry during population in queue " + event.getQueue() + " for channel "
                    + event.getChannel());
            return;
        }

        // Asterisk gives us an initial position but doesn't tell us when he
        // shifts the others
        // We won't use this data for ordering until there is a appropriate
        // event in AMI.
        // (and refreshing the whole queue is too intensive and suffers
        // incoherencies
        // due to asynchronous shift that leaves holes if requested too fast)
        int reportedPosition = event.getPosition();

        queue.createNewEntry(channel, reportedPosition, event.getDateReceived());
    }