Search in sources :

Example 1 with PropertyChangeListener

use of com.swiftmq.mgmt.PropertyChangeListener in project swiftmq-ce by iitsoftware.

the class MessageGroupDispatchPolicy method init.

private void init() {
    Property prop = myEntity.getProperty("message-group-enabled");
    enabled = ((Boolean) prop.getValue()).booleanValue();
    prop.setPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            enabled = ((Boolean) newValue).booleanValue();
            if (enabled)
                restart();
            else
                reset();
        }
    });
    prop = myEntity.getProperty("message-group-property");
    propName = (String) prop.getValue();
    prop.setPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            if (enabled)
                throw new PropertyChangeException("Please disable message grouping for this clustered queue before you change this property!");
            propName = (String) newValue;
        }
    });
    prop = myEntity.getProperty("message-group-expiration");
    expiration = ((Long) prop.getValue()).longValue();
    prop.setPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            expiration = ((Long) newValue).longValue();
            if (enabled && expiration != 0)
                checkExpiration();
        }
    });
    prop = myEntity.getProperty("message-group-expiration-cleanup-interval");
    cleanupInterval = ((Long) prop.getValue()).longValue();
    prop.setPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            cleanupInterval = changeCleanupInterval(((Long) newValue).longValue());
        }
    });
}
Also used : PropertyChangeListener(com.swiftmq.mgmt.PropertyChangeListener) Property(com.swiftmq.mgmt.Property) PropertyChangeException(com.swiftmq.mgmt.PropertyChangeException)

Example 2 with PropertyChangeListener

use of com.swiftmq.mgmt.PropertyChangeListener in project swiftmq-ce by iitsoftware.

the class StableStore method init.

private void init() throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$store", toString() + "/init ...");
    nFree = 0;
    if (freePoolEnabled)
        freePool = new IntRingBuffer[10];
    filename = path + File.separatorChar + FILENAME;
    emptyData = new byte[Page.PAGE_SIZE];
    // emtpy
    emptyData[0] = 1;
    for (int i = 1; i < Page.PAGE_SIZE; i++) emptyData[i] = 0;
    file = new RandomAccessFile(filename, "rw");
    fileLength = file.length();
    if (fileLength > 0) {
        numberPages = (int) (fileLength / Page.PAGE_SIZE);
        if (!offline)
            shrinkFile();
    } else
        initialize(initialPages);
    sync();
    if (freePoolEnabled)
        buildFreePageList();
    if (!offline) {
        Entity entity = ctx.filesList.createEntity();
        entity.setName(FILENAME);
        entity.createCommands();
        ctx.filesList.addEntity(entity);
        freeProp = entity.getProperty("free-pages");
        usedProp = entity.getProperty("used-pages");
        fileSizeProp = entity.getProperty("file-size");
        sizeCollectProp = ctx.dbEntity.getProperty("size-collect-interval");
        collectInterval = (long) (Long) sizeCollectProp.getValue();
        startTimer();
        PropertyChangeListener propChangeListener = new PropertyChangeListener() {

            public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
                stopTimer();
                collectInterval = (Long) newValue;
                startTimer();
            }
        };
        sizeCollectProp.setPropertyChangeListener(propChangeListener);
        swiftletManagerAdapter = new SwiftletManagerAdapter() {

            public void swiftletStarted(SwiftletManagerEvent event) {
                mgmtSwiftlet = (MgmtSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$mgmt");
                mgmtSwiftlet.addMgmtListener(StableStore.this);
            }
        };
        SwiftletManager.getInstance().addSwiftletManagerListener("sys$mgmt", swiftletManagerAdapter);
    }
    ctx.logSwiftlet.logInformation("sys$store", toString() + "/init done, size=" + numberPages + ", freePages=" + getNumberFreePages());
}
Also used : IntRingBuffer(com.swiftmq.tools.collection.IntRingBuffer) Entity(com.swiftmq.mgmt.Entity) SwiftletManagerEvent(com.swiftmq.swiftlet.event.SwiftletManagerEvent) RandomAccessFile(java.io.RandomAccessFile) PropertyChangeListener(com.swiftmq.mgmt.PropertyChangeListener) MgmtSwiftlet(com.swiftmq.swiftlet.mgmt.MgmtSwiftlet) Property(com.swiftmq.mgmt.Property) SwiftletManagerAdapter(com.swiftmq.swiftlet.event.SwiftletManagerAdapter)

Aggregations

Property (com.swiftmq.mgmt.Property)2 PropertyChangeListener (com.swiftmq.mgmt.PropertyChangeListener)2 Entity (com.swiftmq.mgmt.Entity)1 PropertyChangeException (com.swiftmq.mgmt.PropertyChangeException)1 SwiftletManagerAdapter (com.swiftmq.swiftlet.event.SwiftletManagerAdapter)1 SwiftletManagerEvent (com.swiftmq.swiftlet.event.SwiftletManagerEvent)1 MgmtSwiftlet (com.swiftmq.swiftlet.mgmt.MgmtSwiftlet)1 IntRingBuffer (com.swiftmq.tools.collection.IntRingBuffer)1 RandomAccessFile (java.io.RandomAccessFile)1