Search in sources :

Example 31 with Entity

use of com.swiftmq.mgmt.Entity 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 32 with Entity

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

the class Scheduler method visit.

public void visit(ScheduleAdded po) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/" + po + " ...");
    Schedule schedule = po.getSchedule();
    Entity entity = null;
    if (po.isMessageSchedule()) {
        entity = ctx.activeMessageScheduleList.createEntity();
        entity.setName(schedule.getName());
        entity.createCommands();
        entity.setDynamic(true);
        try {
            entity.getProperty("state").setValue(STATE_NONE);
            entity.getProperty("schedule-date-from").setValue(schedule.getDateFrom() == null ? ScheduleFactory.NOW : schedule.getDateFrom());
            entity.getProperty("schedule-date-to").setValue(schedule.getDateTo() == null ? ScheduleFactory.FOREVER : schedule.getDateTo());
            entity.getProperty("schedule-calendar").setValue(schedule.getCalendar());
            entity.getProperty("schedule-logging-enabled").setValue(new Boolean(schedule.isLoggingEnabled()));
            entity.getProperty("schedule-time-expression").setValue(schedule.getTimeExpression());
            ctx.activeMessageScheduleList.addEntity(entity);
        } catch (Exception e) {
        }
    } else {
        entity = ctx.activeScheduleList.createEntity();
        entity.setName(schedule.getName());
        entity.createCommands();
        entity.setDynamic(true);
        try {
            entity.getProperty("job-group").setValue(schedule.getJobGroup());
            entity.getProperty("job-name").setValue(schedule.getJobName());
            entity.getProperty("state").setValue(STATE_NONE);
            ctx.activeScheduleList.addEntity(entity);
        } catch (Exception e) {
        }
    }
    Entry scheduleEntry = new Entry(schedule, entity);
    scheduleEntry.messageSchedule = po.isMessageSchedule();
    addHistory(scheduleEntry, STATE_NONE, null);
    schedules.put(schedule.getName(), scheduleEntry);
    calcSchedule(scheduleEntry);
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/" + po + " done");
}
Also used : Entity(com.swiftmq.mgmt.Entity) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 33 with Entity

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

the class AMQPHandler method visit.

public void visit(POSendOpen po) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " ...");
    Entity connectionTemplate = versionedConnection.getConnectionTemplate();
    myIdleTimeout = ((Long) connectionTemplate.getProperty("idle-timeout").getValue()).longValue();
    OpenFrame frame = new OpenFrame(0);
    frame.setContainerId(new AMQPString(SwiftletManager.getInstance().getRouterName()));
    frame.setChannelMax(new AMQPUnsignedShort(((Integer) connectionTemplate.getProperty("max-channel-number").getValue()).intValue()));
    frame.setMaxFrameSize(new AMQPUnsignedInt(((Long) connectionTemplate.getProperty("max-frame-size").getValue()).longValue()));
    try {
        AMQPArray offeredCapas = new AMQPArray(AMQPTypeDecoder.SYM8, new AMQPSymbol[] { new AMQPSymbol(CAPABILITY_NO_LOCAL), new AMQPSymbol(CAPABILITY_SELECTOR) });
        frame.setOfferedCapabilities(offeredCapas);
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (myIdleTimeout > 0) {
        frame.setIdleTimeOut(new Milliseconds(myIdleTimeout));
        idleTimeoutChecker = new TimerListener() {

            public void performTimeAction() {
                dispatch(new POCheckIdleTimeout(null));
            }
        };
        ctx.timerSwiftlet.addTimerListener(myIdleTimeout / 2, idleTimeoutChecker);
    }
    versionedConnection.send(AMQPHandlerFactory.AMQP_INIT);
    versionedConnection.send(frame);
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " done");
}
Also used : Entity(com.swiftmq.mgmt.Entity) IOException(java.io.IOException) Milliseconds(com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds) TimerListener(com.swiftmq.swiftlet.timer.event.TimerListener)

Example 34 with Entity

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

the class TransformerFactory method toMap.

private Map toMap(EntityList list) {
    Map result = new HashMap();
    Map entities = list.getEntities();
    if (entities != null && entities.size() > 0) {
        for (Iterator iter = entities.entrySet().iterator(); iter.hasNext(); ) {
            Entity e = (Entity) ((Map.Entry) iter.next()).getValue();
            result.put(e.getName(), e.getProperty("value").getValue());
        }
    }
    return result;
}
Also used : Entity(com.swiftmq.mgmt.Entity) HashMap(java.util.HashMap) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap)

Example 35 with Entity

use of com.swiftmq.mgmt.Entity 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)

Aggregations

Entity (com.swiftmq.mgmt.Entity)179 Property (com.swiftmq.mgmt.Property)154 JMSException (javax.jms.JMSException)149 InvalidSelectorException (javax.jms.InvalidSelectorException)147 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)140 InvalidDestinationException (javax.jms.InvalidDestinationException)105 TopicImpl (com.swiftmq.jms.TopicImpl)42 QueueImpl (com.swiftmq.jms.QueueImpl)35 com.swiftmq.jms (com.swiftmq.jms)16 EntityList (com.swiftmq.mgmt.EntityList)15 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)11 Map (java.util.Map)10 Iterator (java.util.Iterator)9 MessageSelector (com.swiftmq.ms.MessageSelector)7 EntityAddException (com.swiftmq.mgmt.EntityAddException)5 QueueException (com.swiftmq.swiftlet.queue.QueueException)2 QueueTransactionClosedException (com.swiftmq.swiftlet.queue.QueueTransactionClosedException)2 JobException (com.swiftmq.swiftlet.scheduler.JobException)2 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)2 HashMap (java.util.HashMap)2