Search in sources :

Example 1 with Message

use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.

the class ManagementProcessor method entityAdded.

@Override
public void entityAdded(Entity parent, Entity newEntity) {
    if (input.hasChangeCallback())
        watchListenerMap.put(newEntity.getName(), new AllPropertyWatchListener(newEntity).register());
    if (!input.hasAddCallback())
        return;
    Message message = addProperties(ctx.messageBuilder.message().property(ManagementInput.PROP_OPER).set(ManagementInput.VAL_ADD).property(ManagementInput.PROP_TIME).set(System.currentTimeMillis()), newEntity);
    sendMessage(message);
}
Also used : POMgmtMessage(com.swiftmq.impl.streams.processor.po.POMgmtMessage) Message(com.swiftmq.impl.streams.comp.message.Message)

Example 2 with Message

use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.

the class ManagementProcessor method propertyValueChanged.

@Override
public void propertyValueChanged(Property property) {
    if (!input.hasChangeCallback())
        return;
    if (property.getValue() != null && prevValue != null && !property.getValue().equals(prevValue) || prevValue == null) {
        Message message = ctx.messageBuilder.message().property(ManagementInput.PROP_OPER).set(ManagementInput.VAL_CHANGE).property(ManagementInput.PROP_CTX).set(input.context()).property(ManagementInput.PROP_TIME).set(System.currentTimeMillis()).property("name").set(property.getParent().getName()).property(property.getName().replace("-", "_")).set(property.getValue());
        List<String> propIncludes = input.getPropIncludes();
        if (propIncludes != null) {
            for (int i = 0; i < propIncludes.size(); i++) {
                String propName = propIncludes.get(i);
                String propNameU = propName.replace('-', '_');
                if (message.property(propNameU).value().toObject() == null && property.getParent().getProperty(propName) != null) {
                    message.property(propNameU).set(property.getParent().getProperty(propName).getValue());
                }
            }
        }
        sendMessage(message);
        prevValue = property.getValue();
    }
}
Also used : POMgmtMessage(com.swiftmq.impl.streams.processor.po.POMgmtMessage) Message(com.swiftmq.impl.streams.comp.message.Message)

Example 3 with Message

use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.

the class QueueMemory method add.

@Override
public Memory add(Message message) throws Exception {
    if (ctx.ctx.traceSpace.enabled)
        ctx.ctx.traceSpace.trace(ctx.ctx.streamsSwiftlet.getName(), toString() + "/add ...");
    if (isLate(message))
        return this;
    String key = message.messageId();
    if (key == null)
        key = ctx.nextId();
    if (messageStore.get(key) != null) {
        // Duplicate!
        return this;
    }
    long storeTime = getStoreTime(message);
    checkLimit();
    KeyEntry keyEntry = new KeyEntry(key, null, storeTime);
    messageStore.add(key, keyEntry);
    Message copy = ctx.messageBuilder.copyMessage(message);
    MessageImpl impl = copy.getImpl();
    if (impl.getJMSDestination() == null)
        impl.setJMSDestination(new QueueImpl(queueName));
    // Important for the ordering
    impl.setJMSPriority(0);
    impl.setJMSDeliveryMode(getDeliveryMode());
    impl.setJMSTimestamp(storeTime);
    if (key.startsWith("ID:"))
        impl.setJMSMessageID(key.substring(3));
    else
        impl.setJMSMessageID(key);
    if (shared)
        impl.setStringProperty(KEY, name);
    txBookKeeper.add(key, copy, keyEntry);
    addToIndexes(key, copy);
    if (ctx.ctx.traceSpace.enabled)
        ctx.ctx.traceSpace.trace(ctx.ctx.streamsSwiftlet.getName(), toString() + "/add done");
    return this;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message) MessageImpl(com.swiftmq.jms.MessageImpl) QueueImpl(com.swiftmq.jms.QueueImpl)

Example 4 with Message

use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.

the class GroupResult method sum.

/**
 * Determines the sum of all values of a Property and returns the result as a new non-queue Memory with
 * Messages that contains 2 Properties, the grouping Property and the sum Property.
 *
 * @param propName Property Name
 * @return Result
 * @throws Exception
 */
public Memory sum(String propName) throws Exception {
    Memory child = new HeapMemory(ctx);
    for (int i = 0; i < result.length; i++) {
        Message message = result[i].first();
        child.add(ctx.messageBuilder.message().property(groupPropName).set(message.property(groupPropName).value().toObject()).property(propName).set(result[i].sum(propName)));
    }
    return child;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message)

Example 5 with Message

use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.

the class HeapMemory method select.

@Override
public Memory select(String selector) throws Exception {
    MessageSelector sel = new MessageSelector(selector);
    sel.compile();
    Memory child = new HeapMemory(ctx);
    for (int i = 0; i < size(); i++) {
        Message message = at(i);
        if (message.isSelected(sel))
            child.add(message);
    }
    return child;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message) MessageSelector(com.swiftmq.ms.MessageSelector)

Aggregations

Message (com.swiftmq.impl.streams.comp.message.Message)21 Property (com.swiftmq.impl.streams.comp.message.Property)4 POMgmtMessage (com.swiftmq.impl.streams.processor.po.POMgmtMessage)3 ManagementInput (com.swiftmq.impl.streams.comp.io.ManagementInput)2 QueueWireTapInput (com.swiftmq.impl.streams.comp.io.QueueWireTapInput)2 MessageSelector (com.swiftmq.ms.MessageSelector)2 Input (com.swiftmq.impl.streams.comp.io.Input)1 HeapMemory (com.swiftmq.impl.streams.comp.memory.HeapMemory)1 Memory (com.swiftmq.impl.streams.comp.memory.Memory)1 MessageImpl (com.swiftmq.jms.MessageImpl)1 QueueImpl (com.swiftmq.jms.QueueImpl)1 BigDecimal (java.math.BigDecimal)1 ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 Statement (java.sql.Statement)1