You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Burca Ciprian <ci...@deuromedia.ro> on 2007/11/27 15:49:59 UTC

unsubscribe

 

-----Original Message-----
From: Tirthankar Ghosh [mailto:Tirthankarg@synechron.com] 
Sent: Tuesday, November 27, 2007 7:50 AM
To: dev@mina.apache.org
Subject: Need help to identify possible race condition in this snippet

Hi,

 

We are using MINA to capture high-throughput messages over network. It is
important for us to process the messages in the exact sequence they come in
to our application, over the network. The messages contain sequence numbers
and processing needs to ensure that lower sequence numbers are being
processed before the higher ones.

 

Given this context, please look at the code snippet below. It would help us,
if you could let me know if the code marked within the comments, // IS THIS
SECTION PRONED TO RACE CONDITION, can possibly lead to a race condition
leading to the higher sequenced messages getting queued and hence processed
before the lower ones.

 

The code below shows how we have messageReceived callback coded. After the
message gets queued in a blockingqueue, the subsequent code is to poll and
queue and process the messages one at a time. But there is some bit of code
even before the message gets queued and that is where I am under the
impression that a race condition can occur. Please let me know what you
think since we are currently experiencing this problem under rare cases, and
reproducing the problem in QA has not been successful so far.

 

public void messageReceived(IoSession ioSession, Object message) throws
Exception {

// IS THIS SECTION PRONED TO RACE CONDITION  

        String messageString = (String) message;

        SessionID remoteSessionID =
MessageUtils.getReverseSessionID(messageString);

        Session fixSession = findQFSession(ioSession, remoteSessionID);

        if (fixSession != null) {

            fixSession.getLog().onIncoming(messageString); // log the
incoming message in database

            MessageFactory messageFactory = fixSession.getMessageFactory();

            DataDictionary dataDictionary = fixSession.getDataDictionary();

            Message fixMessage;

            try {

                fixMessage = MessageUtils.parse(messageFactory,
dataDictionary, messageString);

// IS THIS SECTION PRONED TO RACE CONDITION                

                queue.put(fixMessage); // put the message into a singleton
linkedblockingqueue

            } catch (InvalidMessage e) {

                log.error("Invalid message: " + e.getMessage());

            }

        } else {

            log.error("Disconnecting; received message for unknown session:
" + messageString);

            ioSession.close();

        }

    }

 

 

Any help would be appreciated.

 

Thanks and regards,

Tirthankar

 



Re: unsubscribe

Posted by Emmanuel Lecharny <el...@gmail.com>.
Better send this mail to : dev-unsubscribe@mina.apache.org^ 
<mailto:dev-unsubscribe@mina.apache.org?subject=unsubscribe&body=unsubscribe>

(http://mina.apache.org/mailing-lists.html(

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org