forked from nats-io/nats.java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADDED] Global Message Delivery Thread Pool
This PR adds the ability to set a library level thread pool responsible to dispatch asynchronous subscriptions' messages. All messages from a given subscription will be delivered in the order they arrived. A connection option allows the user to force the subscription to use its own thread to dispatch its message even if the library pool has been set. Resolves nats-io#114
- Loading branch information
Showing
40 changed files
with
892 additions
and
767 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,9 +32,6 @@ deploy: | |
repo: nats-io/java-nats | ||
tags: true | ||
jdk: oraclejdk8 | ||
notifications: | ||
email: | ||
- [email protected] | ||
env: | ||
global: | ||
- GPG_DIR=${TRAVIS_BUILD_DIR}/.travis/keyrings | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2017 Apcera Inc. All rights reserved. This program and the accompanying | ||
* materials are made available under the terms of the MIT License (MIT) which accompanies this | ||
* distribution, and is available at http://opensource.org/licenses/MIT | ||
*/ | ||
|
||
package io.nats.client; | ||
|
||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Rule; | ||
import org.junit.experimental.categories.Category; | ||
|
||
@Category(IntegrationTest.class) | ||
public class ITBaseTest { | ||
static int msgDeliveryPoolSize = 0; | ||
|
||
@Rule | ||
public TestCasePrinterRule pr = new TestCasePrinterRule(System.out); | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws Exception { | ||
String prop = System.getProperty("msgDeliveryPoolSize"); | ||
if (prop != null) { | ||
msgDeliveryPoolSize = Integer.parseInt(prop); | ||
} | ||
if (msgDeliveryPoolSize == 0) { | ||
// If the system environment variable JNATS_MSG_DELIVERY_THREAD_POOL_SIZE | ||
// exists (and number if positive), the library will create the thread | ||
// pool. We need to shutdown the pool here. Individual tests may create | ||
// the pool with the size they want. | ||
Nats.shutdownMsgDeliveryThreadPool(); | ||
} | ||
} | ||
|
||
@AfterClass | ||
public static void tearDownAfterClass() throws Exception { | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
// If need be, setup the message delivery thread pool for each | ||
// test. This allows finding out if a test is holding onto | ||
// a resource in the message callback preventing the pool to | ||
// be shutdown. | ||
if (msgDeliveryPoolSize > 0) { | ||
Nats.setMsgDeliveryThreadPoolSize(msgDeliveryPoolSize); | ||
} | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
// Shutdown the message delivery pool if one was set. | ||
Nats.shutdownMsgDeliveryThreadPool(); | ||
} | ||
} |
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
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
Oops, something went wrong.