Skip to content

Commit 47a4876

Browse files
committed
Merge #2114 mannually from master, enable configuration of Consumer thread pool.
1 parent 0f36a05 commit 47a4876

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ConsumerConfig.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public class ConsumerConfig extends AbstractReferenceConfig {
3131
// networking framework client uses: netty, mina, etc.
3232
private String client;
3333

34+
// consumer thread pool type: cached, fixed, limit, eager
35+
private String threadpool;
36+
37+
// consumer threadpool core thread size
38+
private Integer corethreads;
39+
40+
// consumer threadpool thread size
41+
private Integer threads;
42+
43+
// consumer threadpool queue size
44+
private Integer queues;
45+
3446
@Override
3547
public void setTimeout(Integer timeout) {
3648
super.setTimeout(timeout);
@@ -56,4 +68,40 @@ public String getClient() {
5668
public void setClient(String client) {
5769
this.client = client;
5870
}
71+
72+
public String getThreadpool() {
73+
return threadpool;
74+
}
75+
76+
public void setThreadpool(String threadpool) {
77+
this.threadpool = threadpool;
78+
}
79+
80+
public Boolean getDefault() {
81+
return isDefault;
82+
}
83+
84+
public Integer getCorethreads() {
85+
return corethreads;
86+
}
87+
88+
public void setCorethreads(Integer corethreads) {
89+
this.corethreads = corethreads;
90+
}
91+
92+
public Integer getThreads() {
93+
return threads;
94+
}
95+
96+
public void setThreads(Integer threads) {
97+
this.threads = threads;
98+
}
99+
100+
public Integer getQueues() {
101+
return queues;
102+
}
103+
104+
public void setQueues(Integer queues) {
105+
this.queues = queues;
106+
}
59107
}

dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ConsumerConfigTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,32 @@ public void testClient() throws Exception {
5050
consumer.setClient("client");
5151
assertThat(consumer.getClient(), equalTo("client"));
5252
}
53+
54+
@Test
55+
public void testThreadpool() throws Exception {
56+
ConsumerConfig consumer = new ConsumerConfig();
57+
consumer.setThreadpool("fixed");
58+
assertThat(consumer.getThreadpool(), equalTo("fixed"));
59+
}
60+
61+
@Test
62+
public void testCorethreads() throws Exception {
63+
ConsumerConfig consumer = new ConsumerConfig();
64+
consumer.setCorethreads(10);
65+
assertThat(consumer.getCorethreads(), equalTo(10));
66+
}
67+
68+
@Test
69+
public void testThreads() throws Exception {
70+
ConsumerConfig consumer = new ConsumerConfig();
71+
consumer.setThreads(20);
72+
assertThat(consumer.getThreads(), equalTo(20));
73+
}
74+
75+
@Test
76+
public void testQueues() throws Exception {
77+
ConsumerConfig consumer = new ConsumerConfig();
78+
consumer.setQueues(5);
79+
assertThat(consumer.getQueues(), equalTo(5));
80+
}
5381
}

0 commit comments

Comments
 (0)