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

Class EmbeddedJMSResource

    • Constructor Detail

      • EmbeddedJMSResource

        public EmbeddedJMSResource()
        Create a default EmbeddedJMSResource
      • EmbeddedJMSResource

        public EmbeddedJMSResource(boolean useNetty)
        Create a default EmbeddedJMSResource
      • EmbeddedJMSResource

        public EmbeddedJMSResource(int serverId)
        Create a default EmbeddedJMSResource with the specified server id
      • EmbeddedJMSResource

        public EmbeddedJMSResource(org.apache.activemq.artemis.core.config.Configuration configuration,
                                   JMSConfiguration jmsConfiguration)
        Create an EmbeddedJMSResource with the specified configurations
        Parameters:
        configuration - ActiveMQServer configuration
        jmsConfiguration - JMSServerManager configuration
      • EmbeddedJMSResource

        public EmbeddedJMSResource(String filename)
        Create an EmbeddedJMSResource with the specified configuration file
        Parameters:
        filename - configuration file name
      • EmbeddedJMSResource

        public EmbeddedJMSResource(String serverConfigurationFileName,
                                   String jmsConfigurationFileName)
        Create an EmbeddedJMSResource with the specified configuration file
        Parameters:
        serverConfigurationFileName - ActiveMQServer configuration file name
        jmsConfigurationFileName - JMSServerManager configuration file name
    • Method Detail

      • setMessageProperties

        public static void setMessageProperties(javax.jms.Message message,
                                                Map<String,Object> properties)
      • start

        public void start()
        Start the embedded EmbeddedJMSResource.

        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 broker, blocking until the broker has stopped.

        The broker will normally be stopped by JUnit using the after() method. This method allows the broker to be stopped manually to support advanced testing scenarios.

      • before

        protected void before()
                       throws Throwable
        Start the embedded ActiveMQ Broker

        Invoked by JUnit to setup the resource

        Overrides:
        before in class org.junit.rules.ExternalResource
        Throws:
        Throwable
      • after

        protected void after()
        Stop the embedded ActiveMQ Broker

        Invoked by JUnit to tear down the resource

        Overrides:
        after in class org.junit.rules.ExternalResource
      • getJmsServer

        public EmbeddedJMS getJmsServer()
        Get the EmbeddedJMS server.

        This may be required for advanced configuration of the EmbeddedJMS server.

        Returns:
      • getServerName

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

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

        public org.apache.activemq.artemis.core.server.Queue getDestinationQueue(String destinationName)
        Get the Queue corresponding to a JMS Destination.

        The full name of the JMS destination including the prefix should be provided - i.e. queue://myQueue or topic://myTopic. If the destination type prefix is not included in the destination name, a prefix of "queue://" is assumed.

        Parameters:
        destinationName - the full name of the JMS Destination
        Returns:
        the number of messages in the JMS Destination
      • getTopicQueues

        public List<org.apache.activemq.artemis.core.server.Queue> getTopicQueues(String topicName)
        Get the Queues corresponding to a JMS Topic.

        The full name of the JMS Topic including the prefix should be provided - i.e. topic://myTopic. If the destination type prefix is not included in the destination name, a prefix of "topic://" is assumed.

        Parameters:
        topicName - the full name of the JMS Destination
        Returns:
        the number of messages in the JMS Destination
      • getMessageCount

        public long getMessageCount(String destinationName)
        Get the number of messages in a specific JMS Destination.

        The full name of the JMS destination including the prefix should be provided - i.e. queue://myQueue or topic://myTopic. If the destination type prefix is not included in the destination name, a prefix of "queue://" is assumed. NOTE: For JMS Topics, this returned count will be the total number of messages for all subscribers. For example, if there are two subscribers on the topic and a single message is published, the returned count will be two (one message for each subscriber).

        Parameters:
        destinationName - the full name of the JMS Destination
        Returns:
        the number of messages in the JMS Destination
      • createBytesMessage

        public javax.jms.BytesMessage createBytesMessage()
      • createTextMessage

        public javax.jms.TextMessage createTextMessage()
      • createMapMessage

        public javax.jms.MapMessage createMapMessage()
      • createObjectMessage

        public javax.jms.ObjectMessage createObjectMessage()
      • createStreamMessage

        public javax.jms.StreamMessage createStreamMessage()
      • createMessage

        public javax.jms.BytesMessage createMessage(byte[] body)
      • createMessage

        public javax.jms.TextMessage createMessage(String body)
      • createMessage

        public javax.jms.MapMessage createMessage(Map<String,Object> body)
      • createMessage

        public javax.jms.ObjectMessage createMessage(Serializable body)
      • createMessage

        public javax.jms.BytesMessage createMessage(byte[] body,
                                                    Map<String,Object> properties)
      • createMessage

        public javax.jms.TextMessage createMessage(String body,
                                                   Map<String,Object> properties)
      • pushMessage

        public void pushMessage(String destinationName,
                                javax.jms.Message message)
      • pushMessage

        public javax.jms.BytesMessage pushMessage(String destinationName,
                                                  byte[] body)
      • pushMessage

        public javax.jms.TextMessage pushMessage(String destinationName,
                                                 String body)
      • pushMessage

        public javax.jms.MapMessage pushMessage(String destinationName,
                                                Map<String,Object> body)
      • pushMessage

        public javax.jms.ObjectMessage pushMessage(String destinationName,
                                                   Serializable body)
      • pushMessageWithProperties

        public javax.jms.BytesMessage pushMessageWithProperties(String destinationName,
                                                                byte[] body,
                                                                Map<String,Object> properties)
      • pushMessageWithProperties

        public javax.jms.TextMessage pushMessageWithProperties(String destinationName,
                                                               String body,
                                                               Map<String,Object> properties)
      • peekMessage

        public javax.jms.Message peekMessage(String destinationName)
      • peekBytesMessage

        public javax.jms.BytesMessage peekBytesMessage(String destinationName)
      • peekTextMessage

        public javax.jms.TextMessage peekTextMessage(String destinationName)
      • peekMapMessage

        public javax.jms.MapMessage peekMapMessage(String destinationName)
      • peekObjectMessage

        public javax.jms.ObjectMessage peekObjectMessage(String destinationName)
      • peekStreamMessage

        public javax.jms.StreamMessage peekStreamMessage(String destinationName)

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