[erlang-questions] Receiving identical messages from Erlang and from JInterface

Erlang list <>
Thu Jan 4 16:59:36 CET 2007


I am just starting to use Erlang and I've run into something I don't 
understand.  Here is a transcript of a shell session when I send two 
identical messages from a remote Erlang node:

()102> b().
ok
()103> process_info(self(), messages).
{messages,[]}
()104> % send duplicate messages from Erlang
()104> process_info(self(), messages).
{messages,[{<5007.61.0>,hello},{<5007.61.0>,hello}]}
()105> receive {P,X} -> {P,X} after 2000 -> false 
end.
{<5007.61.0>,hello}
()106> b().
P = <5007.61.0>
X = hello
ok
()107> receive {P,X} -> {P,X} after 2000 -> false 
end.
{<5007.61.0>,hello}
()108> process_info(self(), messages).
{messages,[]}
()109>

This works as expected.  However, when I do the same but send the 
messages from a Java program using JInterface the first message is 
received but pattern matching for the second message seems to fail:

()111> b().
ok
()112> process_info(self(), messages).
{messages,[]}
()113> % send duplicate messages from JInterface
()113> process_info(self(), messages).
{messages,[{<4999.1.0>,hello},{<4999.1.0>,hello}]}
()114> receive {P,X} -> {P,X} after 2000 -> false 
end.
{<4999.1.0>,hello}
()115> b().
P = <4999.1.0>
X = hello
ok
()116> receive {P,X} -> {P,X} after 2000 -> false 
end.
false
()117> process_info(self(), messages).
{messages,[{<4999.1.0>,hello}]}
()118>

The essentials of the Java program are:

OtpNode node = new OtpNode("jnode", "secretcookie");
OtpMbox mbox = node.createMbox("mbox1");
OtpErlangObject[] msg = new OtpErlangObject[2];
msg[0] = mbox.self();
msg[1] = new OtpErlangAtom("hello");
OtpErlangTuple tuple = new OtpErlangTuple(msg);
mbox.send("foobox", "", tuple);


erlang:system_info(version) = "5.5.1", R11B
Both clients on Windows Win2K, receiver (zippy) is Linux.

Any ideas or clues as to where to look or why this doesn't appear to work?

Happy New Year everyone 3|;-P



More information about the erlang-questions mailing list