Ask to fetch a single message from a queue.  If a consumer is supplied,
        the consumer will be called with either a Message argument, or None if
        there is no message in queue. If a synchronous transport, Message or
        None is returned.
483354
def get(self, queue, consumer=None, no_ack=True, ticket=None):
        '''
        
        '''
        args = Writer()
        args.write_short(ticket or self.default_ticket).\
            write_shortstr(queue).\
            write_bit(no_ack)

        self._get_cb.append(consumer)
        self.send_frame(MethodFrame(self.channel_id, 60, 70, args))
        return self.channel.add_synchronous_cb(self._recv_get_response)
469063
static void rcvRequestMsgs(CommsByteBuffer request, Conversation conversation, int requestNumber,
                               boolean allocatedFromBufferPool, boolean partOfExchange)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "rcvRequestMsgs",
                        new Object[]
                        {
                         request,
                         conversation,
                         "" + requestNumber,
                         "" + allocatedFromBufferPool
                        });

        short connectionObjectID = request.getShort(); // BIT16 ConnectionObjectId
        short consumerObjectID = request.getShort(); // BIT16 SyncConsumerSessionId
        int receivedBytes = request.getInt(); // BIT32 ReceivedBytes
        int requestedBytes = request.getInt(); // BIT32 RequestedBytes

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        {
            SibTr.debug(tc, "connectionObjectID", connectionObjectID);
            SibTr.debug(tc, "consumerObjectID", consumerObjectID);
            SibTr.debug(tc, "receivedBytes", receivedBytes);
            SibTr.debug(tc, "requestedBytes", requestedBytes);
        }

        CATMainConsumer mainConsumer =
                        ((CATMainConsumer) ((ConversationState) conversation.getAttachment()).getObject(consumerObjectID));

        mainConsumer.requestMsgs(requestNumber, receivedBytes, requestedBytes);

        request.release(allocatedFromBufferPool);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "rcvRequestMsgs");
    }
1055269
def consume(self, message):
        
        if 'jsonrpc' not in message or message['jsonrpc'] != JSONRPC_VERSION:
            log.warn("Unknown message type %s", message)
            return

        if 'id' not in message:
            log.debug("Handling notification from client %s", message)
            self._handle_notification(message['method'], message.get('params'))
        elif 'method' not in message:
            log.debug("Handling response from client %s", message)
            self._handle_response(message['id'], message.get('result'), message.get('error'))
        else:
            try:
                log.debug("Handling request from client %s", message)
                self._handle_request(message['id'], message['method'], message.get('params'))
            except JsonRpcException as e:
                log.exception("Failed to handle request %s", message['id'])
                self._consumer({
                    'jsonrpc': JSONRPC_VERSION,
                    'id': message['id'],
                    'error': e.to_dict()
                })
            except Exception:  # pylint: disable=broad-except
                log.exception("Failed to handle request %s", message['id'])
                self._consumer({
                    'jsonrpc': JSONRPC_VERSION,
                    'id': message['id'],
                    'error': JsonRpcInternalError.of(sys.exc_info()).to_dict()
                })
363386
def _has_message(self):
        
        sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding)
        return sep in self._receive_buffer
398729
def get(self):
        
        try:
            item = self._queue.get_nowait()
        except (Empty, PersistEmpty):
            return None

        if self._persistence_path:
            self._queue.task_done()

        return item
985964
def message(self, pubnub, message):
        
        try:
            json_data = json.dumps(message.message.get('data'))
        except AttributeError:
            json_data = message.message
        for func in SUBSCRIPTIONS[message.channel]:
            # This means pubnub couldn't get the current state of the channel
            # The pull_url is the location to pull the current state from.
            # Returning None here to have the calling program handle this.
            if 'pull_url' in json_data:
                func(None)
            else:
                func(json.loads(json_data))
1262407
def got_response(self):
        
        return any(message.sender != self.initiator
                   for message in self.messages)
448870
def gotMessage(self, message_id, message):
        
        d = defer.maybeDeferred(self._handle_message, message)
        d.addCallback(self.generate_response)
        d.addCallback(lambda resp: self.reply(message_id, resp))
        return d
