@Service(value="messageService") public class MessageServiceImpl extends Object implements MessageService
MessageService
interface.BEAN
Constructor and Description |
---|
MessageServiceImpl(org.springframework.transaction.PlatformTransactionManager transactionManager) |
Modifier and Type | Method and Description |
---|---|
Message |
findEagerMessageById(Long msgId)
Finds message by message ID with eager loading.
|
Message |
findMessageById(Long msgId)
Finds message by message ID.
|
List<Message> |
findMessagesByFilter(MessageFilter messageFilter,
long limit)
Finds list of messages that match with given filter.
|
Message |
findPartlyFailedMessage(Duration interval)
Finds ONE message in state
MsgStateEnum.PARTLY_FAILED . |
Message |
findPostponedMessage(Duration interval)
Finds ONE message in state
MsgStateEnum.POSTPONED . |
int |
getCountMessages(MsgStateEnum state,
Duration interval)
Get count of messages in specific state.
|
int |
getCountProcessingMessagesForFunnel(String funnelValue,
Duration idleInterval,
String funnelCompId)
Get count of processing messages for specified funnel value and funnel ID.
|
List<Message> |
getMessagesForGuaranteedOrderForFunnel(String funnelValue,
Duration idleInterval,
boolean excludeFailedState,
String funnelCompId)
Gets list of messages with specified funnel value for guaranteed processing order of messages
for specified funnel.
|
List<Message> |
getMessagesForGuaranteedOrderForRoute(String funnelValue,
boolean excludeFailedState)
Gets list of messages with specified funnel value for guaranteed processing order of whole routes.
|
void |
insertMessage(Message message)
Inserts new message.
|
void |
insertMessages(Collection<Message> messages)
Inserts new messages.
|
void |
setFunnelComponentId(Message msg,
String funnelCompId)
Sets funnel component identifier to specified message.
|
void |
setStateFailed(Message msg,
ErrorExtEnum errCode,
String errDesc)
Changes state of the message to
MsgStateEnum.FAILED . |
void |
setStateFailed(Message msg,
Exception ex,
ErrorExtEnum errCode,
String customData,
Map<String,Object> props)
Changes state of the message to
MsgStateEnum.FAILED . |
boolean |
setStateInQueueForLock(Message message)
Set state
MsgStateEnum.IN_QUEUE on Message under database lock. |
void |
setStateOk(Message msg,
Map<String,Object> props)
Changes state of the message to
MsgStateEnum.OK . |
void |
setStatePartlyFailed(Message msg,
Exception ex,
ErrorExtEnum errCode,
String customData,
Map<String,Object> props)
Changes state of the message to
MsgStateEnum.PARTLY_FAILED . |
void |
setStatePartlyFailedWithoutError(Message msg)
Changes state of the message to
MsgStateEnum.PARTLY_FAILED but without increasing error count. |
void |
setStatePostponed(Message msg)
Changes state of the message to
MsgStateEnum.POSTPONED . |
void |
setStateProcessing(Message msg)
Changes state of the message to
MsgStateEnum.PROCESSING . |
boolean |
setStateProcessingForLock(Message message)
Set state
MsgStateEnum.PROCESSING on Message under database lock. |
void |
setStateWaiting(Message msg)
Changes state of the message to
MsgStateEnum.WAITING - only if the message hasn't been already processed. |
void |
setStateWaitingForResponse(Message msg)
Changes state of the message to
MsgStateEnum.WAITING_FOR_RES . |
@Autowired public MessageServiceImpl(org.springframework.transaction.PlatformTransactionManager transactionManager)
@Transactional public void insertMessage(Message message)
MessageService
insertMessage
in interface MessageService
message
- message that will be saved@Transactional public void insertMessages(Collection<Message> messages)
MessageService
insertMessages
in interface MessageService
messages
- the collection of message@Transactional public void setStateOk(Message msg, Map<String,Object> props)
MessageService
MsgStateEnum.OK
.
If message is child message then method checks if all child messages of the parent message aren't processed.
setStateOk
in interface MessageService
msg
- the messageprops
- the exchange properties [property name; property value]@Transactional public void setStateProcessing(Message msg)
MessageService
MsgStateEnum.PROCESSING
.setStateProcessing
in interface MessageService
msg
- the message@Transactional public void setStateWaiting(Message msg)
MessageService
MsgStateEnum.WAITING
- only if the message hasn't been already processed.setStateWaiting
in interface MessageService
msg
- the message@Transactional public void setStateWaitingForResponse(Message msg)
MessageService
MsgStateEnum.WAITING_FOR_RES
.setStateWaitingForResponse
in interface MessageService
msg
- the message@Transactional public void setStatePartlyFailedWithoutError(Message msg)
MessageService
MsgStateEnum.PARTLY_FAILED
but without increasing error count.setStatePartlyFailedWithoutError
in interface MessageService
msg
- the message@Transactional public void setStatePartlyFailed(Message msg, Exception ex, ErrorExtEnum errCode, String customData, Map<String,Object> props)
MessageService
MsgStateEnum.PARTLY_FAILED
.setStatePartlyFailed
in interface MessageService
msg
- the messageex
- the exceptionerrCode
- the error code that can be explicitly defined if neededcustomData
- the custom dataprops
- the exchange properties [property name; property value]@Transactional public void setStateFailed(Message msg, Exception ex, ErrorExtEnum errCode, String customData, Map<String,Object> props)
MessageService
MsgStateEnum.FAILED
.
If message is child message then parent message will be marked as failed too.
setStateFailed
in interface MessageService
msg
- the messageex
- the exceptionerrCode
- the error code that can be explicitly defined if neededcustomData
- the custom dataprops
- the exchange properties [property name; property value]@Transactional public void setStateFailed(Message msg, ErrorExtEnum errCode, String errDesc)
MessageService
MsgStateEnum.FAILED
.
If message is child message then parent message will be marked as failed too.
setStateFailed
in interface MessageService
msg
- the messageerrCode
- the error codeerrDesc
- the error descriptionpublic boolean setStateInQueueForLock(Message message)
MessageService
MsgStateEnum.IN_QUEUE
on Message
under database lock.setStateInQueueForLock
in interface MessageService
message
- message on which will be state changedtrue
- state was successfully changed, false
- otherwisepublic boolean setStateProcessingForLock(Message message)
MessageService
MsgStateEnum.PROCESSING
on Message
under database lock.setStateProcessingForLock
in interface MessageService
message
- message on which will be state changedtrue
- state was successfully changed, false
- otherwise@Nullable public Message findMessageById(Long msgId)
MessageService
findMessageById
in interface MessageService
msgId
- the message IDnull
if not found message with specified ID@Nullable public Message findEagerMessageById(Long msgId)
MessageService
findEagerMessageById
in interface MessageService
msgId
- the message IDnull
if not found message with specified IDpublic List<Message> findMessagesByFilter(MessageFilter messageFilter, long limit)
MessageService
findMessagesByFilter
in interface MessageService
messageFilter
- the filter.limit
- the limit of message count.empty list
if none were found.public int getCountMessages(MsgStateEnum state, Duration interval)
MessageService
getCountMessages
in interface MessageService
state
- State of messageinterval
- searching messages updated after this interval (in seconds)public int getCountProcessingMessagesForFunnel(String funnelValue, Duration idleInterval, String funnelCompId)
MessageService
getCountProcessingMessagesForFunnel
in interface MessageService
funnelValue
- the funnel valueidleInterval
- interval (in seconds) that determines how long can be message processingfunnelCompId
- the funnel component IDpublic List<Message> getMessagesForGuaranteedOrderForRoute(String funnelValue, boolean excludeFailedState)
MessageService
getMessagesForGuaranteedOrderForRoute
in interface MessageService
funnelValue
- the funnel valueexcludeFailedState
- FAILED
state is used by default;
use true
if you want to exclude FAILED statemessage timestamp
public List<Message> getMessagesForGuaranteedOrderForFunnel(String funnelValue, Duration idleInterval, boolean excludeFailedState, String funnelCompId)
MessageService
getMessagesForGuaranteedOrderForFunnel
in interface MessageService
funnelValue
- the funnel valueidleInterval
- interval (in seconds) that determines how long can message be processingexcludeFailedState
- FAILED
state is used by default;
use true
if you want to exclude FAILED statefunnelCompId
- the funnel component IDmessage timestamp
@Transactional public void setStatePostponed(Message msg)
MessageService
MsgStateEnum.POSTPONED
.setStatePostponed
in interface MessageService
msg
- the message@Transactional public void setFunnelComponentId(Message msg, String funnelCompId)
MessageService
setFunnelComponentId
in interface MessageService
msg
- the messagefunnelCompId
- the funnel component ID@Nullable @Transactional public Message findPostponedMessage(Duration interval)
MessageService
MsgStateEnum.POSTPONED
.findPostponedMessage
in interface MessageService
interval
- Interval (in seconds) after that can be postponed message processed again@Nullable @Transactional public Message findPartlyFailedMessage(Duration interval)
MessageService
MsgStateEnum.PARTLY_FAILED
.findPartlyFailedMessage
in interface MessageService
interval
- Interval (in seconds) between two tries of partly failed messages.Copyright © 2018 Pivotal Software, Inc.. All rights reserved.