use of com.swiftmq.jms.MessageImpl 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.jms.MessageImpl in project swiftmq-ce by iitsoftware.
the class Message method copyMessage.
private MessageImpl copyMessage(MessageImpl msg) throws Exception {
DataByteArrayOutputStream dbos = new DataByteArrayOutputStream(4096);
DataByteArrayInputStream dbis = new DataByteArrayInputStream();
dbos.rewind();
msg.writeContent(dbos);
dbis.reset();
dbis.setBuffer(dbos.getBuffer(), 0, dbos.getCount());
MessageImpl msgCopy = MessageImpl.createInstance(dbis.readInt());
msgCopy.readContent(dbis);
msgCopy.clearSwiftMQAllProps();
return msgCopy;
}
use of com.swiftmq.jms.MessageImpl in project swiftmq-ce by iitsoftware.
the class Message method copyProperties.
/**
* Internal use only.
*/
public Message copyProperties(Message source) throws JMSException {
ensureLocalCopy();
MessageImpl sourceImpl = source.getImpl();
for (Enumeration _e = sourceImpl.getPropertyNames(); _e.hasMoreElements(); ) {
String name = (String) _e.nextElement();
_impl.setObjectProperty(name, sourceImpl.getObjectProperty(name));
}
return this;
}
use of com.swiftmq.jms.MessageImpl in project swiftmq-client by iitsoftware.
the class MessageConsumerImpl method reportDelivered.
protected void reportDelivered(Message message, boolean duplicate) {
try {
MessageIndex messageIndex = ((MessageImpl) message).getMessageIndex();
requestRegistry.request(new MessageDeliveredRequest(this, mySession.dispatchId, serverQueueConsumerId, messageIndex, duplicate));
} catch (Exception e) {
}
}
use of com.swiftmq.jms.MessageImpl in project swiftmq-client by iitsoftware.
the class MessageConsumerImpl method addToCache.
void addToCache(AsyncMessageDeliveryRequest request) {
if (isClosed())
return;
if (request.isRequiresRestart())
fillCachePending = false;
MessageImpl msg = request.getMessageEntry().getMessage();
if (request.getConnectionId() != mySession.myConnection.getConnectionId()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { mySession.myConnection.toString(), mySession.toString(), toString() }, "addToCache, invalid connectionId (" + request.getConnectionId() + " vs " + mySession.myConnection.getConnectionId() + ")");
}
return;
}
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(msg, new String[] { mySession.myConnection.toString(), mySession.toString(), toString() }, "addToCache");
}
messageCache.add(request);
}
Aggregations