Re: [jgroups-dev] Begginer - Sending and receiving message with Jgroups

Bela Ban <[email protected]> Thu, 19 May 2011 21:42:06 +0200
Newsgroups gmane.comp.java.javagroups.devel
Message-ID <[email protected]>

On 5/19/11 8:20 PM, viniciusfaleiro wrote:
>
> Hi.. I`ve been working with TIBCO and I`m trying Jgroups now in an open
> source project... TIBCO and Jgroups are pretty similar as far as I know but
> one of the Jgroups characteristics that is bugging me is that when I`m
> trying to send a message, The sender also receives the message that he
> actually sent. Is that common for Jgroups or I`m doing something wrong?


No, this is correct and is the default behavior. You can do 2 things to 
get rid of this: either check whether you and the sender and discard the 
message, e.g.

public void receive(Message msg) {
     if(local_addr.equals(msg.getSrc()) {
          // discard message
     }
}

or disable reception of local messages:
channel.setDiscardOwnMessages(true); // in 3.0, previously use 
channel.setOpt(Channel.LOCAL, false);


> You can find my codes here:
> https://github.com/viniciusfaleiro/ActiveDB/blob/master/src/br/com/activedb/messaging/ActiveDBChannel.java

You're joining the same channel multiple times, this won't work. Do your 
own multiplexing over the same channel


-- 
Bela Ban
Lead JGroups / Clustering Team
JBoss

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Javagroups-development mailing list