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

io.dddspring.common.notification.DomainNotificationEvent Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package io.dddspring.common.notification;

import io.dddspring.common.event.DomainEventHandle;

import java.util.HashMap;

public class DomainNotificationEvent implements NotificationDomain {

    protected int recivenum;
    protected int successednum;
    protected int failednum;
    public DomainNotificationEvent(){
        reset();
    }
    public int reciveCount(){return recivenum;}
    public int sucessedCount(){return successednum;}
    public int failedCount(){return failednum;}
    public void reset(){
        recivenum=0;
        successednum=0;
        failednum=0;
    }
    protected HashMap eventlist=new HashMap();

    @Override
    public void registerEvent(Class eventclass,DomainEventHandle eventHandle){

        System.out.println("eventclass.getCanonicalName"+eventclass.getCanonicalName());
        System.out.println("eventclass.getSimpleName"+eventclass.getSimpleName());
        System.out.println("eventclass.getName"+eventclass.getName());

        this.eventlist.put(eventclass.getName(),eventHandle);
    }
    @Override
    public void onNoticee(String rs) {
        try {
                System.out.println("消息rs::"+rs);
                NotificationReader reader = new NotificationReader(rs);
                DomainEventHandle eventHandle=eventlist.get(reader.typeName());

                if(eventlist.containsKey(reader.typeName())){
                    eventHandle.onEvent(NotificationSerializer.instance().deserialize(rs, eventHandle.type()));
                    successednum++;
                }

                System.out.println("消息reader.typeName::"+reader.typeName());

        } catch (Exception e) {
            e.printStackTrace();
            failednum++;

        }finally {
            recivenum ++;
        }


    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy