Publishing Services to KSB

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.

KSBConfigurer

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>

KSBExporter

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>

ServiceDefinition properties

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.

Basic parameters

All service definitions support these properties:

Table 6.3. ServiceDefinition Properties

PropertyDescriptionRequired
ServiceThe reference to the target service beanyes
localServiceNameThe "local" part of the service name; together with a namespace this forms a qualified name, or QNameyes
serviceNameSpaceURIThe "namespace" part of the service name; together with a local name forms a qualified name, or QNameNot required; if omitted, the Core.currentContextConfig().getMessageEntity() is used when exporting the service
serviceEndpointURL at which the service can be invoked by a remote callNot required; defaults to the serviceServletUrl parameter defined in the Rice config
retryAttemptsNumber 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
millisToLiveNumber of milliseconds the call should persist before resulting in failure Not required; defaults to no limit (-1)
PriorityPriorityNot required; defaults to 5
MessageExceptionHandlerReference to a MessageExceptionHandler that should be invoked in case of exceptionNot required; default implementation handles retries and timeouts
busSecurityWhether to enable bus security for the serviceNot required; defaults to ON


ServiceNameSpaceURI/MessageEntity

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"))

SOAPServiceDefinition

Table 6.4. SOAPServiceDefinition

PropertyDescriptionRequired
serviceInterfaceThe interface to expose and from which to generate the WSDLNot required; if omitted the first interface implemented by the class is used

JavaServiceDefinition

Table 6.5. JavaServiceDefinition

PropertyDescriptionRequired
serviceInterfaceThe interface to expose Not required; if omitted, all application-layer interfaces implemented by the class are exposed
serviceInterfacesA list of interfaces to exposeNot required; if omitted, all application-layer interfaces implemented by the class are exposed

Publishing Rice services

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>

Warning

Not all Rice services are intended for public use. Do not arbitrarily expose them on the bus