public class Async extends Object
EmbeddedActiveMQ to
 sensible values so you do not have to.
 This class also implements a Command Pattern for ease of writing asynchronous code.| Constructor and Description | 
|---|
Async(String dataDirectory,
     boolean useLibAio,
     com.google.inject.Injector injector,
     QueueConfig... queueConfigs)
Creates and configures a new instance. 
 | 
Async(String dataDirectory,
     boolean useLibAio,
     QueueConfig... queueConfigs)
Creates and configures a new instance. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
configureNetty(String host,
              int port)
Call this method once after a constructor in order to create a Netty instance to accept out of VM messages. 
 | 
BatchReceiver | 
getBatchReceiver(String queueName,
                long timeout)
Generate a  
BatchReceiver to receive and process stored messages. | 
static byte[] | 
getBytes(javax.jms.BytesMessage message)  | 
org.apache.activemq.artemis.core.config.Configuration | 
getConfig()
Get additional server configuration. 
 | 
long | 
getMessageCount(String queue)
Returns number of messages currently in queue 
 | 
Map<String,Long> | 
getMessageCounts()
Returns counts of messages for all queues. 
 | 
List<Command> | 
getTopCommands(int count,
              String queueName)
Returns top commands in queue. 
 | 
List<String> | 
getTopTextMessages(int maxSize,
                  String queueName)
Returns top  
TextMessages in queue. | 
boolean | 
isPaused(String queueName)  | 
boolean | 
moveMessage(String jmsMessageId,
           String source,
           String target)
Moves a message from one queue to another 
 | 
int | 
moveMessages(String source,
            String target)
Moves all messages from one queue to another 
 | 
void | 
pause(String queueName)
Pauses a queue. 
 | 
Command | 
receiveCommand(String queueName)
Receives a command from a queue synchronously. 
 | 
<T extends Command> | 
receiveCommand(String queueName,
              Class<T> type)
Receives a command from a queue synchronously. 
 | 
<T extends Command> | 
receiveCommand(String queueName,
              int timeout,
              Class<T> type)
Receives a command from a queue synchronously. 
 | 
Command | 
receiveCommand(String queueName,
              long timeout)
Receives a command from a queue synchronously. 
 | 
javax.jms.Message | 
receiveMessage(String queueName,
              long timeout)
Receives a messafge from a queue asynchronously.If this queue also has listeners, then messages will be distributed across
 all consumers. 
 | 
int | 
removeAllMessages(String queueName)
Removes all messages from queue. 
 | 
int | 
removeMessages(String queueName,
              String filter)
Removes messages from queue. 
 | 
void | 
resume(String queueName)
Resumes a paused queue 
 | 
void | 
send(String queueName,
    Command command)
Sends a command into a queue for processing 
 | 
void | 
send(String queueName,
    Command command,
    Date deliveryTime)
Sends a command into a queue for processing 
 | 
void | 
send(String queueName,
    Command command,
    int deliveryMode)
Sends a command into a queue for processing 
 | 
void | 
send(String queueName,
    Command command,
    int deliveryMode,
    int priority,
    long timeToLive)
Sends a command into a queue for processing 
 | 
void | 
send(String queueName,
    Command command,
    int deliveryMode,
    int priority,
    long timeToLive,
    long deliveryTime)
Sends a command into a queue for processing 
 | 
void | 
send(String queueName,
    Command command,
    int deliveryMode,
    long deliveryTime)
Sends a command into a queue for processing 
 | 
void | 
sendTextMessage(String queueName,
               String text)
Sends a non-expiring  
TextMessage with average priority. | 
void | 
sendTextMessage(String queueName,
               String text,
               int deliveryMode,
               int priority,
               long timeToLive)  | 
void | 
sendTextMessage(String queueName,
               String text,
               int deliveryMode,
               int priority,
               long timeToLive,
               long deliveryTime)
Sends a  
TextMessage. | 
void | 
sendTextMessage(String queueName,
               String text,
               long deliveryTime)
Sends a non-expiring  
TextMessage with average priority. | 
void | 
setBinaryMode(boolean binaryMode)
If true, uses binary mode to send messages. 
 | 
void | 
start()
Starts the server. 
 | 
void | 
stop()
Stops this JMS server. 
 | 
public Async(String dataDirectory, boolean useLibAio, QueueConfig... queueConfigs)
dataDirectory - root directory where persistent messages are storeduseLibAio - true to use libaio, false not to use (See Artemis log statements to check if it was detected).queueConfigs - vararg of QueueConfig instances.public Async(String dataDirectory, boolean useLibAio, com.google.inject.Injector injector, QueueConfig... queueConfigs)
dataDirectory - root directory where persistent messages are storeduseLibAio - true to use libaio, false to use NIO.injector - Google Guice injector. Used to inject dependency members into commands if needed.queueConfigs - vararg of QueueConfig> instances.public void start()
public void stop()
public void setBinaryMode(boolean binaryMode)
binaryMode - true to send messages in binary mode, false to send as strings.public void configureNetty(String host, int port)
host - host to bind toport - port to listen onpublic void send(String queueName, Command command)
queueName - name of queuecommand - command instance.public void send(String queueName, Command command, Date deliveryTime)
queueName - name of queuecommand - command instance.deliveryTime - delivery time in the future. If null, or in the past, the message
                     will be delivered as usual.public void send(String queueName, Command command, int deliveryMode)