265660
async def _handle_message(self,
                              message: BaseMessage,
                              responder: Responder) -> Optional[Dict]:
        

        async def noop(request: Request, responder: Responder):
            pass

        mm = MiddlewareManager.instance()
        reg_manager = self.register\
            .work_on_register(message.get_conversation().id)

        async with reg_manager as reg:
            request = Request(message, reg)
            await request.transform()

            if not request.stack.layers:
                return

            logger.debug('Incoming message: %s', request.stack)
            await mm.get('pre_handle', noop)(request, responder)

            # noinspection PyBroadException
            try:
                state, trigger, dnr = \
                    await self._build_state(request, message, responder)
            except Exception:
                logger.exception('Error while finding a transition from %s',
                                 reg.get(Register.STATE))
                reporter.report(request, None)
                return

            if state is None:
                logger.debug(
                    'No next state found but "%s" is not confusing, stopping',
                    request.message,
                )
                return

            state = await self._run_state(responder, state, trigger, request)

            # noinspection PyBroadException
            try:
                await responder.flush(request)
            except MissingTranslationError as e:
                responder.clear()
                responder.send([RawText(str(e))])
                await responder.flush(request)

                reporter.report(request, state.name())
                logger.exception('Missing translation in state %s',
                                 state.name())
            except Exception:
                reporter.report(request, state.name())
                logger.exception('Could not flush content after %s',
                                 state.name())
            else:
                if not dnr:
                    reg.replacement = await self._build_state_register(
                        state,
                        request,
                        responder,
                    )
                return reg.replacement
34049
def (self):
        
        while True:
            message = self.res_queue.get()
            if message is None:
                _logger.debug(" thread is terminated")
                return
            self._(message)
585098
def get(*args)
      if args.size == 1 && args[0].is_a?(Hash)
        queue_name = (args[0][:name] || args[0]['name']).to_s
        queue_name.empty? ? super : queues_get(queue_name)
      else
        super
      end
    end
828937
def _get_from_send_queue(self):
        '''  '''
        try:
            packet = self.transmit.get(block=False)
            self.logger.info('Sending packet')
            self.logger.debug(packet)
            return packet
        except queue.Empty:
            pass
        return None
580401
def PopItem(self):
    
    try:
      # If no timeout is specified the queue will block if empty otherwise
      # a Queue.Empty exception is raised.
      return self._queue.get(timeout=self._timeout)

    except KeyboardInterrupt:
      raise errors.QueueClose

    # If close() is called on the multiprocessing.Queue while it is blocking
    # on get() it will raise IOError.
    except IOError:
      raise errors.QueueClose

    except Queue.Empty:
      raise errors.QueueEmpty
122200
public Message receiveMessage(String queueName, long timeout) {
        checkStarted();
        try(Session session = receiverSessionPool.getSession()){
            Queue queue = (Queue) jmsServer.lookup(QUEUE_NAMESPACE + queueName);
            try(MessageConsumer consumer = session.createConsumer(queue)) {
                return consumer.receive(timeout);
            }
        } catch (Exception e) {
            throw new AsyncException("Could not get message", e);
        }
    }
