org.jgroups.protocols.DETECT_LOOPBACKS Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including
all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and
Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
package org.jgroups.protocols;
import org.jgroups.Message;
import org.jgroups.annotations.MBean;
import org.jgroups.annotations.Property;
import org.jgroups.stack.Protocol;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Detects unicast loopbacks: messages where dest == local address
* @author Bela Ban
* @since 5.1.6
*/
@MBean(description="Detects unicast loopback messages")
public class DETECT_LOOPBACKS extends Protocol {
@Property(description="Prints to stdout")
protected boolean print_to_stdout=true;
protected final AtomicInteger count=new AtomicInteger();
public Object down(Message msg) {
if(Objects.equals(local_addr, msg.getDest())) {
String s=String.format("[%d] %s, headers: %s", count.getAndIncrement(), msg, msg.getHeaders());
if(print_to_stdout)
System.out.printf("%s\n", s);
else if(log.isTraceEnabled())
log.trace(s);
}
return down_prot.down(msg);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy