此内容没有您所选择的语言版本。
19.4. Runtime Control
Overview
Several message context property values can be set in client code to control WS-RM at runtime, with key values defined by public constants in the
org.apache.cxf.ws.rm.RMManager
class.
Runtime control options
The following table lists the keys defined by the
org.apache.cxf.ws.rm.RMManager
class.
Key | Description |
---|---|
WSRM_VERSION_PROPERTY
|
String WS-RM version namespace (
http://schemas.xmlsoap.org/ws/2005/02/rm/ or http://docs.oasis-open.org/ws-rx/wsrm/200702 ).
|
WSRM_WSA_VERSION_PROPERTY
| String WS-Addressing version namespace (http://schemas.xmlsoap.org/ws/2004/08/addressing or http://www.w3.org/2005/08/addressing ) - this property is ignored unless you're using the http://schemas.xmlsoap.org/ws/2005/02/rm/ RM namespace). |
WSRM_LAST_MESSAGE_PROPERTY
| Boolean value true to tell the WS-RM code that the last message is being sent, allowing the code to close the WS-RM sequence and release resources (as of the 3.0.0 version of CXF, the WS-RM will close the RM sequence by default, when you close your client). |
WSRM_INACTIVITY_TIMEOUT_PROPERTY
| Long inactivity timeout in milliseconds. |
WSRM_RETRANSMISSION_INTERVAL_PROPERTY
| Long base retransmission interval in milliseconds. |
WSRM_EXPONENTIAL_BACKOFF_PROPERTY
| Boolean exponential back-off flag. |
WSRM_ACKNOWLEDGEMENT_INTERVAL_PROPERTY
| Long acknowledgement interval in milliseconds. |
Controlling WS-RM through JMX
You can also monitor and control many aspects of WS-RM using the JMX Management features of Apache CXF. The full list of JMX operations is defined by
org.apache.cxf.ws.rm.ManagedRMManager
and org.apache.cxf.ws.rm.ManagedRMEndpoint
, but these operations include viewing the current RM state down to the individual message level. You can also use JXM to close or terminate a WS-RM sequence, and to receive notification of when previously-sent messages are acknowledged by the remote RM endpoint.
Example of JMX control
For example, if you have the JMX server enabled in your client configuration, you could use the following code to track the last acknowledgement number received:
// Java private static class AcknowledgementListener implements NotificationListener { private volatile long lastAcknowledgement; @Override public void handleNotification(Notification notification, Object handback) { if (notification instanceof AcknowledgementNotification) { AcknowledgementNotification ack = (AcknowledgementNotification)notification; lastAcknowledgement = ack.getMessageNumber(); } } // initialize client ... // attach to JMX bean for notifications // NOTE: you must have sent at least one message to initialize RM before executing this code Endpoint ep = ClientProxy.getClient(client).getEndpoint(); InstrumentationManager im = bus.getExtension(InstrumentationManager.class); MBeanServer mbs = im.getMBeanServer(); RMManager clientManager = bus.getExtension(RMManager.class); ObjectName name = RMUtils.getManagedObjectName(clientManager, ep); System.out.println("Looking for endpoint name " + name); AcknowledgementListener listener = new AcknowledgementListener(); mbs.addNotificationListener(name, listener, null, null); // send messages using RM with acknowledgement status reported to listener ...