use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.
the class PreparedLogQueue method add.
public synchronized long add(PrepareLogRecordImpl logRecord) throws IOException {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$store", toString() + "/add, logRecord: " + logRecord);
CacheEntry cacheEntry = new CacheEntry();
cacheEntry.logRecord = logRecord;
long address = (long) ArrayListTool.setFirstFreeOrExpand(cache, cacheEntry);
logRecord.setAddress(address);
outStream.rewind();
logRecord.writeContent(outStream);
try {
BytesMessageImpl msg = new BytesMessageImpl();
msg.writeBytes(outStream.getBuffer(), 0, outStream.getCount());
StoreEntry storeEntry = new StoreEntry();
storeEntry.message = msg;
long txId = ctx.transactionManager.createTxId(false);
List journal = new ArrayList();
queueIndex.setJournal(journal);
cacheEntry.indexEntry = queueIndex.add(storeEntry);
Semaphore sem = new Semaphore();
ctx.recoveryManager.commit(new CommitLogRecord(txId, sem, journal, this, null));
sem.waitHere();
ctx.transactionManager.removeTxId(txId);
} catch (Exception e) {
throw new IOException(e.toString());
}
return address;
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.
the class ClusterMetricPublisher method performTimeAction.
public void performTimeAction() {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/performTimeAction ...");
ClusteredQueueMetricCollection cmc = ctx.dispatchPolicyRegistry.getClusteredQueueMetricCollection();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/performTimeAction, cmc=" + cmc);
List list = cmc.getClusteredQueueMetrics();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
ClusteredQueueMetric cm = (ClusteredQueueMetric) list.get(i);
List list2 = cm.getQueueMetrics();
if (list2 != null) {
for (int j = 0; j < list2.size(); j++) {
QueueMetric qm = (QueueMetric) list2.get(j);
AbstractQueue queue = ctx.queueManager.getQueueForInternalUse(qm.getQueueName());
if (queue != null) {
try {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/performTimeAction, queue=" + qm.getQueueName() + ", qm.hasReceiver()=" + qm.hasReceiver() + ", cm.isReceiverSomewhere()=" + cm.isReceiverSomewhere() + ", qm.isRedispatch()=" + qm.isRedispatch() + ", queue.getNumberQueueMessages()=" + queue.getNumberQueueMessages());
if (!qm.hasReceiver() && cm.isReceiverSomewhere() && qm.isRedispatch() && queue.getNumberQueueMessages() > 0)
ctx.redispatcherController.redispatch(qm.getQueueName(), cm.getClusteredQueueName());
} catch (QueueException e) {
}
}
}
}
}
}
try {
QueuePushTransaction transaction = sender.createTransaction();
Versionable versionable = new Versionable();
versionable.addVersioned(700, createVersioned(700, cmc), "com.swiftmq.impl.queue.standard.cluster.v700.MetricFactory");
BytesMessageImpl msg = createMessage(versionable);
transaction.putMessage(msg);
transaction.commit();
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/performTimeAction, exception=" + e);
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/performTimeAction done");
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-client by iitsoftware.
the class EndpointImpl method performRequest.
public synchronized void performRequest(Request request) {
try {
dos.rewind();
Dumpalizer.dump(dos, request);
BytesMessageImpl msg = new BytesMessageImpl();
msg.writeBytes(dos.getBuffer(), 0, dos.getCount());
msg.setJMSReplyTo(replyQueue);
sender.send(msg);
} catch (Exception e) {
close();
}
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-client by iitsoftware.
the class EndpointImpl method onMessage.
public void onMessage(Message message) {
try {
BytesMessageImpl msg = (BytesMessageImpl) message;
int len = (int) msg._getBodyLength();
if (buffer == null || len > buffer.length)
buffer = new byte[len];
msg.readBytes(buffer);
dis.reset();
dis.setBuffer(buffer);
Dumpable d = Dumpalizer.construct(dis, factory);
if (d instanceof Reply)
requestRegistry.setReply((Reply) d);
else
dispatch((Request) d);
} catch (Exception e) {
e.printStackTrace();
close();
}
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-client by iitsoftware.
the class EndpointImpl method onMessage.
public void onMessage(Message message) {
try {
BytesMessageImpl msg = (BytesMessageImpl) message;
int len = (int) msg._getBodyLength();
if (buffer == null || len > buffer.length)
buffer = new byte[len];
msg.readBytes(buffer);
dis.reset();
dis.setBuffer(buffer);
Dumpable d = Dumpalizer.construct(dis, factory);
if (d instanceof Reply)
requestRegistry.setReply((Reply) d);
else
dispatch((Request) d);
} catch (Exception e) {
e.printStackTrace();
close();
}
}
Aggregations