Package org.apache.qpid.client.messaging.address.Link

Examples of org.apache.qpid.client.messaging.address.Link.SubscriptionQueue


    public Link getLink()
    {
        Link link = new Link();
        link.setSubscription(new Subscription());
        link.setSubscriptionQueue(new SubscriptionQueue());
        if (_linkPropAccess != null)
        {
            link.setDurable(getBooleanProperty(_linkPropAccess,DURABLE,false));
            link.setName(_linkPropAccess.getString(NAME));

            String reliability = _linkPropAccess.getString(RELIABILITY);
            if ( reliability != null)
            {
                if (reliability.equalsIgnoreCase("unreliable"))
                {
                    link.setReliability(Reliability.UNRELIABLE);
                }
                else if (reliability.equalsIgnoreCase("at-least-once"))
                {
                    link.setReliability(Reliability.AT_LEAST_ONCE);
                }
                else
                {
                    throw new IllegalArgumentException("The reliability mode '" +
                            reliability + "' is not yet supported");
                }
            }
           
            if (((Map) _address.getOptions().get(LINK)).get(CAPACITY) instanceof Map)
            {
                MapAccessor capacityProps = new MapAccessor((Map) ((Map) _address.getOptions().get(LINK)).get(CAPACITY));

                Integer sourceCapacity = capacityProps.getInt(CAPACITY_SOURCE);
                link.setConsumerCapacity(sourceCapacity == null ? -1 : sourceCapacity);

                Integer targetCapacity = capacityProps.getInt(CAPACITY_TARGET);
                link.setProducerCapacity(targetCapacity == null ? -1 : targetCapacity);
            }
            else
            {
                int cap = _linkPropAccess.getInt(CAPACITY) == null ? -1 : _linkPropAccess.getInt(CAPACITY);
                link.setConsumerCapacity(cap);
                link.setProducerCapacity(cap);
            }
            link.setFilter(_linkPropAccess.getString(FILTER));
            // so far filter type not used
           
            Map linkMap = (Map) _address.getOptions().get(LINK);

            if (linkMap != null)
            {
                Map x_subscribe = null;

                if(linkMap.containsKey(X_SUBSCRIBE))
                {
                    x_subscribe = (Map)((Map) _address.getOptions().get(LINK)).get(X_SUBSCRIBE);
                }
                else if(linkMap.containsKey(X_SUBSCRIBES))
                {
                    // left in for backwards compatibility with old broken constant
                    x_subscribe = (Map)((Map) _address.getOptions().get(LINK)).get(X_SUBSCRIBES);
                }

                if(x_subscribe != null)
                {
                    if (x_subscribe.containsKey(ARGUMENTS))
                    {
                        link.getSubscription().setArgs((Map<String, Object>) x_subscribe.get(ARGUMENTS));
                    }

                    boolean exclusive = x_subscribe.containsKey(EXCLUSIVE) ?
                            Boolean.parseBoolean((String) x_subscribe.get(EXCLUSIVE)) : false;

                    link.getSubscription().setExclusive(exclusive);
                }
            }

            link.setBindings(getBindings(linkMap));
            Map xDeclareMap = getDeclareArgs(linkMap);
            SubscriptionQueue queue = link.getSubscriptionQueue();
            if (!xDeclareMap.isEmpty() && xDeclareMap.containsKey(ARGUMENTS))
            {
                MapAccessor xDeclareMapAccessor = new MapAccessor(xDeclareMap);
                queue.setAutoDelete(getBooleanProperty(xDeclareMapAccessor,AUTO_DELETE,true));
                queue.setExclusive(getBooleanProperty(xDeclareMapAccessor,EXCLUSIVE,true));
                queue.setAlternateExchange(xDeclareMapAccessor.getString(ALT_EXCHANGE));
                queue.setDeclareArgs((Map<String,Object>)xDeclareMap.get(ARGUMENTS));
            }
        }

        return link;
    }
View Full Code Here


        {
            queueName = link.getName() == null ? "TempQueue" + UUID.randomUUID() : link.getName();
            dest.setQueueName(new AMQShortString(queueName));
        }

        SubscriptionQueue queueProps = link.getSubscriptionQueue();
        Map<String,Object> arguments = queueProps.getDeclareArgs();
        if (!arguments.containsKey((AddressHelper.NO_LOCAL)))
        {
            arguments.put(AddressHelper.NO_LOCAL, noLocal);
        }

        if (link.isDurable() && queueName.startsWith("TempQueue"))
        {
            throw new AMQException("You cannot mark a subscription queue as durable without providing a name for the link.");
        }

        getQpidSession().queueDeclare(queueName,
                queueProps.getAlternateExchange(), arguments,
                queueProps.isAutoDelete() ? Option.AUTO_DELETE : Option.NONE,
                link.isDurable() ? Option.DURABLE : Option.NONE,
                queueProps.isExclusive() ? Option.EXCLUSIVE : Option.NONE);

        Map<String,Object> bindingArguments = new HashMap<String, Object>();
        bindingArguments.put(AMQPFilterTypes.JMS_SELECTOR.getValue().toString(), messageSelector == null ? "" : messageSelector);
        getQpidSession().exchangeBind(queueName,
                              dest.getAddressName(),
View Full Code Here

TOP

Related Classes of org.apache.qpid.client.messaging.address.Link.SubscriptionQueue

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.