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);
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations