artemis

package module
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAnonymousLogin

func WithAnonymousLogin() testcontainers.CustomizeRequestOption

WithAnonymousLogin enables anonymous logins.

func WithCredentials

func WithCredentials(user, password string) testcontainers.CustomizeRequestOption

WithCredentials sets the administrator credentials. The default is artemis:artemis.

func WithExtraArgs

func WithExtraArgs(args string) testcontainers.CustomizeRequestOption

Additional arguments sent to the `artemis create“ command. The default is `--http-host 0.0.0.0 --relax-jolokia`. Setting this value will override the default. See the documentation on `artemis create` for available options.

Types

type Container

type Container struct {
	testcontainers.Container
	// contains filtered or unexported fields
}

Container represents the Artemis container type used in the module.

func RunContainer

func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*Container, error)

RunContainer creates an instance of the Artemis container type.

Example
// runArtemisContainer {
ctx := context.Background()

artemisContainer, err := artemis.RunContainer(ctx,
	testcontainers.WithImage("docker.io/apache/activemq-artemis:2.30.0"),
	artemis.WithCredentials("test", "test"),
)
if err != nil {
	log.Fatalf("failed to start container: %s", err)
}
defer func() {
	if err := artemisContainer.Terminate(ctx); err != nil {
		log.Fatalf("failed to terminate container: %s", err)
	}
}()
// }

state, err := artemisContainer.State(ctx)
if err != nil {
	log.Fatalf("failed to get container state: %s", err) // nolint:gocritic
}

fmt.Println(state.Running)

// connectToArtemisContainer {
// Get broker endpoint.
host, err := artemisContainer.BrokerEndpoint(ctx)
if err != nil {
	log.Fatalf("failed to get broker endpoint: %s", err)
}

// containerUser {
user := artemisContainer.User()
// }
// containerPassword {
pass := artemisContainer.Password()
// }

// Connect to Artemis via STOMP.
conn, err := stomp.Dial("tcp", host, stomp.ConnOpt.Login(user, pass))
if err != nil {
	log.Fatalf("failed to connect to Artemis: %s", err)
}
defer func() {
	if err := conn.Disconnect(); err != nil {
		log.Fatalf("failed to disconnect from Artemis: %s", err)
	}
}()
// }

fmt.Printf("%s:%s\n", user, pass)
Output:

true
test:test

func (*Container) BrokerEndpoint

func (c *Container) BrokerEndpoint(ctx context.Context) (string, error)

BrokerEndpoint returns the host:port for the combined protocols endpoint. The endpoint accepts CORE, MQTT, AMQP, STOMP, HORNETQ and OPENWIRE protocols.

func (*Container) ConsoleURL

func (c *Container) ConsoleURL(ctx context.Context) (string, error)

ConsoleURL returns the URL for the management console.

func (*Container) Password

func (c *Container) Password() string

Password returns the administrator password.

func (*Container) User

func (c *Container) User() string

User returns the administrator username.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL