Search in sources :

Example 11 with BytesMessageImpl

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;
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) StoreEntry(com.swiftmq.swiftlet.store.StoreEntry) CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Semaphore(com.swiftmq.tools.concurrent.Semaphore) IOException(java.io.IOException) IOException(java.io.IOException) EOFException(java.io.EOFException)

Example 12 with BytesMessageImpl

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");
}
Also used : Versionable(com.swiftmq.tools.versioning.Versionable) AbstractQueue(com.swiftmq.swiftlet.queue.AbstractQueue) QueuePushTransaction(com.swiftmq.swiftlet.queue.QueuePushTransaction) BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) QueueException(com.swiftmq.swiftlet.queue.QueueException) List(java.util.List) QueueException(com.swiftmq.swiftlet.queue.QueueException) PropertyChangeException(com.swiftmq.mgmt.PropertyChangeException)

Example 13 with BytesMessageImpl

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();
    }
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl)

Example 14 with BytesMessageImpl

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();
    }
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) Endpoint(com.swiftmq.admin.mgmt.Endpoint) Dumpable(com.swiftmq.tools.dump.Dumpable)

Example 15 with BytesMessageImpl

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();
    }
}
Also used : BytesMessageImpl(com.swiftmq.jms.BytesMessageImpl) Endpoint(com.swiftmq.admin.mgmt.Endpoint) Dumpable(com.swiftmq.tools.dump.Dumpable)

Aggregations

BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)26 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)5 QueueImpl (com.swiftmq.jms.QueueImpl)4 List (java.util.List)4 JMSException (javax.jms.JMSException)4 Endpoint (com.swiftmq.admin.mgmt.Endpoint)2 ContentHeaderProperties (com.swiftmq.amqp.v091.types.ContentHeaderProperties)2 ByteBuf (com.swiftmq.impl.mqtt.v311.netty.buffer.ByteBuf)2 TextMessageImpl (com.swiftmq.jms.TextMessageImpl)2 XidImpl (com.swiftmq.jms.XidImpl)2 StoreEntry (com.swiftmq.swiftlet.store.StoreEntry)2 Dumpable (com.swiftmq.tools.dump.Dumpable)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 BytesMessage (javax.jms.BytesMessage)2 Field (com.swiftmq.amqp.v091.types.Field)1 AMQPException (com.swiftmq.amqp.v100.client.AMQPException)1 Delivery (com.swiftmq.impl.amqp.amqp.v00_09_01.Delivery)1 MqttFixedHeader (com.swiftmq.impl.mqtt.v311.netty.handler.codec.mqtt.MqttFixedHeader)1 QueueIndexEntry (com.swiftmq.impl.store.standard.index.QueueIndexEntry)1