Search in sources :

Example 1 with Error

use of com.swiftmq.amqp.v100.generated.transport.definitions.Error in project swiftmq-ce by iitsoftware.

the class SessionHandler method sendDetach.

private void sendDetach(Handle handle, ErrorConditionIF condition, AMQPString description) {
    DetachFrame detachFrame = new DetachFrame(channel);
    detachFrame.setHandle(handle);
    detachFrame.setClosed(AMQPBoolean.TRUE);
    if (condition != null) {
        Error error = new Error();
        error.setCondition(condition);
        if (description != null)
            error.setDescription(description);
        detachFrame.setError(error);
    }
    versionedConnection.send(detachFrame);
}
Also used : Error(com.swiftmq.amqp.v100.generated.transport.definitions.Error)

Example 2 with Error

use of com.swiftmq.amqp.v100.generated.transport.definitions.Error in project swiftmq-ce by iitsoftware.

the class SessionHandler method visit.

public void visit(POSendEnd po) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " ...");
    EndFrame frame = new EndFrame(channel);
    if (po.getErrorCondition() != null) {
        com.swiftmq.amqp.v100.generated.transport.definitions.Error error = new Error();
        error.setCondition(po.getErrorCondition());
        if (po.getDescription() != null)
            error.setDescription(po.getDescription());
        frame.setError(error);
    }
    versionedConnection.send(frame);
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " done");
}
Also used : Error(com.swiftmq.amqp.v100.generated.transport.definitions.Error) Error(com.swiftmq.amqp.v100.generated.transport.definitions.Error) com.swiftmq.amqp.v100.generated.transport.definitions(com.swiftmq.amqp.v100.generated.transport.definitions)

Example 3 with Error

use of com.swiftmq.amqp.v100.generated.transport.definitions.Error in project swiftmq-ce by iitsoftware.

the class AMQPHandler method visit.

public void visit(POSendClose po) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " ...");
    CloseFrame frame = new CloseFrame(0);
    if (po.getErrorCondition() != null) {
        com.swiftmq.amqp.v100.generated.transport.definitions.Error error = new Error();
        error.setCondition(po.getErrorCondition());
        if (po.getDescription() != null)
            error.setDescription(po.getDescription());
        frame.setError(error);
        connectionDisabled = true;
    }
    frame.setCallback(new AsyncCompletionCallback() {

        public void done(boolean b) {
            ctx.networkSwiftlet.getConnectionManager().removeConnection(versionedConnection.getConnection());
        }
    });
    versionedConnection.send(frame);
    closeFrameSent = true;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + ", visit, po=" + po + " done");
}
Also used : Error(com.swiftmq.amqp.v100.generated.transport.definitions.Error) AsyncCompletionCallback(com.swiftmq.tools.concurrent.AsyncCompletionCallback) ConnectionError(com.swiftmq.amqp.v100.generated.transport.definitions.ConnectionError) Error(com.swiftmq.amqp.v100.generated.transport.definitions.Error) AmqpError(com.swiftmq.amqp.v100.generated.transport.definitions.AmqpError)

Example 4 with Error

use of com.swiftmq.amqp.v100.generated.transport.definitions.Error in project swiftmq-client by iitsoftware.

the class Rejected method decode.

private void decode() throws Exception {
    List l = getValue();
    AMQPType t = null;
    int idx = 0;
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            error = new Error(((AMQPList) t).getValue());
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'error' in 'Rejected' type: " + e);
    }
}
Also used : Error(com.swiftmq.amqp.v100.generated.transport.definitions.Error) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 5 with Error

use of com.swiftmq.amqp.v100.generated.transport.definitions.Error in project swiftmq-client by iitsoftware.

the class SessionDispatcher method settleOutbound.

private void settleOutbound(long from, long to, boolean settled, DeliveryStateIF deliveryState) {
    if (from <= to) {
        long current = from;
        while (current <= to) {
            DeliveryMapping deliveryMapping = unsettledOutgoingDeliveries.remove(current);
            if (deliveryMapping != null) {
                deliveryMapping.link.getDeliveryMemory().deliverySettled(deliveryMapping.deliveryTag);
                if (deliveryMapping.link.getWaitingPO() != null) {
                    POSendMessage po = (POSendMessage) deliveryMapping.link.getWaitingPO();
                    po.setSuccess(true);
                    po.setDeliveryState(deliveryState);
                    po.getSemaphore().notifySingleWaiter();
                    deliveryMapping.link.setWaitingPO(null);
                }
                // If there is a close waiting on that link, dispatch it when there are no more unsettled deliveries
                if (deliveryMapping.link.getDeliveryMemory().getNumberUnsettled() == 0 && deliveryMapping.link.getWaitingClosePO() != null) {
                    dispatch(deliveryMapping.link.getWaitingClosePO());
                    deliveryMapping.link.setWaitingClosePO(null);
                }
            }
            current++;
            outgoingWindow++;
        }
        if (deliveryState != null) {
            if (!settled && deliveryState instanceof Accepted) {
                DispositionFrame dispoFrame = new DispositionFrame(mySession.getChannel());
                dispoFrame.setRole(Role.SENDER);
                dispoFrame.setFirst(new DeliveryNumber(from));
                dispoFrame.setLast(new DeliveryNumber(to));
                dispoFrame.setSettled(AMQPBoolean.TRUE);
                dispoFrame.setState(new Accepted());
                outboundHandler.send(dispoFrame);
            }
        }
    } else {
    // TODO: error
    }
}
Also used : Accepted(com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted)

Aggregations

IOException (java.io.IOException)9 Error (com.swiftmq.amqp.v100.generated.transport.definitions.Error)8 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Semaphore (com.swiftmq.tools.concurrent.Semaphore)3 StreamException (com.rabbitmq.stream.StreamException)2 POCloseLink (com.swiftmq.amqp.v100.client.po.POCloseLink)2 AmqpValue (com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)2 com.swiftmq.amqp.v100.generated.transport.definitions (com.swiftmq.amqp.v100.generated.transport.definitions)2 ConnectionError (com.swiftmq.amqp.v100.generated.transport.definitions.ConnectionError)2 com.rabbitmq.stream.amqp (com.rabbitmq.stream.amqp)1 POSendMessage (com.swiftmq.amqp.v100.client.po.POSendMessage)1 Accepted (com.swiftmq.amqp.v100.generated.messaging.delivery_state.Accepted)1 DeliveryStateIF (com.swiftmq.amqp.v100.generated.messaging.delivery_state.DeliveryStateIF)1 Rejected (com.swiftmq.amqp.v100.generated.messaging.delivery_state.Rejected)1 com.swiftmq.amqp.v100.generated.messaging.message_format (com.swiftmq.amqp.v100.generated.messaging.message_format)1 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)1 Header (com.swiftmq.amqp.v100.generated.messaging.message_format.Header)1 MessageIdString (com.swiftmq.amqp.v100.generated.messaging.message_format.MessageIdString)1