Package org.apache.qpid.proton.amqp.transport

Examples of org.apache.qpid.proton.amqp.transport.ErrorCondition


                        // Validate the Selector.
                        try {
                            SelectorParser.parse(selector);
                        } catch (InvalidSelectorException e) {
                            sender.setSource(null);
                            sender.setCondition(new ErrorCondition(AmqpError.INVALID_FIELD, e.getMessage()));
                            sender.close();
                            consumerContext.closed = true;
                            return;
                        }
                    }
                }
            }

            ActiveMQDestination dest;
            if (source == null) {

                source = new org.apache.qpid.proton.amqp.messaging.Source();
                source.setAddress("");
                source.setCapabilities(DURABLE_SUBSCRIPTION_ENDED);
                sender.setSource(source);

                // Looks like durable sub removal.
                RemoveSubscriptionInfo rsi = new RemoveSubscriptionInfo();
                rsi.setConnectionId(connectionId);
                rsi.setSubscriptionName(sender.getName());
                rsi.setClientId(connectionInfo.getClientId());

                consumerContext.closed = true;
                sendToActiveMQ(rsi, new ResponseHandler() {
                    @Override
                    public void onResponse(IAmqpProtocolConverter converter, Response response) throws IOException {
                        if (response.isException()) {
                            sender.setSource(null);
                            Throwable exception = ((ExceptionResponse) response).getException();
                            String name = exception.getClass().getName();
                            sender.setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, exception.getMessage()));
                        }
                        sender.open();
                        pumpProtonToSocket();
                    }
                });
                return;
            } else if (contains(source.getCapabilities(), DURABLE_SUBSCRIPTION_ENDED)) {
                consumerContext.closed = true;
                sender.close();
                pumpProtonToSocket();
                return;
            } else if (source.getDynamic()) {
                // lets create a temp dest.
                dest = createTempQueue();
                source = new org.apache.qpid.proton.amqp.messaging.Source();
                source.setAddress(dest.getQualifiedName());
                source.setDynamic(true);
                sender.setSource(source);
            } else {
                dest = createDestination(source);
            }

            subscriptionsByConsumerId.put(id, consumerContext);
            ConsumerInfo consumerInfo = new ConsumerInfo(id);
            consumerContext.info = consumerInfo;
            consumerInfo.setSelector(selector);
            consumerInfo.setNoRangeAcks(true);
            consumerInfo.setDestination(dest);
            consumerInfo.setPrefetchSize(100);
            consumerInfo.setDispatchAsync(true);
            if (source.getDistributionMode() == COPY && dest.isQueue()) {
                consumerInfo.setBrowser(true);
            }
            if (TerminusDurability.UNSETTLED_STATE.equals(source.getDurable()) && dest.isTopic()) {
                consumerInfo.setSubscriptionName(sender.getName());
            }

            Map filter = source.getFilter();
            if (filter != null) {
                DescribedType value = (DescribedType) filter.get(NO_LOCAL);
                if (value != null) {
                    consumerInfo.setNoLocal(true);
                }
            }

            sendToActiveMQ(consumerInfo, new ResponseHandler() {
                @Override
                public void onResponse(IAmqpProtocolConverter converter, Response response) throws IOException {
                    if (response.isException()) {
                        sender.setSource(null);
                        Throwable exception = ((ExceptionResponse) response).getException();
                        Symbol condition = AmqpError.INTERNAL_ERROR;
                        if (exception instanceof InvalidSelectorException) {
                            condition = AmqpError.INVALID_FIELD;
                        }
                        sender.setCondition(new ErrorCondition(condition, exception.getMessage()));
                        subscriptionsByConsumerId.remove(id);
                        sender.close();
                    } else {
                        sessionContext.consumers.put(id, consumerContext);
                        sender.open();
                    }
                    pumpProtonToSocket();
                }
            });
        } catch (AmqpProtocolException e) {
            sender.setSource(null);
            sender.setCondition(new ErrorCondition(Symbol.getSymbol(e.getSymbolicName()), e.getMessage()));
            sender.close();
        }
    }
View Full Code Here


    ErrorCondition createErrorCondition(String name) {
        return createErrorCondition(name, "");
    }

    ErrorCondition createErrorCondition(String name, String description) {
        ErrorCondition condition = new ErrorCondition();
        condition.setCondition(Symbol.valueOf(name));
        condition.setDescription(description);
        return condition;
    }
View Full Code Here

                            // TODO - need an API for detaching rather than closing the link
                            detach.setClosed(true);

                            EndpointError localError = link.getLocalError();
                            if( localError !=null ) {
                                ErrorCondition error = new ErrorCondition();
                                error.setCondition(Symbol.getSymbol(localError.getName()));
                                error.setDescription(localError.getDescription());
                                detach.setError(error);
                            }


                            int frameBytes = writeFrame(buffer, transportSession.getLocalChannel(), detach, null, null);
View Full Code Here

    }

    @Override
    protected List wrap(End val)
    {
        ErrorCondition errorCondition = val.getError();
        return errorCondition == null ? Collections.EMPTY_LIST : Collections.singletonList(errorCondition);
    }
View Full Code Here

    }

    @Override
    protected List wrap(Close val)
    {
        ErrorCondition error = val.getError();
        return error == null ? Collections.EMPTY_LIST : Collections.singletonList(error);
    }
View Full Code Here

                            Detach detach = new Detach();
                            detach.setHandle(localHandle);
                            // TODO - need an API for detaching rather than closing the link
                            detach.setClosed(true);

                            ErrorCondition localError = link.getCondition();
                            if( localError.getCondition() !=null )
                            {
                                detach.setError(localError);
                            }

View Full Code Here

                   && !hasSendableMessages(session)
                   && !_isCloseSent)
                {
                    int channel = freeLocalChannel(transportSession);
                    End end = new End();
                    ErrorCondition localError = endpoint.getCondition();
                    if( localError.getCondition() !=null )
                    {
                        end.setError(localError);
                    }

                    writeFrame(channel, end, null, null);
View Full Code Here

        {
            if(!hasSendableMessages(null))
            {
                Close close = new Close();

                ErrorCondition localError = _connectionEndpoint.getCondition();
                if( localError.getCondition() !=null )
                {
                    close.setError(localError);
                }

                _isCloseSent = true;
View Full Code Here

        {
            _remoteSessions.remove(channel);
            transportSession.receivedEnd();
            SessionImpl session = transportSession.getSession();
            session.setRemoteState(EndpointState.CLOSED);
            ErrorCondition errorCondition = end.getError();
            if(errorCondition != null)
            {
                session.getRemoteCondition().copyFrom(errorCondition);
            }
View Full Code Here

    public ErrorCondition getRemoteError() {
        return getEndpoint().getRemoteCondition();
    }

    static protected ErrorCondition toError(Throwable value) {
        return new ErrorCondition(Symbol.valueOf("error"), value.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.proton.amqp.transport.ErrorCondition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.