Package org.fusesource.hawtbuf

Examples of org.fusesource.hawtbuf.UTF8Buffer


                HashMap<String, Object> jsonMap = new HashMap<String, Object>();
                jsonMap.put("@class", "queue_destination");
                jsonMap.put("name", dest.getQueueName());
                String json = mapper.writeValueAsString(jsonMap);
                System.out.println(json);
                destRecord.setBindingData(new UTF8Buffer(json));
                manager.store_queue(destRecord);

                queue.recover(new MessageRecoveryListener() {
                    @Override
                    public boolean hasSpace() {
                        return true;
                    }

                    @Override
                    public boolean recoverMessageReference(MessageId ref) throws Exception {
                        return true;
                    }

                    @Override
                    public boolean isDuplicate(MessageId ref) {
                        return false;
                    }

                    @Override
                    public boolean recoverMessage(Message message) throws IOException {
                        messageKeyCounter[0]++;
                        seqKeyCounter[0]++;

                        MessagePB.Bean messageRecord = createMessagePB(message, messageKeyCounter[0]);
                        manager.store_message(messageRecord);

                        QueueEntryPB.Bean entryRecord = createQueueEntryPB(message, containerKeyCounter[0], seqKeyCounter[0], messageKeyCounter[0]);
                        manager.store_queue_entry(entryRecord);

                        return true;
                    }
                });

            } else if (odest instanceof ActiveMQTopic) {
                ActiveMQTopic dest = (ActiveMQTopic) odest;

                TopicMessageStore topic = store.createTopicMessageStore(dest);
                for (SubscriptionInfo sub : topic.getAllSubscriptions()) {

                    QueuePB.Bean destRecord = new QueuePB.Bean();
                    destRecord.setKey(containerKeyCounter[0]);
                    destRecord.setBindingKind(ds_kind);

                    // TODO: use a real JSON encoder like jackson.
                    HashMap<String, Object> jsonMap = new HashMap<String, Object>();
                    jsonMap.put("@class", "dsub_destination");
                    jsonMap.put("name", sub.getClientId() + ":" + sub.getSubscriptionName());
                    HashMap<String, Object> jsonTopic = new HashMap<String, Object>();
                    jsonTopic.put("name", dest.getTopicName());
                    jsonMap.put("topics", new Object[]{jsonTopic});
                    if (sub.getSelector() != null) {
                        jsonMap.put("selector", sub.getSelector());
                    }
                    String json = mapper.writeValueAsString(jsonMap);
                    System.out.println(json);

                    destRecord.setBindingData(new UTF8Buffer(json));
                    manager.store_queue(destRecord);

                    final long seqKeyCounter[] = new long[]{0};
                    topic.recoverSubscription(sub.getClientId(), sub.getSubscriptionName(), new MessageRecoveryListener() {
                        @Override
View Full Code Here


    }

    byte onSubscribe(final Topic topic) throws MQTTProtocolException {

        final UTF8Buffer topicName = topic.name();
        final QoS topicQoS = topic.qos();
        ActiveMQDestination destination = new ActiveMQTopic(convertMQTTToActiveMQ(topicName.toString()));

        if( mqttSubscriptionByTopic.containsKey(topicName)) {
            final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(topicName);
            if (topicQoS != mqttSubscription.qos()) {
                // remove old subscription as the QoS has changed
                onUnSubscribe(topicName);
            } else {
                // duplicate SUBSCRIBE packet, find all matching topics and resend retained messages
                resendRetainedMessages(topicName, destination, mqttSubscription);

                return (byte) topicQoS.ordinal();
            }
            onUnSubscribe(topicName);
        }

        ConsumerId id = new ConsumerId(sessionId, consumerIdGenerator.getNextSequenceId());
        ConsumerInfo consumerInfo = new ConsumerInfo(id);
        consumerInfo.setDestination(destination);
        consumerInfo.setPrefetchSize(getActiveMQSubscriptionPrefetch());
        consumerInfo.setRetroactive(true);
        consumerInfo.setDispatchAsync(true);
        // create durable subscriptions only when cleansession is false
        if ( !connect.cleanSession() && connect.clientId() != null && topicQoS.ordinal() >= QoS.AT_LEAST_ONCE.ordinal() ) {
            consumerInfo.setSubscriptionName(topicQoS + ":" + topicName.toString());
        }
        MQTTSubscription mqttSubscription = new MQTTSubscription(this, topicQoS, consumerInfo);

        // optimistic add to local maps first to be able to handle commands in onActiveMQCommand
        subscriptionsByConsumerId.put(id, mqttSubscription);
View Full Code Here

        result.qos(qoS);
        if (message.getBooleanProperty(RetainedMessageSubscriptionRecoveryPolicy.RETAINED_PROPERTY)) {
            result.retain(true);
        }

        UTF8Buffer topicName;
        synchronized (mqttTopicMap) {
            topicName = mqttTopicMap.get(message.getJMSDestination());
            if (topicName == null) {
                topicName = new UTF8Buffer(convertActiveMQToMQTT(message.getDestination().getPhysicalName()));
                mqttTopicMap.put(message.getJMSDestination(), topicName);
            }
        }
        result.topicName(topicName);
View Full Code Here

public class UTF8BufferCodec extends AbstractBufferCodec<UTF8Buffer> {
    public static final UTF8BufferCodec INSTANCE = new UTF8BufferCodec();

    @Override
    protected UTF8Buffer createBuffer(byte[] data) {
        return new UTF8Buffer(data);
    }
View Full Code Here

    }

    public static UTF8Buffer readUTF(DataInputStream in, int length) throws IOException {
        byte data[] = new byte[length];
        in.readFully(data);
        return new UTF8Buffer(data);
    }
View Full Code Here

    public void setTightEncodingEnabled(boolean tightEncodingEnabled) throws IOException {
        setProperty("TightEncodingEnabled", tightEncodingEnabled ? Boolean.TRUE : Boolean.FALSE);
    }

    public String getHost() throws IOException {
        UTF8Buffer buff = (UTF8Buffer) getProperty("Host");
        if( buff == null ) {
            return null;
        }
        return (String) buff.toString();
    }
View Full Code Here

                                parameters.protocolVirtualHost = parts[0];
                                parameters.protocolUser = parts[1];

                                // Update the connect frame to strip out the virtual host from the username field...
                                connect.userName(new UTF8Buffer(parameters.protocolUser));

                                // re-write the received buffer /w  the updated connect frame
                                Buffer tail = received.getBuffer((int) h.getBytesDecoded(), received.length());
                                BufferSupport.setLength(received, 0);
                                append(received, connect.encode());
View Full Code Here

  public ActiveMQDestination() {
  }

  protected ActiveMQDestination(String name) {
      setPhysicalName(new UTF8Buffer(name));
  }
View Full Code Here

        return url;
    }

    public void setURL(URL url) {
        this.url = url;
        remoteBlobUrl = url != null ? new UTF8Buffer(url.toExternalForm()) : null;
    }
View Full Code Here

                if( i!=0 ) {
                    sb.append(",");
                }
                sb.append(encodeClassName(types[i]));
            }
            Buffer signature = new UTF8Buffer(sb.toString()).buffer();

            Serialization annotation = method.getAnnotation(Serialization.class);
            SerializationStrategy serializationStrategy;
            if( annotation!=null ) {
                serializationStrategy = serializationStrategies.get(annotation.value());
View Full Code Here

TOP

Related Classes of org.fusesource.hawtbuf.UTF8Buffer

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.