Package com.attivio.sdk.esb
Class MessageDomainManager
- java.lang.Object
-
- com.attivio.sdk.esb.MessageDomainManager
-
public final class MessageDomainManager extends java.lang.Object
Singleton which manages the list of queues and associated message domains. Provides methods for acquiring and releasing Semaphores associated with a domain so that domain limits will be maintained. User code should not directly interact with this class.
-
-
Field Summary
Fields Modifier and Type Field Description static MessageDomainManager
instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquire(java.lang.String componentName, java.lang.String domain)
Acquires the semaphore associated with the componentName and domain (if any).java.lang.String
addDomainSuffix(java.lang.String domain, java.lang.String uri)
Changes the uri to a domain-specific version if domain is non-null
.void
clear()
Clears the internal data structures.void
createDomainSemaphore(MessageDomain md, java.lang.String componentName)
Creates the resource semaphores that will be used when messages are received for the componentjava.lang.String
getMessageDomain(PlatformMessage msg)
Domains are always non-blankint
messageDomainMaximum(java.lang.String domain)
Determines the maximum number of messages that could be processed by this domain at a single time.java.lang.String[]
parseUri(java.lang.String uri)
Parses the uri into the domain for the message and the uri without the domain suffix.void
release(java.lang.String componentName, java.lang.String domain)
Releases the semaphore associated with the componentName and domain (if any).void
setMessageDomain(PlatformMessage msg, java.lang.String domain)
Sets the domain for the message.java.lang.String
transformForDomain(PlatformMessage msg, java.lang.String uri)
Transformsuri
so that it points to the domain-specific uri for the domain the message is in.
-
-
-
Field Detail
-
instance
public static final MessageDomainManager instance
-
-
Method Detail
-
clear
public void clear()
Clears the internal data structures. Provided for tests. Other use is not supported.
-
createDomainSemaphore
public void createDomainSemaphore(MessageDomain md, java.lang.String componentName)
Creates the resource semaphores that will be used when messages are received for the component- Parameters:
md
-componentName
-
-
transformForDomain
public java.lang.String transformForDomain(PlatformMessage msg, java.lang.String uri)
Transformsuri
so that it points to the domain-specific uri for the domain the message is in.- Parameters:
msg
-uri
-- Returns:
- the
uri
modified so it points to the message's domain
-
addDomainSuffix
public java.lang.String addDomainSuffix(java.lang.String domain, java.lang.String uri)
Changes the uri to a domain-specific version if domain is non-null
. Does not check to see if the uri has already been modified in this way.- Parameters:
domain
-uri
-- Returns:
- the updated domain
-
getMessageDomain
public java.lang.String getMessageDomain(PlatformMessage msg)
Domains are always non-blank- Parameters:
msg
-- Returns:
- domain associated with message or null if none
-
setMessageDomain
public void setMessageDomain(PlatformMessage msg, java.lang.String domain)
Sets the domain for the message. A blank domain will result innull
when callinggetMessageDomain(PlatformMessage)
- Parameters:
msg
-domain
-
-
messageDomainMaximum
public int messageDomainMaximum(java.lang.String domain)
Determines the maximum number of messages that could be processed by this domain at a single time.- Parameters:
domain
-- Returns:
- the maximum number of simultaneous messages for this domain or 0 if no semaphore exists
-
parseUri
public java.lang.String[] parseUri(java.lang.String uri)
Parses the uri into the domain for the message and the uri without the domain suffix. The uri will always be in the second element of the returned array. If the input uri contained a message domain suffix it will be placed in the first element of the returned array.- Parameters:
uri
-- Returns:
-
acquire
public void acquire(java.lang.String componentName, java.lang.String domain)
Acquires the semaphore associated with the componentName and domain (if any). This method will not re-acquire the semaphore if the current thread already has acquired it. The expectation is that calls toacquire
will be paired with matching calls torelease(String, String)
(generally in a finally block). Failure to do so will result in deadlocks.- Parameters:
componentName
-domain
-
-
release
public void release(java.lang.String componentName, java.lang.String domain)
Releases the semaphore associated with the componentName and domain (if any). If the calling thread acquired the semaphore via an earlier call with a different componentName, the semaphore will not be released. This provides a type of re-entrancy based on component name.- Parameters:
componentName
-domain
-
-
-