Package com.attivio.util
Class MessageUtils
- java.lang.Object
-
- com.attivio.util.MessageUtils
-
public class MessageUtils extends java.lang.Object
Contains utilities for accessing the Enterprise Service Bus functionality.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AVM_PROTOCOL
static int
DEFAULT_ENDPOINT_RETRY_MAX
Default forENDPOINT_RETRY_MAX_PROPNAME
.static long
DEFAULT_ENDPOINT_RETRY_WAIT_TIME
Default forENDPOINT_RETRY_WAIT_TIME_PROPNAME
.static java.lang.String
ENDPOINT_RETRY_MAX_PROPNAME
the property name for the maximum number of retries, defaults to -1 meaning no limit.static java.lang.String
ENDPOINT_RETRY_WAIT_TIME_PROPNAME
the property name for the time to wait between retries, defaults to 1000.static java.lang.String
MAVM_PROTOCOL
static java.lang.String
MAVM_TRIGGER
static java.lang.String
MESSAGELOG_PREFIX
Prefix for all message detail logging logger names.
-
Constructor Summary
Constructors Constructor Description MessageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
dispatch(PlatformMessage msg, java.lang.String endpointName)
Sends the message to theendpointName
asynchronously.static java.lang.String
getDefaultTransportProtocol()
static int
getMaxRetries()
static AttivioLogger
getMessageLogger(java.lang.String workflowName, java.lang.String componentName)
static java.lang.String
getNodeURI(java.lang.String name)
Returns the URI for the provided name using the configured "node://" implementation for the protocol if no protocol already set.static long
getNumberOfRetries()
static java.lang.String
getQueueURI(java.lang.String name, java.lang.String protocol)
Returns the URI for the provided name using the configured vm queue implementation for the protocol if no protocol already set.static long
getRetryWaitTime()
static boolean
hasVisitedComponent(PlatformMessage msg, java.lang.String componentName)
static boolean
isDefaultTransportQueuePresent(java.lang.String name)
Call methodusesDefaultTransport(String)
first to validate uri to avoid IllegalArgumentExceptionstatic PlatformMessage
rawSend(PlatformMessage msg, java.lang.String endpointName, boolean synchronous)
Sends a message to theendpointName
.static PlatformMessage
rawSendWithRetry(PlatformMessage msg, java.lang.String endpointName, boolean synchronous)
Sends a message to theendpointName
.static PlatformMessage
rawSendWithRetry(PlatformMessage msg, java.lang.String endpointName, boolean synchronous, int maxRetries, long retryWaitTime)
Method for sending a message, retrying on transport error.static java.lang.String
removeProtocolPrefix(java.lang.String name)
static PlatformMessage
send(PlatformMessage msg, java.lang.String endpointName)
Sends a message to theendpointName
synchronously.static PlatformMessage
send(PlatformMessage msg, java.lang.String endpointName, boolean allowNullResponse)
Sends a message to theendpointName
synchronously.static PlatformMessage
send(PlatformMessage msg, java.lang.String endpointName, boolean allowNullResponse, int maxRetries, long retryWaitTime)
Sends a message toendpointName
synchronously, retrying on transport error.static PlatformMessage
send(PlatformMessage msg, java.lang.String endpointName, int maxRetries, long retryWaitTime)
Sends a message toendpointName
synchronously, retrying on transport error.static void
setDefaultTransportProtocol(java.lang.String protocol)
Sets the default protocol to be prepended to uris with no specified protocol.static boolean
usesAieTransportProtocol(java.lang.String workflowName)
static boolean
usesDefaultTransport(java.lang.String uri)
-
-
-
Field Detail
-
MESSAGELOG_PREFIX
public static final java.lang.String MESSAGELOG_PREFIX
Prefix for all message detail logging logger names. UsegetMessageLogger(String, String)
to get the logger for a specific component.- See Also:
- Constant Field Values
-
ENDPOINT_RETRY_MAX_PROPNAME
public static final java.lang.String ENDPOINT_RETRY_MAX_PROPNAME
the property name for the maximum number of retries, defaults to -1 meaning no limit.- See Also:
- Constant Field Values
-
ENDPOINT_RETRY_WAIT_TIME_PROPNAME
public static final java.lang.String ENDPOINT_RETRY_WAIT_TIME_PROPNAME
the property name for the time to wait between retries, defaults to 1000. Units are in milliseconds.- See Also:
- Constant Field Values
-
DEFAULT_ENDPOINT_RETRY_WAIT_TIME
public static final long DEFAULT_ENDPOINT_RETRY_WAIT_TIME
Default forENDPOINT_RETRY_WAIT_TIME_PROPNAME
.- See Also:
- Constant Field Values
-
DEFAULT_ENDPOINT_RETRY_MAX
public static final int DEFAULT_ENDPOINT_RETRY_MAX
Default forENDPOINT_RETRY_MAX_PROPNAME
.- See Also:
- Constant Field Values
-
MAVM_PROTOCOL
public static final java.lang.String MAVM_PROTOCOL
- See Also:
- Constant Field Values
-
AVM_PROTOCOL
public static final java.lang.String AVM_PROTOCOL
- See Also:
- Constant Field Values
-
MAVM_TRIGGER
public static final java.lang.String MAVM_TRIGGER
- See Also:
- Constant Field Values
-
-
Method Detail
-
dispatch
public static void dispatch(PlatformMessage msg, java.lang.String endpointName) throws AttivioException
Sends the message to theendpointName
asynchronously.- Parameters:
msg
- the message to sendendpointName
- a local avm queue name or a valid URI- Throws:
AttivioException
- if endpointName is not a valid endpoint or if an exception is encountered while delivering the message
-
send
public static PlatformMessage send(PlatformMessage msg, java.lang.String endpointName) throws AttivioException
Sends a message to theendpointName
synchronously.- Parameters:
msg
- the message to sendendpointName
- a local avm queue name or a valid uri.- Returns:
- the platform message
- Throws:
AttivioException
- if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
-
send
public static PlatformMessage send(PlatformMessage msg, java.lang.String endpointName, boolean allowNullResponse) throws AttivioException
Sends a message to theendpointName
synchronously.- Parameters:
msg
- the message to sendendpointName
- a local avm queue name or a valid uri.allowNullResponse
- if false, exception will be thrown if a null response is received- Returns:
- the platform message
- Throws:
AttivioException
- if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
-
send
public static PlatformMessage send(PlatformMessage msg, java.lang.String endpointName, int maxRetries, long retryWaitTime) throws AttivioException
Sends a message toendpointName
synchronously, retrying on transport error.- Parameters:
msg
- the message to sendendpointName
- a local avm queue name or a valid uri.maxRetries
- maximum number of times to resend (unlimited = -1)retryWaitTime
- how long to wait before retrying (in milliseconds)- Returns:
- the platform message returned in response
- Throws:
AttivioException
- if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
-
send
public static PlatformMessage send(PlatformMessage msg, java.lang.String endpointName, boolean allowNullResponse, int maxRetries, long retryWaitTime) throws AttivioException
Sends a message toendpointName
synchronously, retrying on transport error.- Parameters:
msg
- the message to sendendpointName
- a local avm queue name or a valid uri.maxRetries
- maximum number of times to resend (unlimited = -1)retryWaitTime
- how long to wait before retrying (in milliseconds)- Returns:
- the platform message returned in response
- Throws:
AttivioException
- if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
-
rawSend
public static PlatformMessage rawSend(PlatformMessage msg, java.lang.String endpointName, boolean synchronous) throws AttivioException
Sends a message to theendpointName
. Does not check for null orExceptionResponse
responses.- Parameters:
msg
- the message to sendendpointName
- a local avm queue name or a valid uri.synchronous
- indicates whether or not message should be sent synchronously- Returns:
- the platform message
- Throws:
AttivioException
- if endpointName is not a valid endpoint or if the result is not an PlatformMessage
-
getNumberOfRetries
public static long getNumberOfRetries()
- Returns:
- the number of times messages have been retried.
-
getRetryWaitTime
public static long getRetryWaitTime()
- Returns:
- the number of ms
rawSendWithRetry(com.attivio.sdk.esb.PlatformMessage, java.lang.String, boolean)
will wait between retries
-
getMaxRetries
public static int getMaxRetries()
- Returns:
- the maximum number of retry attempts
rawSendWithRetry(com.attivio.sdk.esb.PlatformMessage, java.lang.String, boolean)
will make.
-
rawSendWithRetry
public static PlatformMessage rawSendWithRetry(PlatformMessage msg, java.lang.String endpointName, boolean synchronous) throws AttivioException
Sends a message to theendpointName
. Does not check for null orExceptionResponse
responses.If it is not possible to connect to the intended destination, the connection will be retried the number of times specified by the
ENDPOINT_RETRY_MAX_PROPNAME
property. If set to -1, there will be no limit to the number of retries. The time in between each retry is controlled by theENDPOINT_RETRY_WAIT_TIME_PROPNAME
property.- Parameters:
msg
- the message to sendendpointName
- a local avm queue name or a valid uri.synchronous
- indicates whether or not message should be sent synchronously- Returns:
- the platform message
- Throws:
AttivioException
- if endpointName is not a valid endpoint or if the result is not an PlatformMessage
-
rawSendWithRetry
public static PlatformMessage rawSendWithRetry(PlatformMessage msg, java.lang.String endpointName, boolean synchronous, int maxRetries, long retryWaitTime) throws AttivioException
Method for sending a message, retrying on transport error.- Throws:
AttivioException
-
hasVisitedComponent
public static boolean hasVisitedComponent(PlatformMessage msg, java.lang.String componentName)
- Parameters:
msg
-componentName
-- Returns:
- true if
msg
has ever been processed by the component.
-
getQueueURI
public static java.lang.String getQueueURI(java.lang.String name, java.lang.String protocol)
Returns the URI for the provided name using the configured vm queue implementation for the protocol if no protocol already set.- Parameters:
name
- the name- Returns:
- the URI
-
removeProtocolPrefix
public static java.lang.String removeProtocolPrefix(java.lang.String name)
-
getNodeURI
public static java.lang.String getNodeURI(java.lang.String name)
Returns the URI for the provided name using the configured "node://" implementation for the protocol if no protocol already set.- Parameters:
name
- the name- Returns:
- the URI
-
isDefaultTransportQueuePresent
public static boolean isDefaultTransportQueuePresent(java.lang.String name)
Call methodusesDefaultTransport(String)
first to validate uri to avoid IllegalArgumentException- Parameters:
name
-- Returns:
- true if the local queue is present on this node
- Throws:
java.lang.IllegalArgumentException
- if the uri is not a local queue
-
usesDefaultTransport
public static boolean usesDefaultTransport(java.lang.String uri)
- Parameters:
uri
-- Returns:
- true if the destination uri will use the default transport protocol
-
setDefaultTransportProtocol
public static void setDefaultTransportProtocol(java.lang.String protocol)
Sets the default protocol to be prepended to uris with no specified protocol.- Parameters:
protocol
-
-
getDefaultTransportProtocol
public static java.lang.String getDefaultTransportProtocol()
-
usesAieTransportProtocol
public static boolean usesAieTransportProtocol(java.lang.String workflowName)
- Parameters:
workflowName
-- Returns:
- true if this workflow name uses the default transport protocol or node:
-
getMessageLogger
public static AttivioLogger getMessageLogger(java.lang.String workflowName, java.lang.String componentName)
- Parameters:
componentName
-- Returns:
- a logger used for logging internal message processing events
-
-