forked from apache/rocketmq
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE apache#4384] Expand RocketMQ Topic/Group attributes
- Loading branch information
Showing
10 changed files
with
465 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
common/src/main/java/org/apache/rocketmq/common/attribute/TopicMessageType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.rocketmq.common.attribute; | ||
|
||
import com.google.common.collect.Sets; | ||
import java.util.Set; | ||
|
||
public enum TopicMessageType { | ||
UNSPECIFIED("UNSPECIFIED"), | ||
NORMAL("NORMAL"), | ||
FIFO("FIFO"), | ||
DELAY("DELAY"), | ||
TRANSACTION("TRANSACTION"); | ||
|
||
private final String value; | ||
TopicMessageType(String value) { | ||
this.value = value; | ||
} | ||
|
||
public static Set<String> topicMessageTypeSet() { | ||
return Sets.newHashSet(UNSPECIFIED.value, NORMAL.value, FIFO.value, DELAY.value, TRANSACTION.value); | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
common/src/main/java/org/apache/rocketmq/common/subscription/CustomizedRetryPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.rocketmq.common.subscription; | ||
|
||
import java.util.Arrays; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class CustomizedRetryPolicy { | ||
// 1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h | ||
private long[] next = new long[]{ | ||
TimeUnit.SECONDS.toMillis(1), | ||
TimeUnit.SECONDS.toMillis(5), | ||
TimeUnit.SECONDS.toMillis(10), | ||
TimeUnit.SECONDS.toMillis(30), | ||
TimeUnit.MINUTES.toMillis(1), | ||
TimeUnit.MINUTES.toMillis(2), | ||
TimeUnit.MINUTES.toMillis(3), | ||
TimeUnit.MINUTES.toMillis(4), | ||
TimeUnit.MINUTES.toMillis(5), | ||
TimeUnit.MINUTES.toMillis(6), | ||
TimeUnit.MINUTES.toMillis(7), | ||
TimeUnit.MINUTES.toMillis(8), | ||
TimeUnit.MINUTES.toMillis(9), | ||
TimeUnit.MINUTES.toMillis(10), | ||
TimeUnit.MINUTES.toMillis(20), | ||
TimeUnit.MINUTES.toMillis(30), | ||
TimeUnit.HOURS.toMillis(1), | ||
TimeUnit.HOURS.toMillis(2) | ||
}; | ||
|
||
public long[] getNext() { | ||
return next; | ||
} | ||
|
||
public void setNext(long[] next) { | ||
this.next = next; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CustomizedRetryPolicy{" + | ||
"next=" + Arrays.toString(next) + | ||
'}'; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
common/src/main/java/org/apache/rocketmq/common/subscription/ExponentialRetryPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.rocketmq.common.subscription; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* next delay time = min(max, initial * multiplier^reconsumeTimes) | ||
*/ | ||
public class ExponentialRetryPolicy { | ||
private long initial = TimeUnit.SECONDS.toMillis(5); | ||
private long max = TimeUnit.HOURS.toMillis(2); | ||
private long multiplier = 2; | ||
|
||
public long getInitial() { | ||
return initial; | ||
} | ||
|
||
public void setInitial(long initial) { | ||
this.initial = initial; | ||
} | ||
|
||
public long getMax() { | ||
return max; | ||
} | ||
|
||
public void setMax(long max) { | ||
this.max = max; | ||
} | ||
|
||
public long getMultiplier() { | ||
return multiplier; | ||
} | ||
|
||
public void setMultiplier(long multiplier) { | ||
this.multiplier = multiplier; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ExponentialRetryPolicy{" + | ||
"initial=" + initial + | ||
", max=" + max + | ||
", multiplier=" + multiplier + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.