Skip navigation links
org.apache.activemq.artemis.junit

Class EmbeddedActiveMQResource

    • Constructor Summary

      Constructors 
      Constructor and Description
      EmbeddedActiveMQResource()
      Create a default EmbeddedActiveMQResource
      EmbeddedActiveMQResource(org.apache.activemq.artemis.core.config.Configuration configuration)
      Creates an EmbeddedActiveMQResource using the specified configuration
      EmbeddedActiveMQResource(int serverId)
      Create a default EmbeddedActiveMQResource with the specified serverId
      EmbeddedActiveMQResource(String filename)
      Creates an EmbeddedActiveMQResource using the specified configuration file
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static void addMessageProperties(org.apache.activemq.artemis.api.core.client.ClientMessage message, Map<String,Object> properties)
      Adds properties to a ClientMessage
      protected void after()
      Invoked by JUnit to tear down the resource - stops the embedded ActiveMQ Artemis server
      protected void before()
      Invoked by JUnit to setup the resource - start the embedded ActiveMQ Artemis server
      org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(org.apache.activemq.artemis.api.core.SimpleString queueName)
      Browse a message (receive but do not consume) from the specified queue using the default receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(org.apache.activemq.artemis.api.core.SimpleString queueName, long timeout)
      Browse a message (receive but do not consume) a message from the specified queue using the specified receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(String queueName)
      Browse a message (receive but do not consume) from the specified queue using the default receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(String queueName, long timeout)
      Browse a message (receive but do not consume) a message from the specified queue using the specified receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage createMessage()
      Create a ClientMessage If useDurableMessage is false, a non-durable message is created.
      org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(byte[] body)
      Create a ClientMessage with the specified body If useDurableMessage is false, a non-durable message is created.
      org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(String body)
      Create a ClientMessage with the specified body If useDurableMessage is false, a non-durable message is created.
      org.apache.activemq.artemis.api.core.client.ClientMessage createMessageWithProperties(byte[] body, Map<String,Object> properties)
      Create a ClientMessage with the specified body and message properties If useDurableMessage is false, a non-durable message is created.
      org.apache.activemq.artemis.api.core.client.ClientMessage createMessageWithProperties(Map<String,Object> properties)
      Create a ClientMessage with the specified message properties If useDurableMessage is false, a non-durable message is created.
      org.apache.activemq.artemis.api.core.client.ClientMessage createMessageWithProperties(String body, Map<String,Object> properties)
      Create a ClientMessage with the specified body and message properties If useDurableMessage is false, a non-durable message is created.
      org.apache.activemq.artemis.core.server.Queue createQueue(org.apache.activemq.artemis.api.core.SimpleString address, org.apache.activemq.artemis.api.core.SimpleString name) 
      org.apache.activemq.artemis.core.server.Queue createQueue(String name) 
      org.apache.activemq.artemis.core.server.Queue createQueue(String address, String name) 
      void createSharedQueue(org.apache.activemq.artemis.api.core.SimpleString address, org.apache.activemq.artemis.api.core.SimpleString name, org.apache.activemq.artemis.api.core.SimpleString user) 
      void createSharedQueue(String name, String user) 
      void createSharedQueue(String address, String name, String user) 
      List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(org.apache.activemq.artemis.api.core.SimpleString address) 
      List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(String address) 
      long getDefaultReceiveTimeout() 
      long getMessageCount(org.apache.activemq.artemis.api.core.SimpleString queueName)
      Get the number of messages in a specific queue.
      long getMessageCount(String queueName) 
      org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ getServer()
      Get the EmbeddedActiveMQ server.
      String getServerName()
      Get the name of the EmbeddedActiveMQ server
      String getVmURL()
      Get the VM URL for the embedded EmbeddedActiveMQ server
      boolean isUseDurableMessage() 
      boolean isUseDurableQueue() 
      org.apache.activemq.artemis.core.server.Queue locateQueue(org.apache.activemq.artemis.api.core.SimpleString queueName) 
      org.apache.activemq.artemis.core.server.Queue locateQueue(String queueName) 
      org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(org.apache.activemq.artemis.api.core.SimpleString queueName)
      Receive a message from the specified queue using the default receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(org.apache.activemq.artemis.api.core.SimpleString queueName, long timeout)
      Receive a message from the specified queue using the specified receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(String queueName)
      Receive a message from the specified queue using the default receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(String queueName, long timeout)
      Receive a message from the specified queue using the specified receive timeout
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(org.apache.activemq.artemis.api.core.SimpleString address, byte[] body)
      Create a new message with the specified body, and send the message to an queueName
      void sendMessage(org.apache.activemq.artemis.api.core.SimpleString address, org.apache.activemq.artemis.api.core.client.ClientMessage message)
      Send a message to an queueName
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(org.apache.activemq.artemis.api.core.SimpleString address, String body)
      Create a new message with the specified body, and send the message to an queueName
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(String address, byte[] body)
      Create a new message with the specified body, and send the message to an address
      void sendMessage(String address, org.apache.activemq.artemis.api.core.client.ClientMessage message)
      Send a message to an address
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(String address, String body)
      Create a new message with the specified body, and send the message to an address
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(org.apache.activemq.artemis.api.core.SimpleString address, byte[] body, Map<String,Object> properties)
      Create a new message with the specified body and properties, and send the message to an queueName
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(org.apache.activemq.artemis.api.core.SimpleString address, Map<String,Object> properties)
      Create a new message with the specified properties, and send the message to an queueName
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(org.apache.activemq.artemis.api.core.SimpleString address, String body, Map<String,Object> properties)
      Create a new message with the specified body and properties, and send the message to an queueName
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(String address, byte[] body, Map<String,Object> properties)
      Create a new message with the specified body and properties, and send the message to an address
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(String address, Map<String,Object> properties)
      Create a new message with the specified properties, and send the message to an address
      org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(String address, String body, Map<String,Object> properties)
      Create a new message with the specified body and properties, and send the message to an address
      void setDefaultReceiveTimeout(long defaultReceiveTimeout)
      Sets the default timeout in milliseconds used when receiving messages.
      void setUseDurableMessage(boolean useDurableMessage)
      Disables/Enables creating durable messages.
      void setUseDurableQueue(boolean useDurableQueue)
      Disables/Enables creating durable queues.
      void start()
      Start the embedded ActiveMQ Artemis server.
      void stop()
      Stop the embedded ActiveMQ Artemis server The server will normally be stopped by JUnit using the after() method.
      • Methods inherited from class org.junit.rules.ExternalResource

        apply
    • Constructor Detail

      • EmbeddedActiveMQResource

        public EmbeddedActiveMQResource()
        Create a default EmbeddedActiveMQResource
      • EmbeddedActiveMQResource

        public EmbeddedActiveMQResource(int serverId)
        Create a default EmbeddedActiveMQResource with the specified serverId
        Parameters:
        serverId - server id
      • EmbeddedActiveMQResource

        public EmbeddedActiveMQResource(org.apache.activemq.artemis.core.config.Configuration configuration)
        Creates an EmbeddedActiveMQResource using the specified configuration
        Parameters:
        configuration - ActiveMQServer configuration
      • EmbeddedActiveMQResource

        public EmbeddedActiveMQResource(String filename)
        Creates an EmbeddedActiveMQResource using the specified configuration file
        Parameters:
        filename - ActiveMQServer configuration file name
    • Method Detail

      • addMessageProperties

        public static void addMessageProperties(org.apache.activemq.artemis.api.core.client.ClientMessage message,
                                                Map<String,Object> properties)
        Adds properties to a ClientMessage
        Parameters:
        message -
        properties -
      • start

        public void start()
        Start the embedded ActiveMQ Artemis server. The server will normally be started by JUnit using the before() method. This method allows the server to be started manually to support advanced testing scenarios.
      • stop

        public void stop()
        Stop the embedded ActiveMQ Artemis server The server will normally be stopped by JUnit using the after() method. This method allows the server to be stopped manually to support advanced testing scenarios.
      • before

        protected void before()
                       throws Throwable
        Invoked by JUnit to setup the resource - start the embedded ActiveMQ Artemis server
        Overrides:
        before in class org.junit.rules.ExternalResource
        Throws:
        Throwable
      • after

        protected void after()
        Invoked by JUnit to tear down the resource - stops the embedded ActiveMQ Artemis server
        Overrides:
        after in class org.junit.rules.ExternalResource
      • isUseDurableMessage

        public boolean isUseDurableMessage()
      • setUseDurableMessage

        public void setUseDurableMessage(boolean useDurableMessage)
        Disables/Enables creating durable messages. By default, durable messages are created
        Parameters:
        useDurableMessage - if true, durable messages will be created
      • isUseDurableQueue

        public boolean isUseDurableQueue()
      • setUseDurableQueue

        public void setUseDurableQueue(boolean useDurableQueue)
        Disables/Enables creating durable queues. By default, durable queues are created
        Parameters:
        useDurableQueue - if true, durable messages will be created
      • getDefaultReceiveTimeout

        public long getDefaultReceiveTimeout()
      • setDefaultReceiveTimeout

        public void setDefaultReceiveTimeout(long defaultReceiveTimeout)
        Sets the default timeout in milliseconds used when receiving messages. Defaults to 50 milliseconds
        Parameters:
        defaultReceiveTimeout - received timeout in milliseconds
      • getServer

        public org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ getServer()
        Get the EmbeddedActiveMQ server. This may be required for advanced configuration of the EmbeddedActiveMQ server.
        Returns:
        the embedded ActiveMQ broker
      • getServerName

        public String getServerName()
        Get the name of the EmbeddedActiveMQ server
        Returns:
        name of the embedded server
      • getVmURL

        public String getVmURL()
        Get the VM URL for the embedded EmbeddedActiveMQ server
        Returns:
        the VM URL for the embedded server
      • getMessageCount

        public long getMessageCount(String queueName)
      • getMessageCount

        public long getMessageCount(org.apache.activemq.artemis.api.core.SimpleString queueName)
        Get the number of messages in a specific queue.
        Parameters:
        queueName - the name of the queue
        Returns:
        the number of messages in the queue; -1 if queue is not found
      • locateQueue

        public org.apache.activemq.artemis.core.server.Queue locateQueue(String queueName)
      • locateQueue

        public org.apache.activemq.artemis.core.server.Queue locateQueue(org.apache.activemq.artemis.api.core.SimpleString queueName)
      • getBoundQueues

        public List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(String address)
      • getBoundQueues

        public List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(org.apache.activemq.artemis.api.core.SimpleString address)
      • createQueue

        public org.apache.activemq.artemis.core.server.Queue createQueue(String name)
      • createQueue

        public org.apache.activemq.artemis.core.server.Queue createQueue(String address,
                                                                         String name)
      • createQueue

        public org.apache.activemq.artemis.core.server.Queue createQueue(org.apache.activemq.artemis.api.core.SimpleString address,
                                                                         org.apache.activemq.artemis.api.core.SimpleString name)
      • createSharedQueue

        public void createSharedQueue(String name,
                                      String user)
      • createSharedQueue

        public void createSharedQueue(String address,
                                      String name,
                                      String user)
      • createSharedQueue

        public void createSharedQueue(org.apache.activemq.artemis.api.core.SimpleString address,
                                      org.apache.activemq.artemis.api.core.SimpleString name,
                                      org.apache.activemq.artemis.api.core.SimpleString user)
      • createMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage()
        Create a ClientMessage If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created
        Returns:
        a new ClientMessage
      • createMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(byte[] body)
        Create a ClientMessage with the specified body If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created
        Parameters:
        body - the body for the new message
        Returns:
        a new ClientMessage with the specified body
      • createMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(String body)
        Create a ClientMessage with the specified body If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created
        Parameters:
        body - the body for the new message
        Returns:
        a new ClientMessage with the specified body
      • createMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage createMessageWithProperties(Map<String,Object> properties)
        Create a ClientMessage with the specified message properties If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created
        Parameters:
        properties - message properties for the new message
        Returns:
        a new ClientMessage with the specified message properties
      • createMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage createMessageWithProperties(byte[] body,
                                                                                                     Map<String,Object> properties)
        Create a ClientMessage with the specified body and message properties If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created
        Parameters:
        body - the body for the new message
        properties - message properties for the new message
        Returns:
        a new ClientMessage with the specified body and message properties
      • createMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage createMessageWithProperties(String body,
                                                                                                     Map<String,Object> properties)
        Create a ClientMessage with the specified body and message properties If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created
        Parameters:
        body - the body for the new message
        properties - message properties for the new message
        Returns:
        a new ClientMessage with the specified body and message properties
      • sendMessage

        public void sendMessage(String address,
                                org.apache.activemq.artemis.api.core.client.ClientMessage message)
        Send a message to an address
        Parameters:
        address - the target queueName for the message
        message - the message to send
      • sendMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(String address,
                                                                                     byte[] body)
        Create a new message with the specified body, and send the message to an address
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        Returns:
        the message that was sent
      • sendMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(String address,
                                                                                     String body)
        Create a new message with the specified body, and send the message to an address
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        Returns:
        the message that was sent
      • sendMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(String address,
                                                                                                   Map<String,Object> properties)
        Create a new message with the specified properties, and send the message to an address
        Parameters:
        address - the target queueName for the message
        properties - message properties for the new message
        Returns:
        the message that was sent
      • sendMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(String address,
                                                                                                   byte[] body,
                                                                                                   Map<String,Object> properties)
        Create a new message with the specified body and properties, and send the message to an address
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        properties - message properties for the new message
        Returns:
        the message that was sent
      • sendMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(String address,
                                                                                                   String body,
                                                                                                   Map<String,Object> properties)
        Create a new message with the specified body and properties, and send the message to an address
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        properties - message properties for the new message
        Returns:
        the message that was sent
      • sendMessage

        public void sendMessage(org.apache.activemq.artemis.api.core.SimpleString address,
                                org.apache.activemq.artemis.api.core.client.ClientMessage message)
        Send a message to an queueName
        Parameters:
        address - the target queueName for the message
        message - the message to send
      • sendMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(org.apache.activemq.artemis.api.core.SimpleString address,
                                                                                     byte[] body)
        Create a new message with the specified body, and send the message to an queueName
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        Returns:
        the message that was sent
      • sendMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(org.apache.activemq.artemis.api.core.SimpleString address,
                                                                                     String body)
        Create a new message with the specified body, and send the message to an queueName
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        Returns:
        the message that was sent
      • sendMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(org.apache.activemq.artemis.api.core.SimpleString address,
                                                                                                   Map<String,Object> properties)
        Create a new message with the specified properties, and send the message to an queueName
        Parameters:
        address - the target queueName for the message
        properties - message properties for the new message
        Returns:
        the message that was sent
      • sendMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(org.apache.activemq.artemis.api.core.SimpleString address,
                                                                                                   byte[] body,
                                                                                                   Map<String,Object> properties)
        Create a new message with the specified body and properties, and send the message to an queueName
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        properties - message properties for the new message
        Returns:
        the message that was sent
      • sendMessageWithProperties

        public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessageWithProperties(org.apache.activemq.artemis.api.core.SimpleString address,
                                                                                                   String body,
                                                                                                   Map<String,Object> properties)
        Create a new message with the specified body and properties, and send the message to an queueName
        Parameters:
        address - the target queueName for the message
        body - the body for the new message
        properties - message properties for the new message
        Returns:
        the message that was sent
      • receiveMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(String queueName)
        Receive a message from the specified queue using the default receive timeout
        Parameters:
        queueName - name of the source queue
        Returns:
        the received ClientMessage, null if the receive timed-out
      • receiveMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(String queueName,
                                                                                        long timeout)
        Receive a message from the specified queue using the specified receive timeout
        Parameters:
        queueName - name of the source queue
        timeout - receive timeout in milliseconds
        Returns:
        the received ClientMessage, null if the receive timed-out
      • receiveMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(org.apache.activemq.artemis.api.core.SimpleString queueName)
        Receive a message from the specified queue using the default receive timeout
        Parameters:
        queueName - name of the source queue
        Returns:
        the received ClientMessage, null if the receive timed-out
      • receiveMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage receiveMessage(org.apache.activemq.artemis.api.core.SimpleString queueName,
                                                                                        long timeout)
        Receive a message from the specified queue using the specified receive timeout
        Parameters:
        queueName - name of the source queue
        timeout - receive timeout in milliseconds
        Returns:
        the received ClientMessage, null if the receive timed-out
      • browseMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(String queueName)
        Browse a message (receive but do not consume) from the specified queue using the default receive timeout
        Parameters:
        queueName - name of the source queue
        Returns:
        the received ClientMessage, null if the receive timed-out
      • browseMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(String queueName,
                                                                                       long timeout)
        Browse a message (receive but do not consume) a message from the specified queue using the specified receive timeout
        Parameters:
        queueName - name of the source queue
        timeout - receive timeout in milliseconds
        Returns:
        the received ClientMessage, null if the receive timed-out
      • browseMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(org.apache.activemq.artemis.api.core.SimpleString queueName)
        Browse a message (receive but do not consume) from the specified queue using the default receive timeout
        Parameters:
        queueName - name of the source queue
        Returns:
        the received ClientMessage, null if the receive timed-out
      • browseMessage

        public org.apache.activemq.artemis.api.core.client.ClientMessage browseMessage(org.apache.activemq.artemis.api.core.SimpleString queueName,
                                                                                       long timeout)
        Browse a message (receive but do not consume) a message from the specified queue using the specified receive timeout
        Parameters:
        queueName - name of the source queue
        timeout - receive timeout in milliseconds
        Returns:
        the received ClientMessage, null if the receive timed-out

Copyright © 2023 The Apache Software Foundation. All Rights Reserved.