queueName - name of queuecommand - command to processdeliveryMode - delivery mode: DeliveryMode.public void send(String queueName, Command command, int deliveryMode, long deliveryTime)
queueName - name of queuecommand - command to processdeliveryMode - delivery mode: DeliveryMode.deliveryTime - delivery time in millisecondspublic void send(String queueName, Command command, int deliveryMode, int priority, long timeToLive)
queueName - name of queuecommand - command to processdeliveryMode - delivery mode: DeliveryMode.priority - priority of the message. Correct values are from 0 to 9, with higher number denoting a
                 higher priority.timeToLive - the message's lifetime (in milliseconds, where 0 is to never expire)public void send(String queueName, Command command, int deliveryMode, int priority, long timeToLive, long deliveryTime)
queueName - name of queuecommand - command to processdeliveryMode - delivery mode: DeliveryMode. 1 for non-persistent, 2 for persistent.priority - priority of the message. Correct values are from 0 to 9, with higher number denoting a
                 higher priority.timeToLive - the message's lifetime (in milliseconds, where 0 is to never expire)deliveryTime - The specified value must be a positive long corresponding to the time
                     the message must be delivered (in milliseconds). For instance, System.currentTimeMillis() + 5000
                     would be 5 seconds from now.public Command receiveCommand(String queueName)
queueName - name of queuereceiveCommand(String, long)public <T extends Command> T receiveCommand(String queueName, Class<T> type)
queueName - name of queuetype - expected class of a commandreceiveCommand(String, long)public <T extends Command> T receiveCommand(String queueName, int timeout, Class<T> type)
queueName - name of queuetimeout - timeout in milliseconds. If a command is not received during a timeout, this methods returns null.type - expected class of a commandreceiveCommand(String, long)public Command receiveCommand(String queueName, long timeout)
queueName - name of queuetimeout - timeout in milliseconds. If a command is not received during a timeout, this methods returns null.public javax.jms.Message receiveMessage(String queueName, long timeout)
queueName - name of queuetimeout - timeout in millis.public void sendTextMessage(String queueName, String text)
TextMessage with average priority.queueName - name of queuetext - body of messagepublic void sendTextMessage(String queueName, String text, long deliveryTime)
TextMessage with average priority.queueName - name of queuetext - body of messagedeliveryTime - The specified value must be a positive long corresponding to the time
                            the message must be delivered (in milliseconds). For instance, System.currentTimeMillis() + 5000
                            would be 5 seconds from now.public void sendTextMessage(String queueName, String text, int deliveryMode, int priority, long timeToLive)
public void sendTextMessage(String queueName, String text, int deliveryMode, int priority, long timeToLive, long deliveryTime)
TextMessage.queueName - name of queuetext - body of messagedeliveryMode - delivery mode: DeliveryMode.priority - priority of the message. Correct values are from 0 to 9, with higher number denoting a
                 higher priority.timeToLive - the message's lifetime (in milliseconds, where 0 is to never expire)deliveryTime - The specified value must be a positive long corresponding to the time
                      the message must be delivered (in milliseconds). For instance, System.currentTimeMillis() + 5000
                      would be 5 seconds from now.public BatchReceiver getBatchReceiver(String queueName, long timeout)
BatchReceiver to receive and process stored messages.
 This method ALWAYS works in the context of a transaction.queueName - name of queuetimeout - timeout to wait.BatchReceiver.public List<Command> getTopCommands(int count, String queueName)
count - number of commands to lookup.public List<String> getTopTextMessages(int maxSize, String queueName)
TextMessages in queue. Does not remove anything from queue. This method can be used for
 an admin tool to peek inside the queue.maxSize - max number of messages to lookup.public static byte[] getBytes(javax.jms.BytesMessage message)
                       throws javax.jms.JMSException
javax.jms.JMSExceptionpublic Map<String,Long> getMessageCounts()
public long getMessageCount(String queue)
queue - queue namepublic void resume(String queueName)
queueName - queue namepublic void pause(String queueName)
queueName - queue name.public boolean isPaused(String queueName)
queueName - queue namepublic int removeMessages(String queueName, String filter)
queueName - queue namefilter - filter selector as  in JMS specification.
               See: JMS Message Selectorspublic int removeAllMessages(String queueName)
queueName - queue name.public int moveMessages(String source, String target)
source - name of source queuetarget - name of target queuepublic boolean moveMessage(String jmsMessageId, String source, String target)
jmsMessageId - JMS message id of a message to movesource - name of source queuetarget - name of target queuepublic org.apache.activemq.artemis.core.config.Configuration getConfig()
Copyright © 2020 JavaLite. All rights reserved.