/* (non-Javadoc)
@see net.timewalker.ffmq4.storage.message.impl.AbstractMessageStore#retrieveMessage(int)
770273
@Override
	protected AbstractMessage retrieveMessage(int handle) throws JMSException
    {
    	return (AbstractMessage)((InMemoryLinkedDataStore)dataStore).retrieve(handle);
    }
811774
def get(self, storagemodel:object, modeldefinition = None, hide = 0) -> StorageQueueModel:
        
        try:
            if hide > 0:
                messages = modeldefinition['queueservice'].get_messages(storagemodel._queuename, num_messages=1, visibility_timeout = hide)
            else:
                messages = modeldefinition['queueservice'].get_messages(storagemodel._queuename, num_messages=1)
                    
            """ parse retrieved message """
            for message in messages:
                storagemodel.mergemessage(message)

            """ no message retrieved ?"""
            if storagemodel.id is None:
                storagemodel = None

        except Exception as e:
            storagemodel = None
            msg = 'can not peek queue message:  queue {} with message {} because {!s}'.format(storagemodel._queuename, storagemodel.content, e)
            raise AzureStorageWrapException(msg=msg)

        finally:
            return storagemodel
179671
public int getMessageLength(){
		// Message type, number of transients
		int length = 1 + 4;
		if(this.requests != null){
			for(OnDemandRequest request : this.requests){
				length += request.getLength();
			}
		}
		
		return length;
	}
914182
def _getMessage(session, txid):
    """"""

    while True:
        if txid in session.messages:
            msg = session.messages[txid]
            del session.messages[txid]
            return msg
        else:
            try:
                # apparently any timeout at all allows the thread to be
                # stopped but none make it unstoppable with ctrl+c
                nextMessage = session.queue.get(timeout=100)
            except queue.Empty:
                continue
            if 'txid' in nextMessage:
                session.messages[nextMessage['txid']] = nextMessage
            else:
                logger.info("message with no txid: %s" % nextMessage)
904611
public AbstractMessage get( LocalSession localSession , 
				    			TransactionSet transactionSet , 
                                MessageSelector selector ) throws JMSException
    {
    	if (closed)
    		return null;
    	
    	this.lastActivity = System.currentTimeMillis();
    	
    	AbstractMessage msg = null;
    	
        // Search in volatile store first
        if (volatileStore != null)
        {
            msg = getFromStore(localSession, volatileStore, transactionSet, selector);
            
            // Then in persistent store
	        if (msg == null && persistentStore != null)
	        	msg = getFromStore(localSession, persistentStore, transactionSet, selector);
        }
        else
        if (persistentStore != null)
	        msg = getFromStore(localSession, persistentStore, transactionSet, selector);
        
        return msg;
    }
1067746
protected String getMessage(String key, String... args) {

        return Messages.get().getBundle(m_cms.getRequestContext().getLocale()).key(key, args);
    }
333841
public long getOldestMessageAge()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getOldestMessageAge");
    MessageItem oldestItem=null;
    try
    {
      oldestItem = (MessageItem)this.findOldestItem();
    }
    catch (MessageStoreException e)
    {
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.impl.store.itemstreams.PtoPMessageItemStream.getOldestMessageAge",
        "1:825:1.93.1.14",
        this);        
            
      SibTr.exception(tc, e);       
    }
        
    long age = 0;
        
    if (null != oldestItem)
    {
      age = oldestItem.calculateWaitTimeUpdate(
        java.lang.System.currentTimeMillis());
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getOldestMessageAge", new Long(age));
    return age;
  }
18361
public long getUnAvailableMessageCount()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getUnAvailableMessageCount");

    long returnValue = -1;
    try
    {
      returnValue = getStatistics().getUnavailableItemCount();
    }
    catch(MessageStoreException e)
    {
      // FFDC
      FFDCFilter.processException(
          e,
          "com.ibm.ws.sib.processor.impl.store.itemstreams.PtoPMessageItemStream.getUnAvailableMessageCount",
          "1:894:1.93.1.14",
          this);  
      
      SibTr.exception(tc, e);
    } 
          
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getUnAvailableMessageCount", new Long(returnValue));
    return returnValue;
  }
1346063
public int getRemainingMessageCount()
  throws SISessionUnavailableException, SISessionDroppedException,
         SIIncorrectCallException
  {
    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.entry(CoreSPILockedMessageEnumeration.tc, "getRemainingMessageCount",
        new Object[] {new Integer(hashCode()), this});

    int count = 0;

    checkValidState("getRemainingMessageCount");

    localConsumerPoint.checkNotClosed();

    synchronized(this)
    {
      // If we've reached the end the count is zero
      if(!endReached)
      {
        LMEMessage message;

        // If currentMsg is null it means we start from the begining
        if(currentMsg == null)
          message = firstMsg;
        else
          message = currentMsg.next;

        while(message != null)
        {
          count++;
          message = message.next;
        }
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && CoreSPILockedMessageEnumeration.tc.isEntryEnabled())
      SibTr.exit(CoreSPILockedMessageEnumeration.tc, "getRemainingMessageCount", new Integer(count));

    return count;
  }
679603
public String getMessage(String key) {
		try {
			String overlayed = this.getOverlayMessage(key);
			if (!GeneralUtils.isEmpty(overlayed)) {
				return overlayed;
			}
			return this.bundle.getString(key);
		} catch (MissingResourceException ex) {
			return "???"+key+"???";
		}
	}
340646
public String getMessage(final String messageKey, final Object... objects) {
        //TODO validate input
        return getFormattedMessage(getMessagePattern(messageKey), objects);
    }
879619
public Message receiveMessage()
    {
        DualMessageQueue baseMessageQueue = (DualMessageQueue)this.getMessageQueue();
        if (baseMessageQueue == null)
            return null;    // In free
        return baseMessageQueue.getMessageStack().receiveMessage();
    }
697530
@Override
	public AbstractMessage nextElement()
	{
		if (cursor.endOfQueueReached())
			throw new NoSuchElementException();
		
		try
		{
			checkNotClosed();
			AbstractMessage msg = fetchNext();
			if (msg != null)
			{
				nextMessage = null; // Consume fetched message
				AbstractMessage msgCopy = MessageTools.duplicate(msg);
				msgCopy.ensureDeserializationLevel(MessageSerializationLevel.FULL);
				return msgCopy;
			}
			
			throw new NoSuchElementException();
		}
		catch (NoSuchElementException e)
		{
			throw e;
		}
		catch (JMSException e)
		{
			throw new IllegalStateException(e.toString());
		}
	}
422374
public MessageItem retrieveMessageFromItemStream(long msgStoreID)
                    throws SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "retrieveMessageFromItemStream", new Long(msgStoreID));

        MessageItem msgItem = null;
        try
        {
            msgItem = (MessageItem) _pubsubMessageItemStream.findById(msgStoreID);
        } catch (MessageStoreException e)
        {
            // FFDC
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.destination.PubSubRealization.retrieveMessageFromItemStream",
                                        "1:3797:1.35.2.4",
                                        this);

            SibTr.exception(tc, e);

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "retrieveMessageFromItemStream", e);

            throw new SIResourceException(e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "retrieveMessageFromItemStream", msgItem);

        return msgItem;
    }
1292899
private SIMPMessage retrieveMsgLocked() throws SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "retrieveMsgLocked", new Object[] { this });

        SIMPMessage msg = null;

        // Look in the Cd's ItenStream for the next available message
        try
        {

            msg = _consumerKey.getMessageLocked();

            if (msg != null)
                msg.eventLocked();
        } catch (MessageStoreException e)
        {
            // MessageStoreException shouldn't occur so FFDC.
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.JSLocalConsumerPoint.retrieveMsgLocked",
                                        "1:2101:1.22.5.1",
                                        this);

            SibTr.exception(tc, e);
            SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
                        new Object[] {
                                      "com.ibm.ws.sib.processor.impl.JSLocalConsumerPoint",
                                      "1:2108:1.22.5.1",
                                      SIMPUtils.getStackTrace(e) });

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "retrieveMsgLocked", e);

            throw new SIResourceException(
                            nls.getFormattedMessage(
                                                    "INTERNAL_MESSAGING_ERROR_CWSIP0002",
                                                    new Object[] {
                                                                  "com.ibm.ws.sib.processor.impl.JSLocalConsumerPoint",
                                                                  "1:2119:1.22.5.1",
                                                                  e },
                                                    null),
                            e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "retrieveMsgLocked", msg);
        //return the locked message

        return msg;
    }
59684
@Override
    public String getMessage() {
        // In case the immediate child has the same msgCode, it must be
        // duplicated
        if (childException != null) {
            if (msgKey.equals(childException.getMsgKey())) {
                return childException.getMessage();
            }
        }
        if (message == null && msgKey != null) {
            message = Tr.formatMessage(tc, msgKey, objs);
        }
        if (message != null) {
            return message;
        } else {
            return this.getClass().getName();
        }
    }
513119
@Override
	public AbstractMessage nextElement()
	{
		if (endOfQueueReached)
			throw new NoSuchElementException();
			
		try
		{
			checkNotClosed();
			AbstractMessage msg = fetchNext();
			if (msg != null)
			{
				nextMessage = null; // Consume fetched message

				// Make sure the message is fully deserialized and marked as read-only
				msg.ensureDeserializationLevel(MessageSerializationLevel.FULL);
				msg.markAsReadOnly();
				
				return msg;
			}
			
			throw new NoSuchElementException();
		}
		catch (NoSuchElementException e)
		{
			throw e;
		}
		catch (JMSException e)
		{
			throw new IllegalStateException(e.toString());
		}
	}