@@ -0,0 +1,3007 @@
+/*%0A * jPOS Project %5Bhttp://jpos.org%5D%0A * Copyright (C) 2000-2021 jPOS Software SRL%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as%0A * published by the Free Software Foundation, either version 3 of the%0A * License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage org.jpos.util;%0A%0Aimport org.jpos.core.Configurable;%0Aimport org.jpos.core.Configuration;%0Aimport org.jpos.core.ConfigurationException;%0Aimport org.jpos.iso.ISOException;%0Aimport org.jpos.iso.ISOMsg;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0A/*%0A * Sample use:%0A *%0A *  %3Clog-listener class=%22org.jpos.util.IgnoreLogListener%22%3E%0A *   %3Cproperty name=%22realm%22 value=%22mychannel%22 /%3E%0A *   %3Cproperty name=%22mti%22 value=%220800%22 /%3E%0A *   %3Cproperty name=%22mti%22 value=%220810%22 /%3E%0A *   %3Cproperty name=%22ignore%22 value=%2250%22 /%3E%0A * %3C/log-listener%3E%0A */%0A%0Apublic class IgnoreLogListener implements LogListener, Configurable %7B%0A    String%5B%5D realms;%0A    String%5B%5D mtis;%0A    int ignore;%0A    int ignored = 0;%0A%0A    public IgnoreLogListener() %7B%0A        super();%0A    %7D%0A%0A    public void setConfiguration (Configuration cfg) throws ConfigurationException %7B%0A        mtis = cfg.getAll(%22mti%22);%0A        realms = cfg.getAll(%22realm%22);%0A        ignore = cfg.getInt(%22ignore%22, 100);%0A    %7D%0A    public LogEvent log (LogEvent ev) %7B%0A        if (hasRealm(ev.getRealm())) %7B%0A            synchronized (ev.getPayLoad()) %7B%0A                final List%3CObject%3E payLoad = ev.getPayLoad();%0A                for (Object obj : payLoad) %7B%0A                    if (obj instanceof ISOMsg) %7B%0A                        ISOMsg m = (ISOMsg) obj;%0A                        try %7B%0A                            if (hasMti(m.getMTI())) %7B%0A                                if (++ignored %3E ignore) %7B%0A                                    ev.addMessage(%22ignored %22 + ignore + %22 similar messages%22);%0A                                    ignored = 0;%0A                                    return ev;%0A                                %7D else %7B%0A                                    return null;%0A                                %7D%0A                            %7D%0A                        %7D catch (ISOException e) %7B%0A                            ev.addMessage(e);%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        return ev;%0A    %7D%0A%0A    private boolean hasMti (String mti) %7B%0A        return Arrays.stream(mtis).anyMatch (m -%3E mti != null && mti.startsWith(m));%0A    %7D%0A%0A    private boolean hasRealm(String realm) %7B%0A        return Arrays.stream(realms).anyMatch(r -%3E realm != null && realm.startsWith(r));%0A    %7D%0A%7D%0A%0A

add handy IgnoreLogListener