Class MultiRegionTransport<S,​R>

  • All Implemented Interfaces:
    ClientTransport<S>, SelfManagedTransport<S,​R>, Transport<S,​R>

    public abstract class MultiRegionTransport<S,​R>
    extends java.lang.Object
    implements SelfManagedTransport<S,​R>
    A SelfManagedTransport that is used explicitly for sending messages from one region to another. The inclusion of this transport in the project configuration signifies that multi-region replication should be enabled on that project

    Subclasses SHOULD NOT override sendMessage(PlatformMessage, Object) or dispatchMessage(PlatformMessage, Object), but only dispatchMessage(MessageList, Object, MessageListTransportCallback)

    Subclasses should use the emitMessage(MessageList, URI) on this class to emit messages from its receiver to the uri that was given to create the receiver. Messages should remain available for re-emission (in case of an unexpected shutdown) until the method release(PlatformMessage) is called for the message. If this practice is not followed, multi-region replication cannot be guaranteed

    The scheme of this transport is fixed and SHOULD NOT BE OVEWRITTEN. This transport cannot do synchronous messaging and as such will have to support sending with a callback hook for completion. This transport is also obliged to keep track of the number of messages it has sent and received by destination.

    Serialization must be handled by implementers of this class. There is an XMLSerializer utility singleton object available to sdk users that can serialize messages to xml - this should work well as a default if the implementer does not particularly care how serialization is performed

    • Field Detail

      • LOG

        public static final org.slf4j.Logger LOG
      • REGION_TRANSFER_PROPERTY

        public static final java.lang.String REGION_TRANSFER_PROPERTY
        Property on PlatformMessages indicating where this message should be sent - corresponds to a messages data group
        See Also:
        Constant Field Values
      • CLIENT_DEPENDENCY_PROP

        public static final java.lang.String CLIENT_DEPENDENCY_PROP
        property on PlatformMessages indicating that the message depends on the completion of a previous client.
        See Also:
        Constant Field Values
      • REGION_TRANSFER_NAME

        public static final java.lang.String REGION_TRANSFER_NAME
        property on PlatformMessages indicating the client name associated with a message transferred from another region.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MultiRegionTransport

        public MultiRegionTransport()
    • Method Detail

      • isMaster

        public boolean isMaster()
      • setMaster

        public void setMaster​(boolean master)
      • getBlackListedDataGroups

        public java.util.Set<java.lang.String> getBlackListedDataGroups()
      • setBlackListedDataGroups

        public void setBlackListedDataGroups​(java.util.Set<java.lang.String> blackListedDataGroups)
      • getBlackListedZones

        public java.util.Set<java.lang.String> getBlackListedZones()
      • setBlackListedZones

        public void setBlackListedZones​(java.util.Set<java.lang.String> blackListedZones)
      • getProtocol

        public java.lang.String getProtocol()
        Get the String protocol that this transports implements.

        This will register this protocol with Attivio for message delivery.

        For example if this method returned "foo" then URI's of the form:

         foo://someUriSyntax:8000/goes?here
         
        would be processed using this transport. This must return a constant value and must return that value as soon as the object is constructed as the value is registered with the platform and can not be changed once registered.
        Specified by:
        getProtocol in interface ClientTransport<S>
      • sendMessage

        public PlatformMessage sendMessage​(PlatformMessage msg,
                                           S sender)
                                    throws TransportException
        Synchronously send a message via the provided sender.
        Specified by:
        sendMessage in interface ClientTransport<S>
        Parameters:
        msg - the message to send.
        sender - the sender that was chosen based on the URI that the message must be sent to

        This method can block as long as is required to send the message including allowing time for the receiver to free up resources.

        Throws:
        TransportException
      • emitMessage

        public void emitMessage​(MessageList messageList,
                                java.net.URI uri)
                         throws TransportException
        Emit a message to the Attivio internal routing and processing system for multi-region replication messages. This method should be called at least once for all messages received by this transport
        Throws:
        TransportException
      • release

        public abstract void release​(PlatformMessage msg)
        Release a message from potential re-emission

        This method will be invoked on this transport when the message received herefrom has made it to a stage that can guarantee its resilience thus the resilience provided by this transport is no longer needed

      • messagesSentPerDestination

        public abstract java.util.Map<java.lang.String,​java.lang.Long> messagesSentPerDestination()
        Retrieve the total messages sent per destination.

        Messages in this case mean individual messages within the MessageList passed in via dispatchMessage(MessageList, Object, MessageListTransportCallback). The number of messages in a MessageList can be obtained using ArrayList.size()

        Returns:
        Map total messages sent per String destination
      • messagesReceivedPerDestination

        public abstract java.util.Map<java.lang.String,​java.lang.Long> messagesReceivedPerDestination()
        Retrieve the total messages received per destination.

        Messages in this case mean individual messages within the MessageList passed in via dispatchMessage(MessageList, Object, MessageListTransportCallback) and subsequently received by this transport. The number of messages in a MessageList can be obtained using ArrayList.size()

        Returns:
        Map total messages received per String destination