activemq

package module
v0.0.0-...-ea854ec Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package activemq provides a testcontainers module for Apache ActiveMQ Classic.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAdminCredentials

func WithAdminCredentials(user, password string) testcontainers.CustomizeRequestOption

WithAdminCredentials sets ACTIVEMQ_WEB_USER and ACTIVEMQ_WEB_PASSWORD. The image entrypoint uses these to update conf/users.properties, which configures the JAAS PropertiesLoginModule used for broker connection/messaging security when connection-level authentication is enabled.

NOTE: these variables do NOT affect web-console or Jolokia authentication. The web console and /api/jolokia/* endpoints are protected by Jetty's HashLoginService reading conf/jetty-realm.properties, which is hardcoded to "admin: admin, admin" and is not configurable via environment variables. AdminUser() and AdminPassword() always return those built-in values.

Types

type Container

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

Container represents the ActiveMQ container type used in the module.

func Run

Run creates an instance of the ActiveMQ container type with a given image.

Example

ExampleRun demonstrates how to start an Apache ActiveMQ Classic container and retrieve the broker URL and web-console credentials.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/testcontainers/testcontainers-go"
	"github.com/testcontainers/testcontainers-go/modules/activemq"
)

func main() {
	// runActiveMQContainer {
	ctx := context.Background()

	activemqContainer, err := activemq.Run(ctx,
		"apache/activemq-classic:5.18.7",
		activemq.WithAdminCredentials("test", "test"),
	)
	defer func() {
		if err := testcontainers.TerminateContainer(activemqContainer); err != nil {
			log.Printf("failed to terminate container: %s", err)
		}
	}()
	if err != nil {
		log.Printf("failed to start container: %s", err)
		return
	}
	// }

	state, err := activemqContainer.State(ctx)
	if err != nil {
		log.Printf("failed to get container state: %s", err)
		return
	}

	fmt.Println(state.Running)

	// adminUser {
	user := activemqContainer.AdminUser()
	// }
	// adminPassword {
	pass := activemqContainer.AdminPassword()
	// }

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

}
Output:
true
admin:admin

func (*Container) AdminPassword

func (c *Container) AdminPassword() string

AdminPassword returns the web-console password. The ActiveMQ Classic image protects the web console with Jetty's HashLoginService (conf/jetty-realm.properties), which is hardcoded to "admin: admin, admin" and cannot be overridden via environment variables. This method therefore always returns "admin".

func (*Container) AdminUser

func (c *Container) AdminUser() string

AdminUser returns the web-console username. The ActiveMQ Classic image protects the web console with Jetty's HashLoginService (conf/jetty-realm.properties), which is hardcoded to "admin: admin, admin" and cannot be overridden via environment variables. This method therefore always returns "admin".

func (*Container) BrokerURL

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

BrokerURL returns the OpenWire broker URL for the mapped 61616/tcp port.

func (*Container) WebConsoleURL

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

WebConsoleURL returns the HTTP URL of the ActiveMQ web console for the mapped 8161/tcp port.

Jump to

Keyboard shortcuts

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