Class EmbeddedActiveMQDelegate
- java.lang.Object
-
- org.apache.activemq.artemis.junit.EmbeddedActiveMQDelegate
-
- All Implemented Interfaces:
EmbeddedActiveMQOperations
public class EmbeddedActiveMQDelegate extends Object implements EmbeddedActiveMQOperations
Base class to embed an ActiveMQ Artemis server into a test.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEmbeddedActiveMQDelegate.EmbeddedActiveMQResourceException
-
Constructor Summary
Constructors Modifier Constructor Description protectedEmbeddedActiveMQDelegate()Create a default EmbeddedActiveMQResourceprotectedEmbeddedActiveMQDelegate(int serverId)Create a default EmbeddedActiveMQResource with the specified serverIdprotectedEmbeddedActiveMQDelegate(String filename)Creates an EmbeddedActiveMQResource using the specified configuration fileprotectedEmbeddedActiveMQDelegate(Configuration configuration)Creates an EmbeddedActiveMQResource using the specified configuration
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddMessageProperties(ClientMessage message, Map<String,Object> properties)Adds properties to a ClientMessageClientMessagebrowseMessage(String queueName)Browse a message (receive but do not consume) from the specified queue using the default receive timeoutClientMessagebrowseMessage(String queueName, long timeout)Browse a message (receive but do not consume) a message from the specified queue using the specified receive timeoutClientMessagebrowseMessage(SimpleString queueName)Browse a message (receive but do not consume) from the specified queue using the default receive timeoutClientMessagebrowseMessage(SimpleString queueName, long timeout)Browse a message (receive but do not consume) a message from the specified queue using the specified receive timeoutClientMessagecreateMessage()Create a ClientMessage.ClientMessagecreateMessage(byte[] body)Create a ClientMessage with the specified body.ClientMessagecreateMessage(String body)Create a ClientMessage with the specified body.ClientMessagecreateMessageWithProperties(byte[] body, Map<String,Object> properties)Create a ClientMessage with the specified body and message properties.ClientMessagecreateMessageWithProperties(String body, Map<String,Object> properties)Create a ClientMessage with the specified body and message properties.ClientMessagecreateMessageWithProperties(Map<String,Object> properties)Create a ClientMessage with the specified message properties.org.apache.activemq.artemis.core.server.QueuecreateQueue(String name)org.apache.activemq.artemis.core.server.QueuecreateQueue(String address, String name)org.apache.activemq.artemis.core.server.QueuecreateQueue(SimpleString address, SimpleString name)voidcreateSharedQueue(String name, String user)voidcreateSharedQueue(String address, String name, String user)voidcreateSharedQueue(SimpleString address, SimpleString name, SimpleString user)List<org.apache.activemq.artemis.core.server.Queue>getBoundQueues(String address)List<org.apache.activemq.artemis.core.server.Queue>getBoundQueues(SimpleString address)longgetDefaultReceiveTimeout()longgetMessageCount(String queueName)Get the number of messages in a specific queue.longgetMessageCount(SimpleString queueName)Get the number of messages in a specific queue.org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQgetServer()Get the EmbeddedActiveMQ server.StringgetServerName()Get the name of the EmbeddedActiveMQ serverStringgetVmURL()Get the VM URL for the embedded EmbeddedActiveMQ serverbooleanisUseDurableMessage()booleanisUseDurableQueue()org.apache.activemq.artemis.core.server.QueuelocateQueue(String queueName)org.apache.activemq.artemis.core.server.QueuelocateQueue(SimpleString queueName)ClientMessagereceiveMessage(String queueName)Receive a message from the specified queue using the default receive timeoutClientMessagereceiveMessage(String queueName, long timeout)Receive a message from the specified queue using the specified receive timeoutClientMessagereceiveMessage(SimpleString queueName)Receive a message from the specified queue using the default receive timeoutClientMessagereceiveMessage(SimpleString queueName, long timeout)Receive a message from the specified queue using the specified receive timeoutClientMessagesendMessage(String address, byte[] body)Create a new message with the specified body, and send the message to an addressClientMessagesendMessage(String address, String body)Create a new message with the specified body, and send the message to an addressvoidsendMessage(String address, ClientMessage message)Send a message to an addressClientMessagesendMessage(SimpleString address, byte[] body)Create a new message with the specified body, and send the message to an queueNameClientMessagesendMessage(SimpleString address, String body)Create a new message with the specified body, and send the message to an queueNamevoidsendMessage(SimpleString address, ClientMessage message)Send a message to an queueNameClientMessagesendMessageWithProperties(String address, byte[] body, Map<String,Object> properties)Create a new message with the specified body and properties, and send the message to an addressClientMessagesendMessageWithProperties(String address, String body, Map<String,Object> properties)Create a new message with the specified body and properties, and send the message to an addressClientMessagesendMessageWithProperties(String address, Map<String,Object> properties)Create a new message with the specified properties, and send the message to an addressClientMessagesendMessageWithProperties(SimpleString address, byte[] body, Map<String,Object> properties)Create a new message with the specified body and properties, and send the message to an queueNameClientMessagesendMessageWithProperties(SimpleString address, String body, Map<String,Object> properties)Create a new message with the specified body and properties, and send the message to an queueNameClientMessagesendMessageWithProperties(SimpleString address, Map<String,Object> properties)Create a new message with the specified properties, and send the message to an queueNamevoidsetDefaultReceiveTimeout(long defaultReceiveTimeout)Sets the default timeout in milliseconds used when receiving messages.voidsetUseDurableMessage(boolean useDurableMessage)Disables/Enables creating durable messages.voidsetUseDurableQueue(boolean useDurableQueue)Disables/Enables creating durable queues.voidstart()Start the embedded ActiveMQ Artemis server.voidstop()Stop the embedded ActiveMQ Artemis server The server will normally be stopped by JUnit using the after() method.
-
-
-
Constructor Detail
-
EmbeddedActiveMQDelegate
protected EmbeddedActiveMQDelegate()
Create a default EmbeddedActiveMQResource
-
EmbeddedActiveMQDelegate
protected EmbeddedActiveMQDelegate(int serverId)
Create a default EmbeddedActiveMQResource with the specified serverId- Parameters:
serverId- server id
-
EmbeddedActiveMQDelegate
protected EmbeddedActiveMQDelegate(Configuration configuration)
Creates an EmbeddedActiveMQResource using the specified configuration- Parameters:
configuration- ActiveMQServer configuration
-
EmbeddedActiveMQDelegate
protected EmbeddedActiveMQDelegate(String filename)
Creates an EmbeddedActiveMQResource using the specified configuration file- Parameters:
filename- ActiveMQServer configuration file name
-
-
Method Detail
-
addMessageProperties
public static void addMessageProperties(ClientMessage message, Map<String,Object> properties)
Adds properties to a ClientMessage- Parameters:
message-properties-
-
start
public void start()
Description copied from interface:EmbeddedActiveMQOperationsStart 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.- Specified by:
startin interfaceEmbeddedActiveMQOperations
-
stop
public void stop()
Description copied from interface:EmbeddedActiveMQOperationsStop 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.- Specified by:
stopin interfaceEmbeddedActiveMQOperations
-
isUseDurableMessage
public boolean isUseDurableMessage()
- Specified by:
isUseDurableMessagein interfaceEmbeddedActiveMQOperations
-
setUseDurableMessage
public void setUseDurableMessage(boolean useDurableMessage)
Description copied from interface:EmbeddedActiveMQOperationsDisables/Enables creating durable messages. By default, durable messages are created- Specified by:
setUseDurableMessagein interfaceEmbeddedActiveMQOperations- Parameters:
useDurableMessage- if true, durable messages will be created
-
isUseDurableQueue
public boolean isUseDurableQueue()
- Specified by:
isUseDurableQueuein interfaceEmbeddedActiveMQOperations
-
setUseDurableQueue
public void setUseDurableQueue(boolean useDurableQueue)
Description copied from interface:EmbeddedActiveMQOperationsDisables/Enables creating durable queues. By default, durable queues are created- Specified by:
setUseDurableQueuein interfaceEmbeddedActiveMQOperations- Parameters:
useDurableQueue- if true, durable messages will be created
-
getDefaultReceiveTimeout
public long getDefaultReceiveTimeout()
- Specified by:
getDefaultReceiveTimeoutin interfaceEmbeddedActiveMQOperations
-
setDefaultReceiveTimeout
public void setDefaultReceiveTimeout(long defaultReceiveTimeout)
Description copied from interface:EmbeddedActiveMQOperationsSets the default timeout in milliseconds used when receiving messages. Defaults to 50 milliseconds- Specified by:
setDefaultReceiveTimeoutin interfaceEmbeddedActiveMQOperations- Parameters:
defaultReceiveTimeout- received timeout in milliseconds
-
getServer
public org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ getServer()
Description copied from interface:EmbeddedActiveMQOperationsGet the EmbeddedActiveMQ server. This may be required for advanced configuration of the EmbeddedActiveMQ server.- Specified by:
getServerin interfaceEmbeddedActiveMQOperations- Returns:
- the embedded ActiveMQ broker
-
getServerName
public String getServerName()
Description copied from interface:EmbeddedActiveMQOperationsGet the name of the EmbeddedActiveMQ server- Specified by:
getServerNamein interfaceEmbeddedActiveMQOperations- Returns:
- name of the embedded server
-
getVmURL
public String getVmURL()
Description copied from interface:EmbeddedActiveMQOperationsGet the VM URL for the embedded EmbeddedActiveMQ server- Specified by:
getVmURLin interfaceEmbeddedActiveMQOperations- Returns:
- the VM URL for the embedded server
-
getMessageCount
public long getMessageCount(String queueName)
Description copied from interface:EmbeddedActiveMQOperationsGet the number of messages in a specific queue.- Specified by:
getMessageCountin interfaceEmbeddedActiveMQOperations- Parameters:
queueName- the name of the queue- Returns:
- the number of messages in the queue; -1 if queue is not found
-
getMessageCount
public long getMessageCount(SimpleString queueName)
Description copied from interface:EmbeddedActiveMQOperationsGet the number of messages in a specific queue.- Specified by:
getMessageCountin interfaceEmbeddedActiveMQOperations- 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)
- Specified by:
locateQueuein interfaceEmbeddedActiveMQOperations
-
locateQueue
public org.apache.activemq.artemis.core.server.Queue locateQueue(SimpleString queueName)
- Specified by:
locateQueuein interfaceEmbeddedActiveMQOperations
-
getBoundQueues
public List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(String address)
- Specified by:
getBoundQueuesin interfaceEmbeddedActiveMQOperations
-
getBoundQueues
public List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(SimpleString address)
- Specified by:
getBoundQueuesin interfaceEmbeddedActiveMQOperations
-
createQueue
public org.apache.activemq.artemis.core.server.Queue createQueue(String name)
- Specified by:
createQueuein interfaceEmbeddedActiveMQOperations
-
createQueue
public org.apache.activemq.artemis.core.server.Queue createQueue(String address, String name)
- Specified by:
createQueuein interfaceEmbeddedActiveMQOperations
-
createQueue
public org.apache.activemq.artemis.core.server.Queue createQueue(SimpleString address, SimpleString name)
- Specified by:
createQueuein interfaceEmbeddedActiveMQOperations
-
createSharedQueue
public void createSharedQueue(String name, String user)
- Specified by:
createSharedQueuein interfaceEmbeddedActiveMQOperations
-
createSharedQueue
public void createSharedQueue(String address, String name, String user)
- Specified by:
createSharedQueuein interfaceEmbeddedActiveMQOperations
-
createSharedQueue
public void createSharedQueue(SimpleString address, SimpleString name, SimpleString user)
- Specified by:
createSharedQueuein interfaceEmbeddedActiveMQOperations
-
createMessage
public ClientMessage createMessage()
Description copied from interface:EmbeddedActiveMQOperationsCreate a ClientMessage.If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created.
- Specified by:
createMessagein interfaceEmbeddedActiveMQOperations- Returns:
- a new ClientMessage
-
createMessage
public ClientMessage createMessage(byte[] body)
Description copied from interface:EmbeddedActiveMQOperationsCreate a ClientMessage with the specified body.If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created.
- Specified by:
createMessagein interfaceEmbeddedActiveMQOperations- Parameters:
body- the body for the new message- Returns:
- a new ClientMessage with the specified body
-
createMessage
public ClientMessage createMessage(String body)
Description copied from interface:EmbeddedActiveMQOperationsCreate a ClientMessage with the specified body.If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created.
- Specified by:
createMessagein interfaceEmbeddedActiveMQOperations- Parameters:
body- the body for the new message- Returns:
- a new ClientMessage with the specified body
-
createMessageWithProperties
public ClientMessage createMessageWithProperties(Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate a ClientMessage with the specified message properties.If useDurableMessage is false, a non-durable message is created. Otherwise, a durable message is created.
- Specified by:
createMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
properties- message properties for the new message- Returns:
- a new ClientMessage with the specified message properties
-
createMessageWithProperties
public ClientMessage createMessageWithProperties(byte[] body, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate 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.
- Specified by:
createMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
body- the body for the new messageproperties- message properties for the new message- Returns:
- a new ClientMessage with the specified body and message properties
-
createMessageWithProperties
public ClientMessage createMessageWithProperties(String body, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate 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.
- Specified by:
createMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
body- the body for the new messageproperties- message properties for the new message- Returns:
- a new ClientMessage with the specified body and message properties
-
sendMessage
public void sendMessage(String address, ClientMessage message)
Description copied from interface:EmbeddedActiveMQOperationsSend a message to an address- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagemessage- the message to send
-
sendMessage
public ClientMessage sendMessage(String address, byte[] body)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body, and send the message to an address- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new message- Returns:
- the message that was sent
-
sendMessage
public ClientMessage sendMessage(String address, String body)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body, and send the message to an address- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new message- Returns:
- the message that was sent
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(String address, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified properties, and send the message to an address- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messageproperties- message properties for the new message- Returns:
- the message that was sent
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(String address, byte[] body, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body and properties, and send the message to an address- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new messageproperties- message properties for the new message- Returns:
- the message that was sent
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(String address, String body, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body and properties, and send the message to an address- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new messageproperties- message properties for the new message- Returns:
- the message that was sent
-
sendMessage
public void sendMessage(SimpleString address, ClientMessage message)
Description copied from interface:EmbeddedActiveMQOperationsSend a message to an queueName- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagemessage- the message to send
-
sendMessage
public ClientMessage sendMessage(SimpleString address, byte[] body)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body, and send the message to an queueName- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new message- Returns:
- the message that was sent
-
sendMessage
public ClientMessage sendMessage(SimpleString address, String body)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body, and send the message to an queueName- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new message- Returns:
- the message that was sent
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(SimpleString address, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified properties, and send the message to an queueName- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messageproperties- message properties for the new message- Returns:
- the message that was sent
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(SimpleString address, byte[] body, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body and properties, and send the message to an queueName- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new messageproperties- message properties for the new message- Returns:
- the message that was sent
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(SimpleString address, String body, Map<String,Object> properties)
Description copied from interface:EmbeddedActiveMQOperationsCreate a new message with the specified body and properties, and send the message to an queueName- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations- Parameters:
address- the target queueName for the messagebody- the body for the new messageproperties- message properties for the new message- Returns:
- the message that was sent
-
receiveMessage
public ClientMessage receiveMessage(String queueName)
Description copied from interface:EmbeddedActiveMQOperationsReceive a message from the specified queue using the default receive timeout- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queue- Returns:
- the received ClientMessage, null if the receive timed-out
-
receiveMessage
public ClientMessage receiveMessage(String queueName, long timeout)
Description copied from interface:EmbeddedActiveMQOperationsReceive a message from the specified queue using the specified receive timeout- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queuetimeout- receive timeout in milliseconds- Returns:
- the received ClientMessage, null if the receive timed-out
-
receiveMessage
public ClientMessage receiveMessage(SimpleString queueName)
Description copied from interface:EmbeddedActiveMQOperationsReceive a message from the specified queue using the default receive timeout- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queue- Returns:
- the received ClientMessage, null if the receive timed-out
-
receiveMessage
public ClientMessage receiveMessage(SimpleString queueName, long timeout)
Description copied from interface:EmbeddedActiveMQOperationsReceive a message from the specified queue using the specified receive timeout- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queuetimeout- receive timeout in milliseconds- Returns:
- the received ClientMessage, null if the receive timed-out
-
browseMessage
public ClientMessage browseMessage(String queueName)
Description copied from interface:EmbeddedActiveMQOperationsBrowse a message (receive but do not consume) from the specified queue using the default receive timeout- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queue- Returns:
- the received ClientMessage, null if the receive timed-out
-
browseMessage
public ClientMessage browseMessage(String queueName, long timeout)
Description copied from interface:EmbeddedActiveMQOperationsBrowse a message (receive but do not consume) a message from the specified queue using the specified receive timeout- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queuetimeout- receive timeout in milliseconds- Returns:
- the received ClientMessage, null if the receive timed-out
-
browseMessage
public ClientMessage browseMessage(SimpleString queueName)
Description copied from interface:EmbeddedActiveMQOperationsBrowse a message (receive but do not consume) from the specified queue using the default receive timeout- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queue- Returns:
- the received ClientMessage, null if the receive timed-out
-
browseMessage
public ClientMessage browseMessage(SimpleString queueName, long timeout)
Description copied from interface:EmbeddedActiveMQOperationsBrowse a message (receive but do not consume) a message from the specified queue using the specified receive timeout- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations- Parameters:
queueName- name of the source queuetimeout- receive timeout in milliseconds- Returns:
- the received ClientMessage, null if the receive timed-out
-
-