public class JDBCMessageStore extends AbstractMessageStore
Modifier and Type | Field and Description |
---|---|
protected static String |
MESSAGE_COLUMN_NAME |
description, fileName, lock, messageStoreMBean, messageStoreObservers, name, parameterKeyMap, parameters, sequence, synapseConfiguration, synapseEnvironment
Constructor and Description |
---|
JDBCMessageStore() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Delete all entries from table
|
protected MessageContext |
deserializeMessage(byte[] msgObj)
Will convert the byte[] message to store-able message.
|
void |
destroy()
Destroy Resources allocated
|
MessageContext |
get(int position)
Get the message at given position
Only can be done with MYSQL, and no use-case in current implementation
|
MessageContext |
get(String msgId)
Return the first element with given msg_id
|
List<MessageContext> |
getAll()
Get all messages in the table
|
MessageConsumer |
getConsumer()
Returns a Message Consumer for this message store.
|
protected JDBCConfiguration |
getJdbcConfiguration() |
protected List<Map> |
getProcessedRows(Statement statement)
Will return the list of processed message rows.
|
MessageProducer |
getProducer()
Returns a Message Producer for this message store.
|
protected Statement |
getStoreMessageStatement(MessageContext messageContext,
Long sequenceId)
Generates the statement to store message in database.
|
void |
init(SynapseEnvironment synapseEnvironment)
Initializes the JDBC Message Store
|
protected List<Map> |
messageContentResultSet(ResultSet resultSet,
String statement)
Return the messages corresponding to the provided statement.
|
MessageContext |
peek()
Select and return the first element in current table
|
MessageContext |
remove()
Removes the first element from table
|
MessageContext |
remove(String msgId)
Remove the message with given msg_id
|
protected List<Statement> |
removeMessageStatement(String msgId)
Statement to remove the message once a response is received.
|
byte[] |
serialize(Object obj) |
void |
setParameters(Map<String,Object> parameters)
Set JDBC store parameters
|
int |
size()
Return number of messages in the store
|
boolean |
store(MessageContext messageContext)
Add a message to the end of the table.
|
addParameter, addParameterKey, dequeued, difference, enqueued, getArtifactContainerName, getDescription, getFileName, getLock, getName, getParameterKey, getParameterKeyMap, getParameters, getType, isEdited, nextConsumerId, nextProducerId, notifyMessageAddition, notifyMessageRemoval, registerObserver, setArtifactContainerName, setDescription, setFileName, setIsEdited, setName, unregisterObserver
protected static final String MESSAGE_COLUMN_NAME
public void init(SynapseEnvironment synapseEnvironment)
init
in interface ManagedLifecycle
init
in class AbstractMessageStore
synapseEnvironment
- SynapseEnvironment for the storeprotected JDBCConfiguration getJdbcConfiguration()
public MessageProducer getProducer()
MessageStore
MessageStore.getProducer()
public MessageConsumer getConsumer()
MessageStore
MessageStore.getConsumer()
public void setParameters(Map<String,Object> parameters)
setParameters
in interface MessageStore
setParameters
in class AbstractMessageStore
parameters
- - List of parameters to setprotected List<Map> getProcessedRows(Statement statement)
statement
- the statement executed in the DB.protected MessageContext deserializeMessage(byte[] msgObj)
msgObj
- serialized message read from the database.public byte[] serialize(Object obj) throws IOException
IOException
public void destroy()
destroy
in interface ManagedLifecycle
destroy
in class AbstractMessageStore
public boolean store(MessageContext messageContext) throws SynapseException
messageContext
- message to insertSynapseException
protected Statement getStoreMessageStatement(MessageContext messageContext, Long sequenceId) throws StoreException
Generates the statement to store message in database.
If the sequence id is specified the corresponding sequence id will be stored, sequence id will be specified if re-sequence message store is being used. In other times this value will be null.
messageContext
- the content of the message.sequenceId
- the sequence id of the message (optional).StoreException
- at an event there's an exception when generating the statement.ResequenceMessageStore
public MessageContext peek() throws SynapseException
SynapseException
public MessageContext remove() throws NoSuchElementException
NoSuchElementException
- if there was not element to be removed.public MessageContext remove(String msgId) throws SynapseException
msgId
- - message IDSynapseException
protected List<Statement> removeMessageStatement(String msgId)
msgId
- message id of the statement which should be removed.public void clear()
public MessageContext get(int position)
position
- - position of the message , starting value is 0public List<MessageContext> getAll()
public MessageContext get(String msgId)
msgId
- - Message IDprotected List<Map> messageContentResultSet(ResultSet resultSet, String statement) throws SQLException
Return the messages corresponding to the provided statement.
resultSet
- the result-set obtained from the statement.statement
- the SQL statement results are obtained for.SQLException
- during an error encountered when accessing the database.public int size()
size
in interface MessageStore
size
in class AbstractMessageStore
Copyright © 2005–2018 Apache Software Foundation. All rights reserved.