Using WS-Reliable Messaging

To make a message exchange between two endpoints reliable, you need to ensure that the RM interceptors and (as WS-Reliable messaging has a dependency on WS-Addressing) the addressing interceptors are added to the interceptor chains. This can be achieved in one of the following ways:

Using the RMAssertion and the CXF WS-Policy Framework

If

  1. A Policy with an RMAssertion element is attached to the wsdl:service element (or any other wsdl element that according to the rules for WS-Policy Attachment is an attachment point for Policy or PolicyReference elements)
  2. The CXF WS-Policy Framework is enabled

the RM interceptors will be automatically added to their respective interceptor chains by the policy framework. The assertion attributes control the behavior of the source/destination.

For example, to enable the WS-Policy Framework on the server side, you configuration file could look like this:

and your wsdl:

Instead of attaching the PolicyReference attached to the wsdl:port element, you can also specify it as a child element of the policies features, e.g. for the server endpoint:

As of CXF 3.0.0 both the older WS-ReliableMessagingPolicy 1.0 (submission version) and the official WS-ReliableMessagingPolicy 1.2 are supported. WS-ReliableMessagingPolicy 1.2 must be used in the policy if you want WS-ReliableMessaging 1.2 support at runtime.

Using the Reliable Messaging Feature

If you don't want to involve the WS-Policy Framework, or want to configure additional parameters such as the sequence termination policy or the persistent store, you can use the reliableMessaging feature. It is defined in namespace http://cxf.apache.org/ws/rm/manager and supports the following child elements:

Name

Value

RMAssertion

An element of type RMAssertion.

deliveryAssurance

An element of type DeliveryAssuranceType that describes the delivery assurance that should apply (AtMostOnce, AtLeastOnce, InOrder).

sourcePolicy

An element of type SourcePolicyType that allows you to configure details of the RM source, such as whether an offer should always be included in a CreateSequence request, or the sequence termination policy.

destinationPolicy

An element of type DestinationPolicyType that allows you to configure details of the RM destination, such as whether inbound offers should be accepted.

store

The store to use (default: null). This must be an element of type jdbcStore (in the same namespace), or a bean or a reference to a bean that implements the RMStore interface.

For details about the element types used in this namespace please refer to the schemas for the http://cxf.apache.org/ws/rm/manager namespace (http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd and http://cxf.apache.org/schemas/configuration/wsrm-manager-types.xsd). The jbdcStore element type is described below.

Example (feature applied at bus level):

Configuring the Reliable Messaging Store

To enable persistence, you must specify the object implementing the persistent store for RM. You can develop your own, or use the JDBC based store that comes with CXF (class org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore). You can configure the latter using a custom jdbcStore bean (namespace http://cxf.apache.org/ws/rm/manager) inside the wsrm-mgr:reliableMessaging element. The jdbcStore bean supports the attributes:

Attribute Name

Type

Default

dataSource

String

null

driverClassName

String

org.apache.derby.jdbc.EmbeddedDriver

initialReconnectDelay

long

0

keepConnection

boolean

false

maxReconnectAttempts

int

0

passWord

String

null

tableExistsCode

int

0

tableExistsState

String

null

schemaName

String

null

userName

String

null

url

String

jdbc:derby:rmdb;create=true

Example:

See the jdbcStore element definition in the RM Manager schema for more details of the attribute usages.

Adding the Reliable Messaging Interceptors Manually

To ensure that the Reliable Messaging interceptors are added to the appropriate interceptor chains, e.g. for all client and server endpoints:

The RetransmissionIntercepor will be added on the fly by the RMOutInterceptor so need not appear in your configuration file.

Configuring the Reliable Messaging Manager Manually

To configure properties of the RM Manager, you can use the rmManager element from the http://cxf.apache.org/ws/rm/manager namespace. It supports the same child elements as the reliableMessaging feature element above. For example, without using features, you can determine that seuences should have a maximum length of 5 as follows: