Search in sources :

Example 1 with EntityList

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

the class TopicBroker method addRemoteSubscriptionUsage.

private void addRemoteSubscriptionUsage(String routerName, String topicName) {
    if (ctx.remoteSubscriberList == null)
        return;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "addRemoteSubscriptionUsage, routerName=" + routerName + ", topicName=" + topicName);
    try {
        Entity rEntity = ctx.remoteSubscriberList.getEntity(routerName);
        if (rEntity == null) {
            rEntity = ctx.remoteSubscriberList.createEntity();
            rEntity.setName(routerName);
            rEntity.createCommands();
            ctx.remoteSubscriberList.addEntity(rEntity);
        }
        EntityList tEntityList = (EntityList) rEntity.getEntity("topics");
        if (tEntityList.getEntity(topicName) == null) {
            Entity entity = tEntityList.createEntity();
            entity.setName(topicName);
            entity.createCommands();
            tEntityList.addEntity(entity);
        }
    } catch (Exception e) {
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException) QueueTransactionClosedException(com.swiftmq.swiftlet.queue.QueueTransactionClosedException) JMSException(javax.jms.JMSException) QueueException(com.swiftmq.swiftlet.queue.QueueException)

Example 2 with EntityList

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

the class TopicBroker method removeRemoteSubscriptionUsage.

private void removeRemoteSubscriptionUsage(String routerName, String topicName) {
    if (ctx.remoteSubscriberList == null)
        return;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace("sys$topicmanager", tracePrefix + "removeRemoteSubscriptionUsage, routerName=" + routerName + ", topicName=" + topicName);
    try {
        Entity rEntity = ctx.remoteSubscriberList.getEntity(routerName);
        if (rEntity != null) {
            EntityList tEntityList = (EntityList) rEntity.getEntity("topics");
            Entity entity = tEntityList.getEntity(topicName);
            if (entity != null)
                tEntityList.removeEntity(entity);
            Map map = tEntityList.getEntities();
            if (map == null || map.size() == 0)
                ctx.remoteSubscriberList.removeEntity(rEntity);
        }
    } catch (Exception e) {
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException) QueueTransactionClosedException(com.swiftmq.swiftlet.queue.QueueTransactionClosedException) JMSException(javax.jms.JMSException) QueueException(com.swiftmq.swiftlet.queue.QueueException)

Example 3 with EntityList

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

the class Scheduler method addHistory.

private void addHistory(Entry entry, String state, String exception) {
    try {
        EntityList histList = (EntityList) entry.entity.getEntity("history");
        if (entry.histNo == 999) {
            entry.histNo = 0;
            Map map = histList.getEntities();
            if (map != null) {
                for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
                    histList.removeEntity((Entity) ((Map.Entry) iter.next()).getValue());
                }
            }
        }
        String[] names = histList.getEntityNames();
        if (names != null && names.length == 20) {
            String min = null;
            for (int i = 0; i < names.length; i++) {
                if (min == null || min.compareTo(names[i]) > 0)
                    min = names[i];
            }
            histList.removeEntity(histList.getEntity(min));
        }
        Entity entity = histList.createEntity();
        entity.setName(dfmt.format(++entry.histNo));
        entity.createCommands();
        entity.getProperty("logtime").setValue(fmt.format(new Date()));
        entity.getProperty("state").setValue(state);
        if (exception != null)
            entity.getProperty("xception").setValue(exception);
        histList.addEntity(entity);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 4 with EntityList

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

the class TransformerFactory method createInboundTransformer.

public InboundTransformer createInboundTransformer(long messageFormat, String destination) throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", createInboundTransformer, messageFormat=" + messageFormat + ", destination=" + destination + " ...");
    Entity result = null;
    Entity dest = destinationTransformerList.getEntity(destination);
    if (dest != null) {
        EntityList inboundList = (EntityList) dest.getEntity("inbound-transformers");
        if (inboundList != null)
            result = inboundList.getEntity(String.valueOf(messageFormat));
    }
    if (result == null) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", createInboundTransformer, messageFormat=" + messageFormat + ", destination=" + destination + ", no destination transformer found, using default");
        result = defaultInboundTransformerList.getEntity(String.valueOf(messageFormat));
    }
    InboundTransformer inboundTransformer = null;
    if (result != null) {
        inboundTransformer = (InboundTransformer) Class.forName((String) result.getProperty("class-name").getValue()).newInstance();
        inboundTransformer.setConfiguration(toMap((EntityList) result.getEntity("properties")));
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", createInboundTransformer, messageFormat=" + messageFormat + ", destination=" + destination + " returns " + inboundTransformer);
    return inboundTransformer;
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList)

Example 5 with EntityList

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

the class RouteTable method addUsageEntity.

private void addUsageEntity(Route route) {
    try {
        Entity destEntity = dynRoutes.getEntity(route.getDestinationRouter());
        if (destEntity == null) {
            destEntity = dynRoutes.createEntity();
            destEntity.setName(route.getDestinationRouter());
            destEntity.createCommands();
            dynRoutes.addEntity(destEntity);
        }
        EntityList routes = (EntityList) destEntity.getEntity("dynamic-routes");
        Entity dr = routes.createEntity();
        dr.setName(route.getKey());
        dr.createCommands();
        routes.addEntity(dr);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityList(com.swiftmq.mgmt.EntityList) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Aggregations

EntityList (com.swiftmq.mgmt.EntityList)17 Entity (com.swiftmq.mgmt.Entity)15 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)8 Iterator (java.util.Iterator)5 Map (java.util.Map)5 EntityAddException (com.swiftmq.mgmt.EntityAddException)4 QueueException (com.swiftmq.swiftlet.queue.QueueException)2 QueueTransactionClosedException (com.swiftmq.swiftlet.queue.QueueTransactionClosedException)2 JMSException (javax.jms.JMSException)2 JobFactoryAdded (com.swiftmq.impl.scheduler.standard.po.JobFactoryAdded)1 ManagementProcessor (com.swiftmq.impl.streams.processor.ManagementProcessor)1 Property (com.swiftmq.mgmt.Property)1 JobParameter (com.swiftmq.swiftlet.scheduler.JobParameter)1 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 Properties (java.util.Properties)1 XAException (javax.transaction.xa.XAException)1