camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ed Welch">
Subject Possible bug in JGroupsFilters.dropNonCoordinatorViews?
Date Tue, 28 Jul 2015 10:44:36 GMT
Was looking at using the jgroups component to coordinate some master/slave routes, and was
digging into the source for the example to see how it works.

Everything seems straight forward to me with one issue:  the dropNonCoordinatorViews method
in JGroupsFilters looks like it may have a bug:

public static Predicate dropNonCoordinatorViews() {
        return new Predicate() {
            public boolean matches(Exchange exchange) {
                Object body = exchange.getIn().getBody();
                JGroupsFilters.LOG.debug("Filtering message {}.", body);
                if(body instanceof View) {
                    View view = (View)body;
                    Address coordinatorNodeAddress = (Address)view.getMembers().get(0);
                    Address channelAddress = (Address)exchange.getIn().getHeader("JGROUPS_CHANNEL_ADDRESS",
                    JGroupsFilters.LOG.debug("Comparing endpoint channel address {} against
the coordinator node address {}.", channelAddress, coordinatorNodeAddress);
                    return channelAddress.equals(coordinatorNodeAddress);
                } else {
                    JGroupsFilters.LOG.debug("Body {} is not an instance of org.jgroups.View
. Skipping filter.", body);
                    return true;

So if the message from the jgroups component is a View, and the coordinator address matches
this channel address, return true, indicating we are the coordinator, and we can start the

However, if the message which was received on the Channel was not a View object, this method
returns true.

If this is used according to the example:


Wouldn't that mean any non View type message would cause the route to start??

Shouldn't that default case for non View type messages return false?

View raw message