Skip to content

Commit ed4384a

Browse files
tswstarplanetchickenlj
authored andcommitted
Merge pull request #2114, enable configuration of Consumer thread pool.
Fixes #2013
1 parent eed3db3 commit ed4384a

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed

dubbo-config/dubbo-config-api/src/main/java/org/apache/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/org/apache/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
}

dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,26 @@
708708
<xsd:documentation><![CDATA[ Transporter layer framework: netty mina.... ]]></xsd:documentation>
709709
</xsd:annotation>
710710
</xsd:attribute>
711+
<xsd:attribute name="threadpool" type="xsd:string" use="optional">
712+
<xsd:annotation>
713+
<xsd:documentation><![CDATA[ Consumer threadpool: cached, fixed, limited, eager]]></xsd:documentation>
714+
</xsd:annotation>
715+
</xsd:attribute>
716+
<xsd:attribute name="corethreads" type="xsd:string" use="optional">
717+
<xsd:annotation>
718+
<xsd:documentation><![CDATA[ The thread pool core threads size. ]]></xsd:documentation>
719+
</xsd:annotation>
720+
</xsd:attribute>
721+
<xsd:attribute name="threads" type="xsd:string" use="optional">
722+
<xsd:annotation>
723+
<xsd:documentation><![CDATA[ The thread pool size. ]]></xsd:documentation>
724+
</xsd:annotation>
725+
</xsd:attribute>
726+
<xsd:attribute name="queues" type="xsd:string" use="optional">
727+
<xsd:annotation>
728+
<xsd:documentation><![CDATA[ The thread pool queue size. ]]></xsd:documentation>
729+
</xsd:annotation>
730+
</xsd:attribute>
711731
<xsd:anyAttribute namespace="##other" processContents="lax"/>
712732
</xsd:extension>
713733
</xsd:complexContent>

dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,26 @@
708708
<xsd:documentation><![CDATA[ Transporter layer framework: netty mina.... ]]></xsd:documentation>
709709
</xsd:annotation>
710710
</xsd:attribute>
711+
<xsd:attribute name="threadpool" type="xsd:string" use="optional">
712+
<xsd:annotation>
713+
<xsd:documentation><![CDATA[ Consumer threadpool: cached, fixed, limited, eager]]></xsd:documentation>
714+
</xsd:annotation>
715+
</xsd:attribute>
716+
<xsd:attribute name="corethreads" type="xsd:string" use="optional">
717+
<xsd:annotation>
718+
<xsd:documentation><![CDATA[ The thread pool core threads size. ]]></xsd:documentation>
719+
</xsd:annotation>
720+
</xsd:attribute>
721+
<xsd:attribute name="threads" type="xsd:string" use="optional">
722+
<xsd:annotation>
723+
<xsd:documentation><![CDATA[ The thread pool size. ]]></xsd:documentation>
724+
</xsd:annotation>
725+
</xsd:attribute>
726+
<xsd:attribute name="queues" type="xsd:string" use="optional">
727+
<xsd:annotation>
728+
<xsd:documentation><![CDATA[ The thread pool queue size. ]]></xsd:documentation>
729+
</xsd:annotation>
730+
</xsd:attribute>
711731
<xsd:anyAttribute namespace="##other" processContents="lax"/>
712732
</xsd:extension>
713733
</xsd:complexContent>

0 commit comments

Comments
 (0)