Petals-BC-JMS 3.0

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (27)

View Page History
{section}
{column}
h1. Feature s

This binding component allows to interact with an external JMS Destination (queue or topic). Service Units are used to map a JMS destination to a JBI ServiceEndpoint. A JBI MessageExchange sent to a ServiceEndpoint (mapped to a JMS destination) is transformed into a JMS TextMessage and sent to the corresponing JMS destination. A JMS message sent to a JMS Destination is transformed into a JBI MessageExchange and sent to the corresponding JBI ServiceEndpoint.
{note}
* Only JMS TextMessage are recognized by the petals-binding-jms component.
* The service operation defined in the JBI MessageExchange is mapped to the operation String property of the JMS TextMessage (both in consumming and providing mode).
* If the JMS BC must use a JMS Provider other than Joram, this provider client libraries must be in the Petals classpath.
{note}

The Petals JMS component can be used to interact with an external JMS application or server (through a queue or a topic).
When used with the provider role, it allows to post TextMessages to a JMS queue or topic.
When used with the consumer role, it allows to read messages from a queue or receive messages posted on a given topic.
{column}

{column:width=35%}
{panel:title=Table of contents}{toc}{panel}
{column}
{section}
h1. Sending or publishing a JBI message to a JMS Queue or Topic
PROVIDE SERVICE: Expose a Java class as a Service

h1. Recommended Usage

This component should be used whenever interactions with a JMS server or application is required.
This component needs a driver (also called a shared library in Petals) so that Petals can interact with the JMS application. This shared library generally contains the JNDI classes, as a JNDI is used to enable communications between both servers.

\\
{note}* Only JMS TextMessage are recognized by the Petals JMS component.
* With the version 3.0, only XML messages can be published and received from a JMS application.
* In Petals, the invoked service operation is mapped to the _operation_ property of the JMS _TextMessage_ (both in consumming and providing mode).
{note}

h1. Sending a message to a JMS Queue

