All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS 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).

There is a newer version: 34.0.0.Final
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy