本文整理了Java中org.fusesource.mqtt.client.QoS.ordinal
方法的一些代码示例,展示了QoS.ordinal
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QoS.ordinal
方法的具体详情如下:
包路径:org.fusesource.mqtt.client.QoS
类名称:QoS
方法名:ordinal
暂无
代码示例来源:origin: fusesource/mqtt-client
protected HeaderBase qos(QoS qos) {
this.header &= 0xF9;
this.header |= (qos.ordinal() << 1) & 0x06;
return this;
}
代码示例来源:origin: fusesource/mqtt-client
public CONNECT willQos(QoS willQos) {
this.willQos = (byte) willQos.ordinal();
return this;
}
代码示例来源:origin: fusesource/mqtt-client
public MQTTFrame encode() {
try {
DataByteArrayOutputStream os = new DataByteArrayOutputStream();
QoS qos = qos();
if(qos != QoS.AT_MOST_ONCE) {
os.writeShort(messageId);
}
for(Topic topic: topics) {
MessageSupport.writeUTF(os, topic.name());
os.writeByte(topic.qos().ordinal());
}
MQTTFrame frame = new MQTTFrame();
frame.header(header());
frame.commandType(TYPE);
return frame.buffer(os.toBuffer());
} catch (IOException e) {
throw new RuntimeException("The impossible happened");
}
}
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
protected HeaderBase qos(QoS qos) {
this.header &= 0xF9;
this.header |= (qos.ordinal() << 1) & 0x06;
return this;
}
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
public CONNECT willQos(QoS willQos) {
this.willQos = (byte) willQos.ordinal();
return this;
}
代码示例来源:origin: org.apache.activemq/activemq-all
@Override
public void onResponse(MQTTProtocolConverter converter, Response response) throws IOException {
// validate subscription request
if (response.isException()) {
final Throwable throwable = ((ExceptionResponse) response).getException();
LOG.warn("Error subscribing to {}", topicName, throwable);
// version 3.1 don't supports silent fail
// version 3.1.1 send "error" qos
if (protocol.version == MQTTProtocolConverter.V3_1_1) {
qos[0] = SUBSCRIBE_ERROR;
} else {
qos[0] = (byte) qoS.ordinal();
}
} else {
qos[0] = (byte) qoS.ordinal();
}
}
});
代码示例来源:origin: org.apache.activemq/activemq-mqtt
@Override
public void onResponse(MQTTProtocolConverter converter, Response response) throws IOException {
// validate subscription request
if (response.isException()) {
final Throwable throwable = ((ExceptionResponse) response).getException();
LOG.warn("Error subscribing to {}", topicName, throwable);
// version 3.1 don't supports silent fail
// version 3.1.1 send "error" qos
if (protocol.version == MQTTProtocolConverter.V3_1_1) {
qos[0] = SUBSCRIBE_ERROR;
} else {
qos[0] = (byte) qoS.ordinal();
}
} else {
qos[0] = (byte) qoS.ordinal();
}
}
});
代码示例来源:origin: org.apache.activemq/activemq-osgi
@Override
public void onResponse(MQTTProtocolConverter converter, Response response) throws IOException {
// validate subscription request
if (response.isException()) {
final Throwable throwable = ((ExceptionResponse) response).getException();
LOG.warn("Error subscribing to {}", topicName, throwable);
// version 3.1 don't supports silent fail
// version 3.1.1 send "error" qos
if (protocol.version == MQTTProtocolConverter.V3_1_1) {
qos[0] = SUBSCRIBE_ERROR;
} else {
qos[0] = (byte) qoS.ordinal();
}
} else {
qos[0] = (byte) qoS.ordinal();
}
}
});
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
/**
* Creates a PUBLISH command that can be sent to a remote client from an
* incoming {@link ActiveMQMessage} instance.
*
* @param message the message to convert to a PUBLISH command.
* @return a new PUBLISH command that is populated from the {@link ActiveMQMessage}.
* @throws DataFormatException
* @throws IOException
* @throws JMSException
*/
public PUBLISH createPublish(ActiveMQMessage message) throws DataFormatException, IOException, JMSException {
PUBLISH publish = protocolConverter.convertMessage(message);
if (publish.qos().ordinal() > this.qos.ordinal()) {
publish.qos(this.qos);
}
switch (publish.qos()) {
case AT_LEAST_ONCE:
case EXACTLY_ONCE:
// set packet id, and optionally dup flag
MQTTPacketIdGenerator.setPacketId(protocolConverter.getClientId(), this, message, publish);
case AT_MOST_ONCE:
}
return publish;
}
代码示例来源:origin: apache/activemq-artemis
@Override
public void onReceive(MQTTFrame frame) {
// validate the QoS
if (frame.messageType() == PUBLISH.TYPE) {
actualQoS[0] = frame.qos().ordinal();
}
}
});
代码示例来源:origin: apache/activemq-artemis
@Override
public void onReceive(MQTTFrame frame) {
// validate the QoS
if (frame.messageType() == PUBLISH.TYPE) {
actualQoS[0] = frame.qos().ordinal();
}
}
});
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
private 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 {
return (byte) requestedQoS.ordinal();
}
}
try {
return onSubscribe(destinationName, requestedQoS);
} catch (IOException e) {
throw new MQTTProtocolException("Failed while intercepting subscribe", true, e);
}
}
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
private 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 {
return (byte) requestedQoS.ordinal();
}
}
try {
return onSubscribe(destinationName, requestedQoS);
} catch (IOException e) {
throw new MQTTProtocolException("Failed while intercepting subscribe", true, e);
}
}
}
代码示例来源:origin: org.apache.activemq/activemq-mqtt
@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);
} catch (IOException e) {
throw new MQTTProtocolException("Failed while intercepting subscribe", true, e);
}
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
private byte onSubscribe(String topicName, QoS requestedQoS) throws MQTTProtocolException {
ActiveMQDestination destination = new ActiveMQTopic(MQTTProtocolSupport.convertMQTTToActiveMQ(topicName));
ConsumerInfo consumerInfo = new ConsumerInfo(getNextConsumerId());
consumerInfo.setDestination(destination);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH);
consumerInfo.setRetroactive(true);
consumerInfo.setDispatchAsync(true);
// create durable subscriptions only when clean session is false
if (!isCleanSession() && getClientId() != null && requestedQoS.ordinal() >= QoS.AT_LEAST_ONCE.ordinal()) {
consumerInfo.setSubscriptionName(requestedQoS + ":" + topicName);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_DURABLE_TOPIC_PREFETCH);
}
if (getActiveMQSubscriptionPrefetch() > 0) {
consumerInfo.setPrefetchSize(getActiveMQSubscriptionPrefetch());
}
return doSubscribe(consumerInfo, topicName, requestedQoS);
}
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
private byte onSubscribe(String topicName, QoS requestedQoS) throws MQTTProtocolException {
ActiveMQDestination destination = new ActiveMQTopic(MQTTProtocolSupport.convertMQTTToActiveMQ(topicName));
ConsumerInfo consumerInfo = new ConsumerInfo(getNextConsumerId());
consumerInfo.setDestination(destination);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH);
consumerInfo.setRetroactive(true);
consumerInfo.setDispatchAsync(true);
// create durable subscriptions only when clean session is false
if (!isCleanSession() && getClientId() != null && requestedQoS.ordinal() >= QoS.AT_LEAST_ONCE.ordinal()) {
consumerInfo.setSubscriptionName(requestedQoS + ":" + topicName);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_DURABLE_TOPIC_PREFETCH);
}
if (getActiveMQSubscriptionPrefetch() > 0) {
consumerInfo.setPrefetchSize(getActiveMQSubscriptionPrefetch());
}
return doSubscribe(consumerInfo, topicName, requestedQoS);
}
代码示例来源:origin: org.apache.activemq/activemq-mqtt
@Override
public byte onSubscribe(String topicName, QoS requestedQoS) throws MQTTProtocolException {
ActiveMQDestination destination = new ActiveMQTopic(MQTTProtocolSupport.convertMQTTToActiveMQ(topicName));
ConsumerInfo consumerInfo = new ConsumerInfo(getNextConsumerId());
consumerInfo.setDestination(destination);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH);
consumerInfo.setRetroactive(true);
consumerInfo.setDispatchAsync(true);
// create durable subscriptions only when clean session is false
if (!protocol.isCleanSession() && protocol.getClientId() != null && requestedQoS.ordinal() >= QoS.AT_LEAST_ONCE.ordinal()) {
consumerInfo.setSubscriptionName(requestedQoS + ":" + topicName);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_DURABLE_TOPIC_PREFETCH);
}
if (protocol.getActiveMQSubscriptionPrefetch() > 0) {
consumerInfo.setPrefetchSize(protocol.getActiveMQSubscriptionPrefetch());
}
return doSubscribe(consumerInfo, topicName, requestedQoS);
}
代码示例来源:origin: org.apache.activemq/activemq-all
@Override
public byte onSubscribe(String topicName, QoS requestedQoS) throws MQTTProtocolException {
ActiveMQDestination destination = new ActiveMQTopic(MQTTProtocolSupport.convertMQTTToActiveMQ(topicName));
ConsumerInfo consumerInfo = new ConsumerInfo(getNextConsumerId());
consumerInfo.setDestination(destination);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH);
consumerInfo.setRetroactive(true);
consumerInfo.setDispatchAsync(true);
// create durable subscriptions only when clean session is false
if (!protocol.isCleanSession() && protocol.getClientId() != null && requestedQoS.ordinal() >= QoS.AT_LEAST_ONCE.ordinal()) {
consumerInfo.setSubscriptionName(requestedQoS + ":" + topicName);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_DURABLE_TOPIC_PREFETCH);
}
if (protocol.getActiveMQSubscriptionPrefetch() > 0) {
consumerInfo.setPrefetchSize(protocol.getActiveMQSubscriptionPrefetch());
}
return doSubscribe(consumerInfo, topicName, requestedQoS);
}
代码示例来源:origin: org.apache.activemq/activemq-osgi
@Override
public byte onSubscribe(String topicName, QoS requestedQoS) throws MQTTProtocolException {
ActiveMQDestination destination = new ActiveMQTopic(MQTTProtocolSupport.convertMQTTToActiveMQ(topicName));
ConsumerInfo consumerInfo = new ConsumerInfo(getNextConsumerId());
consumerInfo.setDestination(destination);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH);
consumerInfo.setRetroactive(true);
consumerInfo.setDispatchAsync(true);
// create durable subscriptions only when clean session is false
if (!protocol.isCleanSession() && protocol.getClientId() != null && requestedQoS.ordinal() >= QoS.AT_LEAST_ONCE.ordinal()) {
consumerInfo.setSubscriptionName(requestedQoS + ":" + topicName);
consumerInfo.setPrefetchSize(ActiveMQPrefetchPolicy.DEFAULT_DURABLE_TOPIC_PREFETCH);
}
if (protocol.getActiveMQSubscriptionPrefetch() > 0) {
consumerInfo.setPrefetchSize(protocol.getActiveMQSubscriptionPrefetch());
}
return doSubscribe(consumerInfo, topicName, requestedQoS);
}
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
public MQTTFrame encode() {
try {
DataByteArrayOutputStream os = new DataByteArrayOutputStream();
QoS qos = qos();
if(qos != QoS.AT_MOST_ONCE) {
os.writeShort(messageId);
}
for(Topic topic: topics) {
MessageSupport.writeUTF(os, topic.name());
os.writeByte(topic.qos().ordinal());
}
MQTTFrame frame = new MQTTFrame();
frame.header(header());
frame.commandType(TYPE);
return frame.buffer(os.toBuffer());
} catch (IOException e) {
throw new RuntimeException("The impossible happened");
}
}
内容来源于网络,如有侵权,请联系作者删除!