try {
OtpErlangObject msg=thisMbox.receive();
if (!(msg instanceof OtpErlangTuple))
System.out.println("invalid message received, expected tuple, got "+msg);
OtpErlangTuple message = (OtpErlangTuple)msg;
if (message.arity() != 3)
System.out.println("invalid tuple received, expected three elements, got "+msg);
if (!(message.elementAt(2) instanceof OtpErlangAtom))
System.out.println("invalid request received, expected an atom, got "+message.elementAt(2));
OtpErlangAtom command = (OtpErlangAtom) message.elementAt(2);