<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.12')-
Image versions on dockerhub
-
-
embedded.toxiproxy.proxies.nats.enabledEnables both creation of the container with ToxiProxy TCP proxy and a proxy to theembedded-natscontainer.
-
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
ToxiproxyClientProxy 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.propertiesembedded.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);
}