Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
borderfalse
Column
width15%
Include Page
TUSCANY: SCA Java Subproject Menu
TUSCANY: SCA Java Subproject Menu
Include Page
TUSCANY: Java SCA Menu New
TUSCANY: Java SCA Menu New
<component name="HelloWorldClientComponent"> <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/> </component> <reference name="HelloWorldReference" promote="HelloWorldClientComponent/service"> <interface.java interface="org.apache.tuscany.sca.binding.jms.HelloWorldService"/> <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61616"> <destination name="DestQueue" create="always"/> <response> <destination name="RespQueue" create="always"/> </response> </binding.jms> </reference> <service name="HelloWorldService" promote="HelloWorldServiceComponent"> <interface.java interface="org.apache.tuscany.sca.binding.jms.HelloWorldService"/> <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61616"> <destination name="DestQueue" create="always"/> </binding.jms> </service> <component name="HelloWorldServiceComponent"> <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/> </component>

Not all these elements are supported by Tuscany. Specifically, the <activationSpec> and <resourceAdapter> elements are not supported as Tuscany does not use JCA or MDBs for its JMS support. Additionally, support for the requestConnection, responseConnection, and operationProperties attributes has not yet been implemented but this should get done in the future.

Column
width85%

<binding.jms>

The Tuscany Java SCA runtime supports the Java Messaging Service using the <binding.jms> SCDL extension. New JMS based service endpoints can be provided using a <binding.jms> element within a SCA <service>, existing JMS queues can be accessed using a <binding.jms> element within a SCA <reference>.

The JMS binding is one of the SCA extensions which is being formalized in the OASIS Open Composite Services Architecture with a published specifications document.

Using the JMS binding

The JMS binding SCDL has the following format:simplest way to use the JMS binding is to use the URI syntax to configure the binding, for example:

Code Block
<binding.jms uri="jms:RequestQueue"/>

This tells the binding to use a JMS destination named "RequestQueue", with all the other configuration options using default values. When used in a SCA reference for RPC style request a temporary replyTo queue will be used.

Using the JMS binding

Binding Operation

<binding.jms>

Some examples:

HelloWorld

The helloworld-jms sample demonstrates basic RPC style operations over JMS. The sample has one component exposing a JMS service on a queue name 'RequestQueue' and another component which invokes the service by sending JMS messages to that queue. The .composite file for this is shown below, see the sample README for full details.

Code Block

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
Code Block

SCDL Content           targetNamespace="http://sample"
           xmlns:sample="http://sample"
           name="HelloWorld">

    <component name="HelloWorldClient">
  Supported  Default  Value  <implementation.java class="helloworld.HelloWorldClient"/>
        <reference name="helloWorldService">
            <interface.java interface="helloworld.HelloWorldService"/>
                 
============<binding.jms uri="jms:RequestQueue"/>
        </reference>
    </component>

    <component name="HelloWorldServiceComponent">
                       =========  ==============<implementation.java class="helloworld.HelloWorldServiceImpl" />
	<service name="HelloWorldService">
            <interface.java interface="helloworld.HelloWorldService"/>
            <binding.jms uri="jms:RequestQueue"/>
        </service>
    </component>

</composite>

JMS binding schema

The complete JMS binding SCDL schema has the following format:

Code Block
    
<binding.jms correlationScheme="string"?            NO         requestmsgidtocorrelid                                  
             initialContextFactory="xs:anyURI"?     YES        org.apache.activemq.jndi.ActiveMQInitialContextFactory  
             jndiURL="xs:anyURI"?                   YES        tcp://localhost:61616                                   
             requestConnection="QName"?             NO                                        
             responseConnection="QName"?            NO
             operationProperties="QName"?           NO
             ... >

   <destination name="xs:anyURI"                     YES        NODESTINATION (= target service name when not set)
               type="string"?                       NO         queue
               create="string"?>                    YES        never (set to allways if no destination set)
    
      <property name="NMTOKEN" type="NMTOKEN">*       NO

   </destination>?

   <connectionFactory name="xs:anyURI"               YES        ConnectionFactory
                     create="string"?>   
           NO         never
    <property name="NMTOKEN" type="NMTOKEN">*
       NO
  </connectionFactory>?

   <activationSpec name="xs:anyURI"                  NO
                  create="string"?> 
                NO
    <property name="NMTOKEN" type="NMTOKEN">* 
      NO
  </activationSpec>?

   <response>
      <destination name="xs:anyURI"                   YES        NORESPONSEDESTINATION (= reference name when not set)
                 type="string"?                     NO         queue
                 create="string"?>                  YES 
       never (set to allways if no response destination set)
      <property name="NMTOKEN" type="NMTOKEN">* 
    NO
    </destination>?
      <connectionFactory name="xs:anyURI"             YES        ConnectionFactory
                      create="string"?>             NO     
    never
      <property name="NMTOKEN" type="NMTOKEN">*
     NO
    </connectionFactory>?
      <activationSpec name="xs:anyURI"                NO
                    create="string"?>
               NO
      <property name="NMTOKEN" type="NMTOKEN">*   
  NO
    </activationSpec>?
   </response>?

   <resourceAdapter name="NMTOKEN">?                 NO

      <property name="NMTOKEN" type="NMTOKEN">*       NO

   </resourceAdapter>?

   <headers JMSType="string"?
                        NO
           JMSCorrelationId="string"?               NO

            JMSDeliveryMode="string"?                NO         DeliveryMode.NON_PERSISTENT

            JMSTimeToLive="int"?  
                   NO         10000
           JMSPriority="string"?>    
               NO         1
    <property name="NMTOKEN" type="NMTOKEN">*
   </headers>?

   <operationProperties name="string"                NO
                       nativeOperation="string"?> 
  NO
    <property name="NMTOKEN" type="NMTOKEN">* 
      NO
    <headers JMSType="string"?                   
   NO
             JMSCorrelationId="string"?
             NO
             JMSDeliveryMode="string"?
              NO
             JMSTimeToLive="int"?  
                 NO
             JMSPriority="string"?>         
        NO
      <property name="NMTOKEN" type="NMTOKEN">* 
    NO
    </headers>?
   </operationProperties>*

</binding.jms>

(question) see See the JMS Binding S Vpecification Specification 1.0 for deatils full details of each of these configuration options.

Binding Operation

<binding.jms>

Some examples:

Creating Queues

By default the JMS binding assumes queue based option where a queue represents a single wire between two components. In this mode operation is assumed to be RPC by default, i.e. the referen will send a message and wait for a response. The name of the response queue is passed to the service along with the message but the desitination queue name must match a reference and service

Code Block