<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-nats</artifactId>
<scope>test</scope>
</dependency>
-
embedded.nats.enabled
(true|false, default is true)
-
embedded.nats.reuseContainer
(true|false, default is false)
-
embedded.nats.dockerImage
(default is 'nats:2.9')
-
Image versions on dockerhub
-
-
embedded.toxiproxy.proxies.nats.enabled
Enables both creation of the container with ToxiProxy TCP proxy and a proxy to theembedded-nats
container.
-
embedded.nats.host
-
embedded.nats.port
-
embedded.nats.httpMonitorPort
-
embedded.nats.routeConnectionsPort
-
embedded.nats.toxiproxy.host
-
embedded.nats.toxiproxy.port
-
embedded.nats.networkAlias
-
embedded.nats.internalClientPort
-
embedded.nats.internalHttpMonitorPort
-
embedded.nats.internalRouteConnectionsPort
-
Bean
ToxiproxyContainer.ContainerProxy natsContainerProxy
Nats container has no security enabled, you can use any credentials.
You can also create client pointed at ToxiProxy TCP proxy:
-
Provide properties:
src/test/resources/bootstrap.properties
embedded.toxiproxy.proxies.nats.enabled=true
@Bean(destroyMethod = "close")
public Connection natsConnection(@Value("${embedded.nats.host}") String host,
@Value("${embedded.nats.port}") int port) {
Options options = new Options.Builder()
.server(String.format("nats://%s:%s", host, port))
.build();
return Nats.connect(options);
}