Search in sources :

Example 11 with Dumpable

use of com.swiftmq.tools.dump.Dumpable 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 12 with Dumpable

use of com.swiftmq.tools.dump.Dumpable 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 13 with Dumpable

use of com.swiftmq.tools.dump.Dumpable in project swiftmq-client by iitsoftware.

the class EndpointImpl method poll.

public void poll() {
    try {
        AMQPMessage msg = consumer.receiveNoWait(this);
        if (msg != null) {
            Data data = msg.getData().get(0);
            dis.reset();
            dis.setBuffer(data.getValue());
            Dumpable d = Dumpalizer.construct(dis, factory);
            if (d instanceof Reply)
                requestRegistry.setReply((Reply) d);
            else
                dispatch((Request) d);
            pollerService.execute(poller);
        }
    } catch (Exception e) {
        e.printStackTrace();
        close();
    }
}
Also used : Data(com.swiftmq.amqp.v100.generated.messaging.message_format.Data) AMQPMessage(com.swiftmq.amqp.v100.messaging.AMQPMessage) Dumpable(com.swiftmq.tools.dump.Dumpable)

Example 14 with Dumpable

use of com.swiftmq.tools.dump.Dumpable in project swiftmq-client by iitsoftware.

the class Connector method visit.

public void visit(PODataAvailable po) {
    if (debug)
        System.out.println(toString() + ", visit, po=" + po + " ...");
    try {
        if (po.getIoException() != null)
            throw po.getIoException();
        Dumpable obj = po.getDumpable();
        if (debug)
            System.out.println(toString() + ", dataAvailable, obj=" + obj);
        if (!recreateStarted) {
            if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
                SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
                for (int i = 0; i < bulkRequest.len; i++) {
                    Dumpable dumpable = (Dumpable) bulkRequest.dumpables[i];
                    if (dumpable.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ)
                        setReply(dumpable);
                }
            } else
                setReply(obj);
            current = null;
        } else if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
            SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
            for (int i = 0; i < bulkRequest.len; i++) {
                Dumpable dumpable = (Dumpable) bulkRequest.dumpables[i];
                if (dumpable.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ) {
                    currentRecreatePO.getRecreatable().setRecreateReply((Reply) dumpable);
                    currentRecreatePO.setSuccess(true);
                    if (currentRecreatePO.getSemaphore() != null)
                        currentRecreatePO.getSemaphore().notifySingleWaiter();
                }
            }
        } else {
            currentRecreatePO.getRecreatable().setRecreateReply((Reply) obj);
            currentRecreatePO.setSuccess(true);
            if (currentRecreatePO.getSemaphore() != null)
                currentRecreatePO.getSemaphore().notifySingleWaiter();
        }
        currentRecreatePO = null;
        requestTime = -1;
    } catch (Exception e) {
        if (debug)
            System.out.println(toString() + ", visit, po=" + po + ", exception=" + e + ", recreateStarted=" + recreateStarted);
        if (currentRecreatePO != null) {
            currentRecreatePO.setSuccess(false);
            currentRecreatePO.setException(e.toString());
            if (currentRecreatePO.getSemaphore() != null)
                currentRecreatePO.getSemaphore().notifySingleWaiter();
            currentRecreatePO = null;
            recreateStarted = false;
            if (debug)
                System.out.println(toString() + ", set recreateStarted to " + recreateStarted);
        }
        reconnector.invalidateConnection();
        connection = null;
        reconnectInProgress = false;
        currentRecreatePO = null;
        requestTime = -1;
        if (debug)
            System.out.println(toString() + ", ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException))?" + ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException)));
        if ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException)) {
            if (sem != null)
                sem.notifySingleWaiter();
        } else {
            if (debug)
                System.out.println(toString() + ", e is instanceof " + e.getClass().getName());
            dispatch(new POReconnect(sem, recreatableConnection, true));
        }
    }
    if (debug)
        System.out.println(toString() + ", visit, po=" + po + " done");
}
Also used : JMSSecurityException(javax.jms.JMSSecurityException) InvalidVersionException(com.swiftmq.jms.InvalidVersionException) SMQPBulkRequest(com.swiftmq.jms.smqp.v750.SMQPBulkRequest) Reply(com.swiftmq.tools.requestreply.Reply) InvalidVersionException(com.swiftmq.jms.InvalidVersionException) IOException(java.io.IOException) JMSSecurityException(javax.jms.JMSSecurityException) Dumpable(com.swiftmq.tools.dump.Dumpable)

Example 15 with Dumpable

use of com.swiftmq.tools.dump.Dumpable in project swiftmq-client by iitsoftware.

the class Connector method dataAvailable.

public void dataAvailable(LengthCaptureDataInput in) {
    PODataAvailable po = new PODataAvailable();
    try {
        Dumpable obj = Dumpalizer.construct(in, dumpableFactory);
        if (obj == null || obj.getDumpId() == SMQPFactory.DID_KEEPALIVE_REQ)
            return;
        po.setDumpable(obj);
    } catch (IOException e) {
        po.setIoException(e);
    }
    if (debug)
        System.out.println("InboundHandler.dataAvailable, po=" + po);
    dispatch(po);
}
Also used : IOException(java.io.IOException) Dumpable(com.swiftmq.tools.dump.Dumpable)

Aggregations

Dumpable (com.swiftmq.tools.dump.Dumpable)23 Request (com.swiftmq.tools.requestreply.Request)8 IOException (java.io.IOException)6 Reply (com.swiftmq.tools.requestreply.Reply)4 LengthCaptureDataInput (com.swiftmq.tools.util.LengthCaptureDataInput)3 DataInput (java.io.DataInput)3 JMSSecurityException (javax.jms.JMSSecurityException)3 Endpoint (com.swiftmq.admin.mgmt.Endpoint)2 Data (com.swiftmq.amqp.v100.generated.messaging.message_format.Data)2 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)2 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)2 InvalidVersionException (com.swiftmq.jms.InvalidVersionException)2 SMQPBulkRequest (com.swiftmq.jms.smqp.v600.SMQPBulkRequest)2 SMQPBulkRequest (com.swiftmq.jms.smqp.v610.SMQPBulkRequest)2 SMQPBulkRequest (com.swiftmq.jms.smqp.v630.SMQPBulkRequest)2 SMQPBulkRequest (com.swiftmq.jms.smqp.v750.SMQPBulkRequest)2 BulkRequest (com.swiftmq.impl.routing.single.smqpr.BulkRequest)1 SMQPBulkRequest (com.swiftmq.jms.smqp.v400.SMQPBulkRequest)1 SMQPBulkRequest (com.swiftmq.jms.smqp.v500.SMQPBulkRequest)1 SMQPBulkRequest (com.swiftmq.jms.smqp.v510.SMQPBulkRequest)1