This use case is similar to [publishing a message on a JMS topic|#Publishing-a-message-to-a-JMS-Topic].

h1. Publishing a message to a JMS Topic

{center}!petals-bc-jms_provide_service.png|width=600px!{center}
{center}_Provides a JMS queue or topic as a JBI service_{center}

h2. Usage

The petals-bc-jms component can expose as a JBI ServiceEndpoint an external JMS Queue or JMS Topic. This is done by deploying a Service Unit on it.
When a message is received from the JBI environment, it is transformed into a JMS TextMessage and sent or published on the Queue or Topic.
To do that with Petals, you have to create a service associated with the Petals JMS component.
This is achieved by creating a service unit whose jbi.xml contains a *provides* section. When deployed in Petals, the Petals JMS component will emulate a service. When this service is invoked, the received message will be posted as a _TextMessage_ on the topic defined in the service unit configuration.

{note}* All the MEP are allowed. However, due to the JMS paradigm, all exchanges are processed like *InOnly* exchanges. For exemple, an InOut exchange returns a default message if the JMS message is sent succesfully.
* The external Queue or Topic referenced by the Service Unit does not have to be available before the Service Unit is started. But the JNDI server where Queue or Topic are registered must be available before the Service Unit deployment.
* Properties from the Petals message are automatically converted to JMS message properties.
{note}
* All MessageExchange patterns are allowed. But, due to the JMS paradigm, all exchanges are processed like InOnly exchanges. For exemple, an InOut exchange returns a default message if JMS message is sent succesfully.
* The external Queue or Topic referenced by the Service Unit doesn't have to be available before you start the Service Unit. But the JNDI server where Queue or Topic are registered, must be available before you deploy the Service Unit.
* The NormalizedMessage properties are automaticaly converted as JMS message properties. Be careful, Weblogic doesn't allow "." character in JMS properties names.
{note}
{petalslink:author=llacote|type=FIXME Normal qu'on mentionne Weblogic dans une doc composant Petals ?}{petalslink}

h2. Configuration

h3. Service Unit descriptor
The Service Unit descriptor file ( jbi.xml ) looks like this :
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:petals="http://petals.objectweb.org/extensions"
xmlns:jbi="http://java.sun.com/xml/ns/jbi" version="1.0">
<jbi:services binding-component="false">
<jbi:provides interface-name="petals:JMSSampleProviderInterface"
service-name="petals:JMSSampleProviderService"
endpoint-name="JMSSampleProviderEndpoint">
<petals:params>
<petals:param name="address">scn://localhost:26400</petals:param>
<petals:param name="destination-name">queueProvider</petals:param>
<petals:param
name="initial-context-factory">fr.dyade.aaa.jndi2.client.NamingContextFactory</petals:param>
<petals:param name="connection-factory">qcf</petals:param>
<petals:param name="user">anonymous</petals:param>
<petals:param name="password">anonymous</petals:param>
<petals:param name="transacted">false</petals:param>
</petals:params>
</jbi:provides>
</jbi:services>
</jbi:jbi>
{code}
JMS communication attributes:

The Service Unit descriptor file ( jbi.xml ) looks like this:

{code:lang=xml}<?xml version="1.0" encoding="UTF-8"?>
<!--
JBI descriptor for the Petals' "petals-bc-jms" component (JMS).
Originally created for the version 3.1 of the component.
-->
<jbi:jbi version="1.0"
xmlns:generatedNs="http://petals.ow2.org"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:jms="http://petals.ow2.org/components/jms/version-3"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!-- Import a Service into Petals or Expose a Petals Service => use a BC. -->
<jbi:services binding-component="true">

<!-- Import a Service into Petals => provides a Service. -->
<jbi:provides
interface-name="generatedNs:itf"
service-name="generatedNs:srv"
endpoint-name="srvEndpoint">

<!-- CDK specific elements -->
<petalsCDK:timeout>30000</petalsCDK:timeout>
<petalsCDK:validate-wsdl>true</petalsCDK:validate-wsdl>
<petalsCDK:forward-security-subject>false</petalsCDK:forward-security-subject>
<petalsCDK:forward-message-properties>false</petalsCDK:forward-message-properties>
<petalsCDK:forward-attachments>false</petalsCDK:forward-attachments>
<petalsCDK:wsdl xsi:nil="true" />

<!-- Component specific elements -->
<jms:jndi-provider-url>tcp://localhost:61616</jms:jndi-provider-url>
<jms:jndi-initial-context-factory>org.apache.activemq.jndi.ActiveMQInitialContextFactory</jms:jndi-initial-context-factory>
<jms:jndi-destination-name>dynamicQueues/PetalsQueue</jms:jndi-destination-name>
<jms:jndi-connection-factory>QueueConnectionFactory</jms:jndi-connection-factory>
<jms:transacted>false</jms:transacted>
<jms:max-active>10</jms:max-active>
<jms:max-idle>5</jms:max-idle>
<jms:max-wait>10000</jms:max-wait>
<jms:time-between-eviction-runs-millis>30000</jms:time-between-eviction-runs-millis>
<jms:min-evictable-idle-time-millis>600000</jms:min-evictable-idle-time-millis>
<jms:test-while-idle>true</jms:test-while-idle>
</jbi:provides>
</jbi:services>
</jbi:jbi>{code}

\\
{center}{*}Service Unit attributes to provide services*{center}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;",style="text-align:center;"}
{table-plus}

Extra attributes: {petalslink:author=llacote|type=FIXME marqué tel quel sans contenu dans le pdf}{petalslink}

{center}{*}Advanced configuration of Service Unit (provides elements)*{center}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;",style="text-align:center;"}

h3. Service Unit content

The Service Unit has to contain the following elements, packaged in an archive:
* The META-INF/jbi.xml descriptor file, has described above,
* An optional wsdl WSDL file describing the related service.

{code}
service-unit.zip
{code}

h1. Sending a JBI message from a received or published JMS Message
CONSUME SERVICE: Expose an internal service outside the JBI environment
h1. Consuming a JBI message from a JMS Queue

This use case is similar to [subscribing to a JMS topic|#Subscribing-to-a-JMS-Topic].

h1. Subscribing to a JMS Topic

{center}!petals-bc-jms-consume_service.png|width=600px!{center}
{center}_Consumes a JBI service on JMS message_{center}

The petals-bc-jms component can listen to an external JMS Queue or JMS Topic and send the message to a JBI
ServiceEndpoint. We say that the component consumes the JBI service.
When a message is received from the JMS server (the component listens to the JMS Queue or has subscribed to a JMS Topic), it is transformed into a JBI Message and sent to the JBI ServiceEndpoint configure in the Service Unit.
h2. Usage

The Petals JMS component can listen to an external JMS Queue or JMS Topic.
When it receives a message, it creates a Petals message and sends to a Petals service (we say that the component consumes the JBI service). This service is specified in the Service Unit.

{note}
* All MessageExchange patterns are allowed. But, due to the JMS paradigm, all exchanges are processed like {{InOnly}} *InOnly* exchanges.
* The external Queue or Topic referenced by the Service Unit has to be available before you start the Service Unit.
{note}