Search in sources :

Example 26 with Entity

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

the class HeuristicHandler method getXids.

public List getXids() {
    Map map = ctx.heuristicUsageList.getEntities();
    if (map != null && map.size() > 0) {
        List list = new ArrayList();
        for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
            Entity entity = (Entity) ((Map.Entry) iter.next()).getValue();
            list.add(entity.getUserObject());
        }
        return list;
    } else
        return null;
}
Also used : Entity(com.swiftmq.mgmt.Entity) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 27 with Entity

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

the class HeuristicHandler method addHeuristic.

public void addHeuristic(XidImpl xid, boolean commit) throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/addHeuristic, xid=" + xid);
    Entity entity = ctx.heuristicUsageList.createEntity();
    if (maxId == Integer.MAX_VALUE)
        maxId = 0;
    entity.setName(String.valueOf(++maxId));
    entity.setUserObject(xid);
    entity.getProperty("xid").setValue(xid.toString());
    entity.getProperty("operation").setValue(commit ? "COMMIT" : "ROLLBACK");
    entity.createCommands();
    ctx.heuristicUsageList.addEntity(entity);
}
Also used : Entity(com.swiftmq.mgmt.Entity)

Example 28 with Entity

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

the class HeuristicHandler method findHeuristic.

private Entity findHeuristic(XidImpl xid) {
    Map map = ctx.heuristicUsageList.getEntities();
    if (map != null && map.size() > 0) {
        for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
            Entity entity = (Entity) ((Map.Entry) iter.next()).getValue();
            XidImpl thatXid = (XidImpl) entity.getUserObject();
            if (thatXid.equals(xid))
                return entity;
        }
    }
    return null;
}
Also used : Entity(com.swiftmq.mgmt.Entity) XidImpl(com.swiftmq.jms.XidImpl) Iterator(java.util.Iterator) Map(java.util.Map)

Example 29 with Entity

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

the class HeuristicHandler method loadHeuristics.

public void loadHeuristics() throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/loadHeuristics");
    duringLoad = true;
    try {
        if (!ctx.queueManager.isQueueDefined(HEURISTIC_QUEUE))
            ctx.queueManager.createQueue(HEURISTIC_QUEUE, (ActiveLogin) null);
        QueueReceiver receiver = ctx.queueManager.createQueueReceiver(HEURISTIC_QUEUE, null, null);
        QueuePullTransaction t = receiver.createTransaction(false);
        MessageEntry entry = null;
        while ((entry = t.getMessage(0)) != null) {
            Entity entity = ctx.heuristicUsageList.createEntity();
            MessageImpl msg = entry.getMessage();
            maxId = Math.max(maxId, msg.getIntProperty(PROP_IID));
            messageToEntity(msg, entity);
            entity.createCommands();
            ctx.heuristicUsageList.addEntity(entity);
        }
        t.rollback();
        receiver.close();
    } finally {
        duringLoad = false;
    }
}
Also used : Entity(com.swiftmq.mgmt.Entity) ActiveLogin(com.swiftmq.swiftlet.auth.ActiveLogin) MessageImpl(com.swiftmq.jms.MessageImpl) BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl)

Example 30 with Entity

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

the class XALiveContextImpl method registerUsageList.

// Will be called from a Timer
synchronized void registerUsageList() {
    if (registeredUsageList || closed || !prepared)
        return;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/registerUsageList...");
    Entity entity = ctx.preparedUsageList.createEntity();
    entity.setName(Integer.toString(incCount()));
    entity.setDynamicObject(xid);
    entity.createCommands();
    try {
        ctx.preparedUsageList.addEntity(entity);
        entity.getProperty("xid").setValue(signature);
    } catch (Exception e) {
    }
    registeredUsageList = true;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.xaSwiftlet.getName(), toString() + "/registerUsageList done");
}
Also used : Entity(com.swiftmq.mgmt.Entity) XAContextException(com.swiftmq.swiftlet.xa.XAContextException) XAException(javax.transaction.xa.XAException)

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