use of com.swiftmq.jms.MessageImpl in project swiftmq-ce by iitsoftware.
the class NontransactedQueueSession method visit.
public void visit(ProduceMessageRequest req) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitProduceMessageRequest");
ctx.incMsgsSent(1);
ProduceMessageReply reply = null;
if (req.isReplyRequired())
reply = (ProduceMessageReply) req.createReply();
int producerId = req.getQueueProducerId();
Producer producer = null;
try {
MessageImpl msg = SMQPUtil.getMessage(req);
long ttl = msg.getJMSExpiration();
if (ttl > 0)
msg.setJMSExpiration(System.currentTimeMillis() + ttl);
if (producerId == -1) {
String queueName = ((QueueImpl) msg.getJMSDestination()).getQueueName();
if (!ctx.queueManager.isQueueRunning(queueName))
throw new InvalidDestinationException("Invalid destination: " + queueName);
producer = new QueueProducer(ctx, queueName);
} else {
producer = (Producer) producerList.get(producerId);
}
QueuePushTransaction transaction = (QueuePushTransaction) producer.createTransaction();
transaction.putMessage(msg);
transaction.commit();
if (req.isReplyRequired()) {
reply.setDelay(transaction.getFlowControlDelay());
reply.setOk(true);
}
if (producerId == -1)
producer.close();
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/produce messages failed: " + e.getMessage());
if (req.isReplyRequired()) {
reply.setOk(false);
reply.setException(e);
}
}
if (req.isReplyRequired())
reply.send();
}
use of com.swiftmq.jms.MessageImpl 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;
}
}
use of com.swiftmq.jms.MessageImpl in project swiftmq-ce by iitsoftware.
the class MessageSenderJob method getMessage.
private MessageImpl getMessage() throws Exception {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/getMessage ...");
MessageSelector selector = new MessageSelector(ctx.PROP_SCHED_ID + " = '" + id + "'");
selector.compile();
QueueReceiver receiver = ctx.queueManager.createQueueReceiver(ctx.INTERNAL_QUEUE, null, selector);
QueuePullTransaction t = receiver.createTransaction(false);
MessageEntry entry = t.getMessage(0, selector);
t.rollback();
receiver.close();
if (entry == null)
throw new Exception("Schedule with ID '" + id + "' not found!");
MessageImpl msg = copyMessage(entry.getMessage());
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/getMessage done");
return msg;
}
use of com.swiftmq.jms.MessageImpl in project swiftmq-client by iitsoftware.
the class FilePublishRequest method toMessage.
public Message toMessage() throws JMSException {
Message message = new MessageImpl();
fillMessage(message);
message.setIntProperty(ProtocolFactory.DUMPID_PROP, ProtocolFactory.FILEPUBLISH_REQ);
message.setStringProperty(REPLYQUEUE_PROP, replyQueue);
message.setStringProperty(FILENAME_PROP, filename);
if (username != null)
message.setStringProperty(USERNAME_PROP, username);
message.setLongProperty(SIZE_PROP, size);
message.setLongProperty(EXPIRATION_PROP, expiration);
message.setStringProperty(DIGESTTYPE_PROP, digestType);
if (passwordHexDigest != null)
message.setStringProperty(PWDHEXDIGEST_PROP, passwordHexDigest);
message.setIntProperty(DELAFTERDL_PROP, deleteAfterNumberDownloads);
message.setBooleanProperty(FILEISPRIVATE_PROP, fileIsPrivate);
return message;
}
use of com.swiftmq.jms.MessageImpl in project swiftmq-client by iitsoftware.
the class FileConsumeReply method toMessage.
public Message toMessage() throws JMSException {
Message message = new MessageImpl();
message.setIntProperty(ProtocolFactory.DUMPID_PROP, ProtocolFactory.FILECONSUME_REP);
message.setStringProperty(FILENAME_PROP, filename);
message.setIntProperty(CHUNKLENGTH_PROP, chunkLength);
message.setLongProperty(SIZE_PROP, size);
return fillMessage(message);
}
Aggregations