Refine search
public Topic(String name, QoS qos) { this(new UTF8Buffer(name), qos); }
public String getTopic() { return topic.toString(); }
@Override public boolean equals(Object o) { if (o == null) return false; if (o.getClass() != this.getClass()) return false; if (this == o) return true; Topic topic = (Topic) o; if (name != null ? !name.equals(topic.name) : topic.name != null) return false; if (qos != topic.qos) return false; return true; }
result.topicName(new UTF8Buffer(topicName)); String messageText = msg.getText(); if (messageText != null) { result.payload(new Buffer(messageText.getBytes("UTF-8"))); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data); result.payload(new Buffer(data)); } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) { ActiveMQMapMessage msg = (ActiveMQMapMessage) message.copy(); Map<String, Object> map = msg.getContentMap(); if (map != null) { result.payload(new Buffer(map.toString().getBytes("UTF-8"))); result.messageId(), clientId, connectionInfo.getConnectionId(), message.getMessageId()); return result;
void onMQTTPublish(PUBLISH command) throws IOException, JMSException { checkConnected(); LOG.trace("MQTT Rcv PUBLISH message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); //Both version 3.1 and 3.1.1 do not allow the topic name to contain a wildcard in the publish packet if (containsMqttWildcard(command.topicName().toString())) { // [MQTT-3.3.2-2]: The Topic Name in the PUBLISH Packet MUST NOT contain wildcard characters getMQTTTransport().onException(IOExceptionSupport.create("The topic name must not contain wildcard characters.", null)); return; } ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, createResponseHandler(command)); }
@Override public void processSaslStep(Sasl sasl) { byte[] data = new byte[sasl.pending()]; sasl.recv(data, 0, data.length); Buffer[] parts = new Buffer(data).split((byte) 0); switch (parts.length) { case 0: // Treat this as anonymous connect to support legacy behavior // which allowed this. Connection will fail if broker is not // configured to allow anonymous connections. break; case 2: username = parts[0].utf8().toString(); password = parts[1].utf8().toString(); break; case 3: username = parts[1].utf8().toString(); password = parts[2].utf8().toString(); break; default: setFailed("Invalid encoding of Authentication credentials"); break; } }
main.retain = true; } else if ("-t".equals(arg)) { main.topic = new UTF8Buffer(shift(argl)); } else if ("-m".equals(arg)) { main.body = new UTF8Buffer(shift(argl)+"\n"); } else if ("-z".equals(arg)) { main.body = new UTF8Buffer(""); } else if ("-f".equals(arg)) { File file = new File(shift(argl)); raf.seek(0); raf.readFully(data); main.body = new Buffer(data); } finally { raf.close();
public void onPublish(UTF8Buffer topic, Buffer payload, Runnable ack) { LOG.debug("Received message: topic={}, payload={}", topic.toString(), new String(payload.toByteArray())); try { this.incoming.put(new AckableMessage(topic.toString(), payload.toByteArray(), ack)); } catch (InterruptedException e) { LOG.warn("Interrupted while queueing an MQTT message."); } }
private MethodData getMethodData(Buffer data) throws IOException, NoSuchMethodException, ClassNotFoundException { MethodData rc = method_cache.get(data); if( rc == null ) { String[] parts = data.utf8().toString().split(","); String name = parts[0]; Class params[] = new Class[parts.length-1]; for( int i=0; i < params.length; i++) { params[i] = decodeClass(parts[i+1]); } Method method = clazz.getMethod(name, params); Serialization annotation = method.getAnnotation(Serialization.class); SerializationStrategy serializationStrategy; if( annotation!=null ) { serializationStrategy = serializationStrategies.get(annotation.value()); if( serializationStrategy==null ) { throw new RuntimeException("Could not find the serialization strategy named: "+annotation.value()); } } else { serializationStrategy = ObjectSerializationStrategy.INSTANCE; } final InvocationStrategy invocationStrategy = InvocationType.forMethod(method); rc = new MethodData(invocationStrategy, serializationStrategy, method); method_cache.put(data, rc); } return rc; }
@SuppressWarnings("deprecation") protected UTF8Buffer tightUnmarshalString(DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { boolean ascii = bs.readBoolean(); // ignored for now. int size = dataIn.readShort(); if( size== 0 ) { return new UTF8Buffer(""); } else { Buffer buffer = dataIn.readBuffer(size); return buffer.utf8(); } } else { return null; } }
public void writeExternal(java.io.DataOutput out) throws java.io.IOException { if( bean.f_name!=null ) { out.writeInt(bean.f_name.getLength()); out.write(bean.f_name.getData(), bean.f_name.getOffset(), bean.f_name.getLength()); } else { out.writeInt(-1); } out.writeInt(bean.f_qos); if( bean.f_address!=null ) { out.writeInt(bean.f_address.getLength()); out.write(bean.f_address.getData(), bean.f_address.getOffset(), bean.f_address.getLength()); } else { out.writeInt(-1); } }
@Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + (qos != null ? qos.hashCode() : 0); return result; }
@Override public PrimitiveTypeEncoding<UTF8Buffer> getEncoding(UTF8Buffer value) { return value.getLength() <= 255 ? smallBufferEncoding : largeBufferEncoding; }
result.topicName(new UTF8Buffer(topicName)); String messageText = msg.getText(); if (messageText != null) { result.payload(new Buffer(messageText.getBytes("UTF-8"))); byte[] data = new byte[(int) msg.getBodyLength()]; msg.readBytes(data); result.payload(new Buffer(data)); } else if (message.getDataStructureType() == ActiveMQMapMessage.DATA_STRUCTURE_TYPE) { ActiveMQMapMessage msg = (ActiveMQMapMessage) message.copy(); Map<String, Object> map = msg.getContentMap(); if (map != null) { result.payload(new Buffer(map.toString().getBytes("UTF-8"))); result.messageId(), clientId, connectionInfo.getConnectionId(), message.getMessageId()); return result;
void onMQTTPublish(PUBLISH command) throws IOException, JMSException { checkConnected(); LOG.trace("MQTT Rcv PUBLISH message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); //Both version 3.1 and 3.1.1 do not allow the topic name to contain a wildcard in the publish packet if (containsMqttWildcard(command.topicName().toString())) { // [MQTT-3.3.2-2]: The Topic Name in the PUBLISH Packet MUST NOT contain wildcard characters getMQTTTransport().onException(IOExceptionSupport.create("The topic name must not contain wildcard characters.", null)); return; } ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, createResponseHandler(command)); }
@Override public void processSaslStep(Sasl sasl) { byte[] data = new byte[sasl.pending()]; sasl.recv(data, 0, data.length); Buffer[] parts = new Buffer(data).split((byte) 0); switch (parts.length) { case 0: // Treat this as anonymous connect to support legacy behavior // which allowed this. Connection will fail if broker is not // configured to allow anonymous connections. break; case 2: username = parts[0].utf8().toString(); password = parts[1].utf8().toString(); break; case 3: username = parts[1].utf8().toString(); password = parts[2].utf8().toString(); break; default: setFailed("Invalid encoding of Authentication credentials"); break; } }
@SuppressWarnings("deprecation") protected UTF8Buffer tightUnmarshalString(DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { boolean ascii = bs.readBoolean(); // ignored for now. int size = dataIn.readShort(); if( size== 0 ) { return new UTF8Buffer(""); } else { Buffer buffer = dataIn.readBuffer(size); return buffer.utf8(); } } else { return null; } }