Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mqtt Cluster
Commits
e2bf158a
Commit
e2bf158a
authored
3 years ago
by
luxurong
Browse files
Options
Download
Email Patches
Plain Diff
ack
parent
405881b2
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smqtt-common/src/main/java/io/github/quickmsg/common/ack/AbsAck.java
+4
-5
...n/src/main/java/io/github/quickmsg/common/ack/AbsAck.java
smqtt-common/src/main/java/io/github/quickmsg/common/ack/RetryAck.java
+1
-3
...src/main/java/io/github/quickmsg/common/ack/RetryAck.java
smqtt-common/src/main/java/io/github/quickmsg/common/channel/MqttChannel.java
+6
-13
...n/java/io/github/quickmsg/common/channel/MqttChannel.java
with
11 additions
and
21 deletions
+11
-21
smqtt-common/src/main/java/io/github/quickmsg/common/ack/AbsAck.java
+
4
-
5
View file @
e2bf158a
...
@@ -25,16 +25,16 @@ public abstract class AbsAck implements Ack {
...
@@ -25,16 +25,16 @@ public abstract class AbsAck implements Ack {
private
final
int
period
;
private
final
int
period
;
private
final
Consumer
<
Boolean
>
consum
er
;
private
final
Runnable
clean
er
;
protected
AbsAck
(
int
maxRetrySize
,
int
period
,
Runnable
runnable
,
AckManager
ackManager
,
Consumer
<
Boolean
>
consum
er
)
{
protected
AbsAck
(
int
maxRetrySize
,
int
period
,
Runnable
runnable
,
AckManager
ackManager
,
Runnable
clean
er
)
{
this
.
maxRetrySize
=
maxRetrySize
;
this
.
maxRetrySize
=
maxRetrySize
;
this
.
period
=
period
;
this
.
period
=
period
;
this
.
runnable
=
runnable
;
this
.
runnable
=
runnable
;
this
.
ackManager
=
ackManager
;
this
.
ackManager
=
ackManager
;
this
.
c
onsumer
=
consum
er
;
this
.
c
leaner
=
clean
er
;
}
}
@Override
@Override
...
@@ -42,7 +42,6 @@ public abstract class AbsAck implements Ack {
...
@@ -42,7 +42,6 @@ public abstract class AbsAck implements Ack {
if
(++
count
<=
maxRetrySize
+
1
&&
!
died
)
{
if
(++
count
<=
maxRetrySize
+
1
&&
!
died
)
{
try
{
try
{
log
.
info
(
"task retry send ..........."
);
log
.
info
(
"task retry send ..........."
);
consumer
.
accept
(
false
);
runnable
.
run
();
runnable
.
run
();
ackManager
.
addAck
(
this
);
ackManager
.
addAck
(
this
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -51,7 +50,7 @@ public abstract class AbsAck implements Ack {
...
@@ -51,7 +50,7 @@ public abstract class AbsAck implements Ack {
}
}
else
{
else
{
c
onsumer
.
accept
(
true
);
c
leaner
.
run
(
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
smqtt-common/src/main/java/io/github/quickmsg/common/ack/RetryAck.java
+
1
-
3
View file @
e2bf158a
package
io.github.quickmsg.common.ack
;
package
io.github.quickmsg.common.ack
;
import
java.util.function.Consumer
;
/**
/**
* @author luxurong
* @author luxurong
*/
*/
...
@@ -11,7 +9,7 @@ public class RetryAck extends AbsAck {
...
@@ -11,7 +9,7 @@ public class RetryAck extends AbsAck {
private
final
long
id
;
private
final
long
id
;
public
RetryAck
(
long
id
,
int
maxRetrySize
,
int
period
,
Runnable
runnable
,
AckManager
ackManager
,
Consumer
<
Boolean
>
consumer
)
{
public
RetryAck
(
long
id
,
int
maxRetrySize
,
int
period
,
Runnable
runnable
,
AckManager
ackManager
,
Runnable
consumer
)
{
super
(
maxRetrySize
,
period
,
runnable
,
ackManager
,
consumer
);
super
(
maxRetrySize
,
period
,
runnable
,
ackManager
,
consumer
);
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
...
This diff is collapsed.
Click to expand it.
smqtt-common/src/main/java/io/github/quickmsg/common/channel/MqttChannel.java
+
6
-
13
View file @
e2bf158a
...
@@ -271,18 +271,12 @@ public class MqttChannel {
...
@@ -271,18 +271,12 @@ public class MqttChannel {
Increase the reference count of bytebuf, and the reference count of retrybytebuf is 2
Increase the reference count of bytebuf, and the reference count of retrybytebuf is 2
mqttChannel.write() method releases a reference count.
mqttChannel.write() method releases a reference count.
*/
*/
Runnable
runnable
=
()
->
mqttChannel
.
write
(
Mono
.
just
(
mqttMessage
)).
subscribe
();
MqttMessage
reply
=
getReplyMqttMessage
(
mqttMessage
);
Consumer
<
Boolean
>
consumer
=
bool
->
{
if
(
bool
)
{
Runnable
runnable
=
()
->
mqttChannel
.
write
(
Mono
.
just
(
reply
)).
subscribe
();
MessageUtils
.
safeRelease
(
mqttMessage
);
Runnable
cleaner
=
()
->
MessageUtils
.
safeRelease
(
reply
);;
}
else
{
Ack
ack
=
new
RetryAck
(
mqttChannel
.
generateId
(
reply
.
fixedHeader
().
messageType
(),
getMessageId
(
reply
)),
if
(
mqttMessage
instanceof
MqttPublishMessage
)
{
5
,
5
,
runnable
,
mqttChannel
.
getTimeAckManager
(),
cleaner
);
((
MqttPublishMessage
)
mqttMessage
).
retain
();
}
}
};
Ack
ack
=
new
RetryAck
(
mqttChannel
.
generateId
(
mqttMessage
.
fixedHeader
().
messageType
(),
getMessageId
(
mqttMessage
)),
5
,
5
,
runnable
,
mqttChannel
.
getTimeAckManager
(),
consumer
);
ack
.
start
();
ack
.
start
();
return
mqttChannel
.
write
(
Mono
.
just
(
mqttMessage
)).
then
();
return
mqttChannel
.
write
(
Mono
.
just
(
mqttMessage
)).
then
();
}
else
{
}
else
{
...
@@ -308,7 +302,6 @@ public class MqttChannel {
...
@@ -308,7 +302,6 @@ public class MqttChannel {
}
else
{
}
else
{
return
mqttMessage
;
return
mqttMessage
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help