public class Async extends Object
EmbeddedJMS
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.
|
static byte[] |
getBytes(javax.jms.BytesMessage message) |
org.apache.activemq.artemis.core.config.Configuration |
getConfig()
Get additional server configuration.
|
org.apache.activemq.artemis.jms.server.config.JMSConfiguration |
getJmsConfig()
Get additional JMS 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.
|
boolean |
isPaused(String queueName) |
boolean |
moveMessage(String messageId,
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.
|
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,
int deliveryMode)
Sends a command into a queue for processing
|
void |
send(String queueName,
Command command,
int deliveryMode,
int priority,
int timeToLive)
Sends a command into a queue for processing
|
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 if not installed.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 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, int deliveryMode)
queueName
- name of queuecommand
- command to processdeliveryMode
- delivery mode: DeliveryMode
.public void send(String queueName, Command command, int deliveryMode, int priority, int 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 start()
public void stop()
public Command receiveCommand(String queueName)
queueName
- name of queue#receiveCommand(String, long)}
public <T extends Command> T receiveCommand(String queueName, Class<T> type)
queueName
- name of queuetype
- expected class of a command#receiveCommand(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 command#receiveCommand(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 List<Command> getTopCommands(int count, String queueName)
count
- number of commands to lookup.public static byte[] getBytes(javax.jms.BytesMessage message) throws javax.jms.JMSException
javax.jms.JMSException
public 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 messageId, String source, String target)
messageId
- JMS message id of a message to movesource
- name of source queuetarget
- name of target queuepublic org.apache.activemq.artemis.jms.server.config.JMSConfiguration getJmsConfig()
public org.apache.activemq.artemis.core.config.Configuration getConfig()
Copyright © 2016. All rights reserved.