Package org.apache.qpid.proton.amqp

Examples of org.apache.qpid.proton.amqp.DescribedType


      SimpleString selector = null;
      Map filter = source.getFilter();
      if (filter != null)
      {
         DescribedType value = (DescribedType) filter.get(SELECTOR);
         if (value != null)
         {
            selector = new SimpleString(value.getDescribed().toString());
         }
      }

      if (source.getDynamic())
      {
View Full Code Here


      SimpleString selector = null;
      Map filter = source.getFilter();
      if (filter != null)
      {
         DescribedType value = (DescribedType) filter.get(SELECTOR);
         if (value != null)
         {
            selector = new SimpleString(value.getDescribed().toString());
         }
      }

      if (source.getDynamic())
      {
View Full Code Here

            if (o == null || ! (o instanceof DescribedType))
            {
                return false;
            }

            DescribedType that = (DescribedType) o;

            if (_described != null ? !_described.equals(that.getDescribed()) : that.getDescribed() != null)
            {
                return false;
            }
            if (_descriptor != null ? !_descriptor.equals(that.getDescriptor()) : that.getDescriptor() != null)
            {
                return false;
            }

            return true;
View Full Code Here

    @Test
    public void testDescribed() throws IOException
    {
        TestDecoder d = createDecoder(getBytes("described"));
        DescribedType dt = (DescribedType) (d.readObject());
        assertEquals(Symbol.valueOf("foo-descriptor"), dt.getDescriptor());
        assertEquals("foo-value", dt.getDescribed());

        dt = (DescribedType) (d.readObject());
        assertEquals(12, dt.getDescriptor());
        assertEquals(13, dt.getDescribed());
    }
View Full Code Here

    @Test
    public void testDescribedArray() throws IOException
    {
        TestDecoder d = createDecoder(getBytes("described_array"));
        DescribedType a[] = (DescribedType[]) (d.readArray());
        for (int i = 0; i < 10; ++i)
        {
            assertEquals(Symbol.valueOf("int-array"), a[i].getDescriptor());
            assertEquals(i, a[i].getDescribed());
        }
View Full Code Here

            String selector = null;
            if (source != null) {
                Map filter = source.getFilter();
                if (filter != null) {
                    DescribedType value = (DescribedType) filter.get(JMS_SELECTOR);
                    if (value != null) {
                        selector = value.getDescribed().toString();
                        // 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);
                }
            }
View Full Code Here

            String selector = null;
            if (source != null) {
                Map filter = source.getFilter();
                if (filter != null) {
                    DescribedType value = (DescribedType) filter.get(JMS_SELECTOR);
                    if (value != null) {
                        selector = value.getDescribed().toString();
                        // 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);
                }
            }
View Full Code Here

      SimpleString selector = null;
      Map filter = source.getFilter();
      if (filter != null)
      {
         DescribedType value = (DescribedType) filter.get(SELECTOR);
         if (value != null)
         {
            selector = new SimpleString(value.getDescribed().toString());
         }
      }

      if (source.getDynamic())
      {
View Full Code Here

        if (o == null || ! (o instanceof DescribedType))
        {
            return false;
        }

        DescribedType that = (DescribedType) o;

        if (_described != null ? !_described.equals(that.getDescribed()) : that.getDescribed() != null)
        {
            return false;
        }
        if (_descriptor != null ? !_descriptor.equals(that.getDescriptor()) : that.getDescriptor() != null)
        {
            return false;
        }

        return true;
View Full Code Here

    private Object readDescribedType(CharBuffer s)
    {
        expect(s, DESCRIPTOR_CHAR);
        final Object descriptor = readValue(s);
        final Object described = readValue(s);
        return new DescribedType() {

            public Object getDescriptor()
            {
                return descriptor;
            }
View Full Code Here

TOP

Related Classes of org.apache.qpid.proton.amqp.DescribedType

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.