Java Code Examples for io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader#messageId()

The following examples show how to use io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader#messageId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 6 votes vote down vote up
/**
 *  P - B (Qos2)
 * @param channel
 * @param variableHeader
 */
public void processPubRel(Channel channel, MqttMessageIdVariableHeader variableHeader) {
	int messageId = variableHeader.messageId();
	ProcedureMessage info = this.procedureProcess.processPubRel(channel, messageId);

	if (info != null) {
		NettyLog.debug("relInfo:" + info);

		BorkerMessage bMsgInfo = BorkerMessage.builder().sourceClientId(info.getSourceClientId())
				.sourceMsgId(info.getSourceMsgId()).topicName(info.getTopicName()).iQosLevel(info.getIQosLevel())
				.msgBytes(info.getMsgBytes()).retain(false).build();

		List<SubscribeTopicInfo> subscribeClientList = this.topicProcess.search(bMsgInfo.getTopicName());
		this.consumerProcess.sendSubscribMessage(bMsgInfo, subscribeClientList);
	}

	this.sendProcess.sendPubCompMessage(channel, messageId);
}
 
Example 2
Source File: ClientProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * B - P (Qos1)
 * @param channel
 * @param mqttMessage
 */
public void processPubAck(Channel channel, MqttMessage mqttMessage) {
	MqttMessageIdVariableHeader messageIdVariableHeader = (MqttMessageIdVariableHeader) mqttMessage
			.variableHeader();
	int messageId = messageIdVariableHeader.messageId();

	producerProcess.processPubAck(messageId);
	producerProcess.delMessage(messageId);
}
 
Example 3
Source File: ClientProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * B- P(Qos2)
 * @param channel
 * @param mqttMessage
 */
public void processPubRec(Channel channel, MqttMessage mqttMessage) {
	MqttMessageIdVariableHeader messageIdVariableHeader = (MqttMessageIdVariableHeader) mqttMessage
			.variableHeader();
	int messageId = messageIdVariableHeader.messageId();

	producerProcess.processPubRec(messageId);
	producerProcess.sendPubRel(messageId);
}
 
Example 4
Source File: ClientProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * B - P (Qos2)
 * @param channel
 * @param mqttMessage
 */
public void processPubComp(Channel channel, MqttMessage mqttMessage) {
	MqttMessageIdVariableHeader messageIdVariableHeader = (MqttMessageIdVariableHeader) mqttMessage
			.variableHeader();
	int messageId = messageIdVariableHeader.messageId();

	producerProcess.processPubComp(messageId);
	producerProcess.delMessage(messageId);
}
 
Example 5
Source File: ClientProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * B - S(Qos2)
 * @param channel
 * @param mqttMessage
 */
public void processPubRel(Channel channel, MqttMessage mqttMessage) {
	MqttMessageIdVariableHeader messageIdVariableHeader = (MqttMessageIdVariableHeader) mqttMessage
			.variableHeader();
	int messageId = messageIdVariableHeader.messageId();
	this.consumerProcess.processPubRel(messageId);
	this.consumerProcess.sendPubCompMessage(messageId);
	this.consumerProcess.delMesage(messageId);
}
 
Example 6
Source File: ClientProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * B - S
 * @param channel
 * @param mqttMessage
 */
public void processUnSubBack(Channel channel, MqttMessage mqttMessage) {
	int messageId;
	if (mqttMessage instanceof MqttUnsubAckMessage) {
		MqttUnsubAckMessage mqttUnsubAckMessage = (MqttUnsubAckMessage) mqttMessage;
		messageId = mqttUnsubAckMessage.variableHeader().messageId();
	} else {
		MqttMessageIdVariableHeader o = (MqttMessageIdVariableHeader) mqttMessage.variableHeader();
		messageId = o.messageId();
		NettyLog.error("not UnsubAckMessage:{}", messageId);
	}
	this.consumerProcess.processUnSubBack(messageId);
}
 
Example 7
Source File: MqttProtocolHandler.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
public void processPubAck(Channel client, MqttPubAckMessage pubAckMessage) {
    MqttMessageIdVariableHeader pubAckVariableMessage = pubAckMessage.variableHeader();
    short packageId = (short) pubAckVariableMessage.messageId();
    String clientId = NettyAttrManager.getAttrClientId(client);

    consumerManager.acknowledge(clientId, packageId);

    if (LOG.isDebugEnabled()) {
        LOG.debug("Received PubAck packageID: {}" + packageId);
    }
}
 
Example 8
Source File: ProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 4 votes vote down vote up
/**
 *  S - B (Qos2)
 * @param channel
 * @param variableHeader
 */
public void processPubRec(Channel channel, MqttMessageIdVariableHeader variableHeader) {
	int messageId = variableHeader.messageId();
	this.consumerProcess.processPubRec(channel, messageId);
	this.sendProcess.sendPubRelMessage(channel, messageId, false);
}
 
Example 9
Source File: MessageUtil.java    From iot-mqtt with Apache License 2.0 4 votes vote down vote up
public static int getMessageId(MqttMessage mqttMessage){
    MqttMessageIdVariableHeader idVariableHeader = (MqttMessageIdVariableHeader) mqttMessage.variableHeader();
    return idVariableHeader.messageId();
}
 
Example 10
Source File: PubComp.java    From netty-learning-example with Apache License 2.0 4 votes vote down vote up
public void processPubComp(Channel channel, MqttMessageIdVariableHeader variableHeader){
    int messageId = variableHeader.messageId();
    log.info("PUBCOMP - clientId: {}, messageId: {}", (String) channel.attr(AttributeKey.valueOf("clientId")).get(), messageId);
    grozaDupPubRelMessageStoreService.remove((String)channel.attr(AttributeKey.valueOf("clientId")).get(), variableHeader.messageId());
}
 
Example 11
Source File: PubAck.java    From netty-learning-example with Apache License 2.0 4 votes vote down vote up
public void processPubAck(Channel channel, MqttMessageIdVariableHeader variableHeader){
    int messageId = variableHeader.messageId();
    log.info("PUBACK - clientId: {}, messageId: {}", (String) channel.attr(AttributeKey.valueOf("clientId")).get(), messageId);
    grozaDupPublishMessageStoreService.remove((String) channel.attr(AttributeKey.valueOf("clientId")).get(), messageId);

}
 
Example 12
Source File: ProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 2 votes vote down vote up
/**
 *  S - B (Qos1)
 * @param channel
 * @param variableHeader
 */
public void processPubAck(Channel channel, MqttMessageIdVariableHeader variableHeader) {
	int messageId = variableHeader.messageId();
	this.consumerProcess.processPubAck(channel, messageId);
}
 
Example 13
Source File: ProtocolProcess.java    From ext-opensource-netty with Mozilla Public License 2.0 2 votes vote down vote up
/**
 *  S - B (Qos2)
 * @param channel
 * @param variableHeader
 */
public void processPubComp(Channel channel, MqttMessageIdVariableHeader variableHeader) {
	int messageId = variableHeader.messageId();
	this.consumerProcess.processPubComp(channel, messageId);
}