Package org.fusesource.mqtt.client

Examples of org.fusesource.mqtt.client.QoS


    public PUBLISH convertMessage(ActiveMQMessage message) throws IOException, JMSException, DataFormatException {
        PUBLISH result = new PUBLISH();
        short id = (short) message.getMessageId().getProducerSequenceId();
        result.messageId(id);
        QoS qoS;
        if (message.propertyExists(QOS_PROPERTY_NAME)) {
            int ordinal = message.getIntProperty(QOS_PROPERTY_NAME);
            qoS = QoS.values()[ordinal];

        } else {
View Full Code Here


        }
        return publish;
    }

    public boolean expectAck(PUBLISH publish) {
        QoS publishQoS = publish.qos();
        if (publishQoS.compareTo(this.qos) > 0){
            publishQoS = this.qos;
        }
        return !publishQoS.equals(QoS.AT_MOST_ONCE);
    }
View Full Code Here

        byte[] body = exchange.getIn().getBody(byte[].class);
        if (body != null) {
            MQTTConfiguration configuration = mqttEndpoint.getConfiguration();
            boolean retain = exchange.getProperty(configuration.getMqttRetainPropertyName(), configuration.isByDefaultRetain(), Boolean.class);

            QoS qoS = configuration.getQoS();
            Object qoSValue = exchange.getProperty(configuration.getMqttQosPropertyName());
            if (qoSValue != null) {
                qoS = MQTTConfiguration.getQoS(qoSValue.toString());
            }
View Full Code Here

        header(frame.header());

        DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]);
        topicName = MessageSupport.readUTF(is);
       
        QoS qos = qos();
        if(qos != QoS.AT_MOST_ONCE) {
            messageId = is.readShort();
        }
        payload = is.readBuffer(is.available());
        if( payload == null ) {
View Full Code Here

   
    public MQTTFrame encode() {
        try {
            DataByteArrayOutputStream variableHeader = new DataByteArrayOutputStream();
            MessageSupport.writeUTF(variableHeader, topicName);
            QoS qos = qos();
            if(qos != QoS.AT_MOST_ONCE) {
                variableHeader.writeShort(messageId);
            }
            MQTTFrame frame = new MQTTFrame();
            frame.header(header());
View Full Code Here

    public PUBLISH convertMessage(ActiveMQMessage message) throws IOException, JMSException, DataFormatException {
        PUBLISH result = new PUBLISH();
        short id = (short) message.getMessageId().getProducerSequenceId();
        result.messageId(id);
        QoS qoS;
        if (message.propertyExists(QOS_PROPERTY_NAME)) {
            int ordinal = message.getIntProperty(QOS_PROPERTY_NAME);
            qoS = QoS.values()[ordinal];

        } else {
View Full Code Here

    }

    public PUBLISH convertMessage(ActiveMQMessage message) throws IOException, JMSException, DataFormatException {
        PUBLISH result = new PUBLISH();
        // packet id is set in MQTTSubscription
        QoS qoS;
        if (message.propertyExists(QOS_PROPERTY_NAME)) {
            int ordinal = message.getIntProperty(QOS_PROPERTY_NAME);
            qoS = QoS.values()[ordinal];

        } else {
View Full Code Here

     *        The publish command to inspect.
     *
     * @return true if the client will expect an PUBACK for this PUBLISH.
     */
    public boolean expectAck(PUBLISH publish) {
        QoS publishQoS = publish.qos();
        if (publishQoS.compareTo(this.qos) > 0){
            publishQoS = this.qos;
        }
        return !publishQoS.equals(QoS.AT_MOST_ONCE);
    }
View Full Code Here

                StringTokenizer tokenizer = new StringTokenizer(name);
                tokenizer.nextToken(":.");
                String qosString = tokenizer.nextToken();
                tokenizer.nextToken();
                String topicName = convertActiveMQToMQTT(tokenizer.nextToken("").substring(1));
                QoS qoS = QoS.valueOf(qosString);
                LOG.trace("Restoring subscription: {}:{}", topicName, qoS);

                ConsumerInfo consumerInfo = new ConsumerInfo(getNextConsumerId());
                consumerInfo.setDestination(queue);
                consumerInfo.setPrefetchSize(protocol.getActiveMQSubscriptionPrefetch());
View Full Code Here

    @Override
    public byte onSubscribe(final Topic topic) throws MQTTProtocolException {

        final String destinationName = topic.name().toString();
        final QoS requestedQoS = topic.qos();

        final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(destinationName);
        if (mqttSubscription != null) {
            if (requestedQoS != mqttSubscription.getQoS()) {
                // remove old subscription as the QoS has changed
                onUnSubscribe(destinationName);
            } else {
                try {
                    onReSubscribe(mqttSubscription);
                } catch (IOException e) {
                    throw new MQTTProtocolException("Failed to find subscription strategy", true, e);
                }
                return (byte) requestedQoS.ordinal();
            }
        }

        try {
            return onSubscribe(destinationName, requestedQoS);
View Full Code Here

TOP

Related Classes of org.fusesource.mqtt.client.QoS

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.