Common Messaging endpoints

From Gcube Wiki
Jump to: navigation, search


The Messaging Endpoints Libary is a simple library that has been developed in order to harvest and make available to clients the Message broker instances addresses that are published on the gCube Information System

The library expects each Message Broker instance to be published on the IS as a gCube Runtime Resource having the following model:


 <ID></ID>
    
   <Type>RuntimeResource</Type>
    
   <Scopes>
        
      <Scope>/xxx/xxxxx</Scope>
    
   </Scopes>
    
   <Profile>
        
      <Category>Service</Category>
        
      <Name>MessageBroker</Name>
        
      <Description />
        
      <Platform>
            
         <Name>ActiveMQ</Name>
            
         <Version>5</Version>
            
         <MinorVersion>5</MinorVersion>
            
         <RevisionVersion>1</RevisionVersion>
            
         <BuildVersion>1</BuildVersion>
        
      </Platform>
        
      <RunTime>
            
         <HostedOn>hostname</HostedOn>
            
         <GHN UniqueID="" />
            
         <Status>READY</Status>
        
      </RunTime>
        
      <AccessPoint>
            
         <Description>openwire interface</Description>
            
         <Interface>
                
            <Endpoint EntryName="openwire">tcp://hostname:port</Endpoint>
            
         </Interface>
            
         <AccessData>
                
            <Username />
                
            <Password />
            
         </AccessData>
        
      </AccessPoint>
    
   </Profile>


The current implementation is using ONLY the openwire broker interface, but in future release if requested we can also add other interface addresses (.e.g STOMP) and give the possibility to retrieve them trough the library.


The Library can be instantiated by clients to retrieve MessageBroker addresses as follows:


 ScopeProvider.instance.set(<scope>);
 
 ScheduledRetriever retriever = BrokerEndpoints.getRetriever(<waiting_time>, <refresh_period>);
  • waiting_time specifies the waiting time in seconds ( the MAX waiting time for the library to try to contact the IS and get the profiles)
  • refresh_period specifies the refreshing time for the profiles

each ScheduledRetriever is static within the JVM, so only one ScheduledRetriever is instantiated per scope.

Once the retriever is instantiated it can be also retrieved as follows

 ScopeProvider.instance.set(<scope>);
 
 ScheduledRetriever retriever = BrokerEndpoints.getRetriever();


The addresses provided are of two types:

  • JMS failover endpoint returned as : failover://(address1, ..., addressn), which can be used JMS producer side to automacally and transparently select one of the available brokers ( with transparent failover support). The failover address can be is available from the ScheduledRetriever as follows:
 retriever.getFailoverEndpoint();
  • Broker addresses which are used by JMS Consumers to connect to brokers. In this case each Consumer should connect to each available broker on the infra.
 retriever.getEndpoints();