656176
def call(self, my_args=None):
        
        LOGGER.debug("rabbitmq.Requester.call")
        if my_args is None:
            raise exceptions.ArianeConfError("requestor call arguments")
        if 'properties' not in my_args or my_args['properties'] is None:
            raise exceptions.ArianeConfError('requestor call properties')
        if 'body' not in my_args or my_args['body'] is None:
            my_args['body'] = ''
        if 'MSG_CORRELATION_ID' not in my_args['properties']:
            self.corr_id = str(uuid.uuid4())
            my_args['properties']['MSG_CORRELATION_ID'] = self.corr_id
        else:
            self.corr_id = my_args['properties']['MSG_CORRELATION_ID']

        self.response = None
        self.corr_id = str(uuid.uuid4())

        props = my_args['properties']
        if 'sessionID' in props and props['sessionID'] is not None and props['sessionID']:
            request_q = str(props['sessionID']) + '-' + self.requestQ
        else:
            request_q = self.requestQ

        if self.trace:
            props['MSG_TRACE'] = True

        if not self.fire_and_forget:
            properties = pika.BasicProperties(content_type=None, content_encoding=None,
                                              headers=props, delivery_mode=None,
                                              priority=None, correlation_id=self.corr_id,
                                              reply_to=self.callback_queue, expiration=None,
                                              message_id=None, timestamp=None,
                                              type=None, user_id=None,
                                              app_id=None, cluster_id=None)
        else:
            properties = pika.BasicProperties(content_type=None, content_encoding=None,
                                              headers=props, delivery_mode=None,
                                              priority=None, expiration=None,
                                              message_id=None, timestamp=None,
                                              type=None, user_id=None,
                                              app_id=None, cluster_id=None)

        self.channel.basic_publish(exchange='',
                                   routing_key=request_q,
                                   properties=properties,
                                   body=str(my_args['body']))

        LOGGER.debug("rabbitmq.Requester.call - published msg {"+str(my_args['body'])+","+str(properties)+"}")

        if not self.fire_and_forget:
            start_time = timeit.default_timer()
            timeout = self.rpc_timeout if self.rpc_timeout > 0 else 0
            while self.response is None and timeout >= 0:
                timeout_id = None
                if timeout > 0:
                    timeout_id = self.connection.add_timeout(timeout, self.on_response)
                self.connection.process_data_events()
                if timeout_id is not None:
                    self.connection.remove_timeout(timeout_id)
                timeout = round(self.rpc_timeout - (timeit.default_timer() - start_time))
            rpc_time = timeit.default_timer() - start_time

            if self.response is None:
                if self.rpc_retry > 0:
                    if 'retry_count' not in my_args:
                        my_args['retry_count'] = 1
                        LOGGER.debug("rabbitmq.Requester.call - Retry (" + str(my_args['retry_count']) + ")")
                        return self.call(my_args)
                    elif 'retry_count' in my_args and (self.rpc_retry - my_args['retry_count']) > 0:
                        LOGGER.warn("rabbitmq.Requester.call - No response returned from request on " + request_q +
                                    " queue after " + str(self.rpc_timeout) + '*' +
                                    str(self.rpc_retry) + " sec ...")
                        self.trace = True
                        my_args['retry_count'] += 1
                        LOGGER.warn("rabbitmq.Requester.call - Retry (" + str(my_args['retry_count']) + ")")
                        return self.call(my_args)
                    else:
                        raise ArianeMessagingTimeoutError('rabbitmq.Requester.call',
                                                          'Request timeout (' + str(self.rpc_timeout) + '*' +
                                                          str(self.rpc_retry) + ' sec) occured')
                else:
                    raise ArianeMessagingTimeoutError('rabbitmq.Requester.call',
                                                      'Request timeout (' + str(self.rpc_timeout) + '*' +
                                                      str(self.rpc_retry) + ' sec) occured')
            else:
                if self.rpc_timeout > 0 and rpc_time > self.rpc_timeout*3/5:
                    LOGGER.debug('rabbitmq.Requester.call - slow RPC time (' + str(rpc_time) + ') on request ' +
                                 str(properties))
                self.trace = False

                rc_ = self.response['props'].headers['RC']
                if rc_ != 0:
                    try:
                        content = json.loads(self.response['body'].decode("UTF-8"))
                    except ValueError:
                        content = self.response['body'].decode("UTF-8")
                    return DriverResponse(
                        rc=rc_,
                        error_message=self.response['props'].headers['SERVER_ERROR_MESSAGE']
                        if 'SERVER_ERROR_MESSAGE' in self.response['props'].headers else '',
                        response_content=content
                    )
                else:
                    try:
                        if 'MSG_PROPERTIES' in self.response['props'].headers:
                            props = json.loads(self.response['props'].headers['MSG_PROPERTIES'])
                        else:
                            props = None
                    except ValueError:
                        if 'MSG_PROPERTIES' in self.response['props'].headers:
                            props = self.response['props'].headers['MSG_PROPERTIES']
                        else:
                            props = None
                    try:
                        content = json.loads(self.response['body'].decode("UTF-8"))
                    except ValueError:
                        content = self.response['body'].decode("UTF-8")
                    return DriverResponse(
                        rc=rc_,
                        response_properties=props,
                        response_content=content
                    )
621793
def receive_messages_from_queue(self, wait_time=15, num_messages=1):
        

        return self.queue.receive_messages(MaxNumberOfMessages=num_messages,
                                           WaitTimeSeconds=wait_time)
850064
protected Message lookupMessage(String queueName)  {
        checkStarted();

        try(Session session = consumerConnection.createSession()) {
            Queue queue = (Queue) jmsServer.lookup(QUEUE_NAMESPACE + queueName);
            Enumeration messages = session.createBrowser(queue).getEnumeration();
            return (Message) messages.nextElement();
        }catch (NoSuchElementException e){
            return null;
        }
        catch (Exception e) {
            throw new AsyncException("Lookup failed", e);
        }
    }