You can publish Services on the service bus either by configuring them directly in the application's KSBConfigurer module definition, or by using the KSBExporter bean. In either case, a ServiceDefinition is provided that specifies various bus settings and the target Spring bean.
A service can be exposed by explicitly registering it with the KSBConfigurer module, services property:
<bean id="rice" class="org.kuali.rice.config.RiceConfigurer"> <property name="messageEntity" value="MYAPP" /> <property name="dataSource" ref="dataSource" /> <property name="transactionManager" ref="atomikosTransactionManager" /> <property name="userTransaction" ref="atomikosUserTransaction" /> <property name="rootConfig" ref="config" /> <property name="modules"> <list> <bean class="org.kuali.rice.ksb.messaging.config.KSBConfigurer"> <property name="serviceServletUrl" value="${base url}/MYAPP/remoting/" /> ... <property name="services"> <list> <bean class="edu.iu.uis.eden.messaging.SOAPServiceDefinition"> <property name="service"> <ref bean="mySoapService" /> </property> <property name="serviceInterface"><value>org.myapp.services.MySOAPService</value></property> <property name="localServiceName" value="myExposedSoapService" /> </bean> <bean class="edu.iu.uis.eden.messaging.JavaServiceDefinition"> <property name="service"> <ref bean="myJavaService" /> </property> <property name="serviceInterface"> <value>org.myapp.services.MyJavaService</value></property> <property name="localServiceName" value="myExposedJavaService" /> </bean>
You can also publish Services in any context using the KSBExporter bean. Note that KSBConfigurer must also be defined in your RiceConfigurer.
<bean class="edu.iu.uis.eden.messaging.KSBExporter"> <property name="serviceDefinition"> <bean class="edu.iu.uis.eden.messaging.JavaServiceDefinition"> <property name="service"> <ref bean="myJavaService" /> </property> <property name="serviceInterface"> <value>org.myapp.services.MyJavaService</value> </property> <property name="localServiceName" value="myExposedJavaService" /> </bean> </property> </bean> <bean class="edu.iu.uis.eden.messaging.KSBExporter"> <property name="serviceDefinition"> <bean class="edu.iu.uis.eden.messaging.SOAPServiceDefinition"> <property name="service"> <ref bean="mySoapService" /> </property> <property name="serviceInterface"> <value>org.myapp.services.MySOAPService</value> </property> <property name="localServiceName" value="myExposedSoapService" /> </bean> </property> </bean>
ServiceDefinitions define how the service is published to the KSB. Currently KSB supports three types of services: Java RPC (via serialization over HTTP), SOAP, and JMS.
All service definitions support these properties:
Table 6.3. ServiceDefinition Properties
Property | Description | Required |
---|---|---|
Service | The reference to the target service bean | yes |
localServiceName | The "local" part of the service name; together with a namespace this forms a qualified name, or QName | yes |
serviceNameSpaceURI | The "namespace" part of the service name; together with a local name forms a qualified name, or QName | Not required; if omitted, the Core.currentContextConfig().getMessageEntity() is used when exporting the service |
serviceEndpoint | URL at which the service can be invoked by a remote call | Not required; defaults to the serviceServletUrl parameter defined in the Rice config |
retryAttempts | Number of attempts to retry the service invocation on failure; for services with side-effects you are advised to omit this property | Not required; defaults to 0 |
millisToLive | Number of milliseconds the call should persist before resulting in failure | Not required; defaults to no limit (-1) |
Priority | Priority | Not required; defaults to 5 |
MessageExceptionHandler | Reference to a MessageExceptionHandler that should be invoked in case of exception | Not required; default implementation handles retries and timeouts |
busSecurity | Whether to enable bus security for the service | Not required; defaults to ON |
ServiceNameSpaceURI is the same as the Message Entity that composes the qualified name under which the service is exposed. When omitted, this namespace defaults to the message entity configured for Rice (e.g., in the RiceConfigurer), thereby qualifying the local name. Note: Although this implicit qualification occurs during export, you must always specify an explicit message entity when acquiring a resource, for example:
GlobalResourceLoader.getService(new QName("MYAPP", "myExposedSoapService"))
To consistently access services that you have exposed, but which may be running under implicitly qualified names, you may use the current message entity provided by the current context config. (This is mostly useful for internal Rice modules or other services that are intended to be run under varying client message entities.)
GlobalResourceLoader.getService(new QName(Core.getCurrentContextConfig().getMessageEntity(), "myExposedSoapService"))
Table 6.4. SOAPServiceDefinition
Property | Description | Required |
---|---|---|
serviceInterface | The interface to expose and from which to generate the WSDL | Not required; if omitted the first interface implemented by the class is used |
Table 6.5. JavaServiceDefinition
Property | Description | Required |
---|---|---|
serviceInterface | The interface to expose | Not required; if omitted, all application-layer interfaces implemented by the class are exposed |
serviceInterfaces | A list of interfaces to expose | Not required; if omitted, all application-layer interfaces implemented by the class are exposed |
We show how you can "import" Rice services into the client Spring application context in Configuring KSB Client in Spring. Using this technique, you can also publish Rice services on the KSB:
<!-- import a Rice service from the ResourceLoader stack --> <bean id="aRiceService" class="org.kuali.rice.resourceloader.support.ResourceLoaderServiceFactoryBean"/> <!-- if Rice does not publish this service on the bus, one can explicitly publish it --> <bean class="edu.iu.uis.eden.messaging.KSBExporter"> <property name="serviceDefinition"> <bean class="edu.iu.uis.eden.messaging.JavaServiceDefinition"> <property name="service"> <ref bean="aRiceService"/> </property> <property name="serviceInterface"> <value>org.kuali.rice...SomeInterface</value> </property> <property name="localServiceName" value="aPublishedRiceService" /> </bean> </property> </bean>
Not all Rice services are intended for public use. Do not arbitrarily expose them on the bus