The Message Broker Subscription control is used to dynamically subscribe to channels and receive messages. You bind the channel and optionally, an XQuery expression for filtering messages, when you create an instance of the control for your business process. The bindings cannot be overridden dynamically.
The following are the Message Broker Subscription control methods:
package com.bea.control; import weblogic.jws.control.Control; /** * Message Broker Subscription control base interface */
public interface SubscriptionControl extends Control {
/** * Subscribes the control to the message broker. If the subscription * uses a filter expression, then the default filter value will be * used. If no default filter value is defined in the annotations, * then a <tt>null</tt> filter value will be used, meaning that any * filter result will trigger a callback. */
void subscribe();
/** * Unsubscribes the control from the message broker, stopping * further events (messages) from being delivered to the control. */
void unsubscribe(); interface Callback { /** * Internal callback method used to implement user-defined callbacks. * JPDs cannot and should not attempt to implement this callback method. * * @param msg the message that triggered the subscription * @throws Exception * void _internalCallback(Object msg) throws Exception; */ } }
The following code shows an example of an extended control.
/* * @jc:mb-subscription-control * channel-name="/controls/stocks" * xquery="$message/StockSymbol/text()" */ interface MySubscriptionControl extends SubscriptionControl, ControlExtension { /** * @jc:mb-subscription-method * filter-value-match="BEA" */ void subscribeToBEA(); /** * @jc:mb-subscription-method * filter-value-match="{symbol}" */ void subscribeToSymbol(XmlObject symbol); interface Callback { /** * @jc:mb-subscription-callback message-body="{myMsgReceived}" */ onXMLMessage(XmlObject myMsgReceived); } } /* * @common:control */ MySubscriptionControl subCtrl; // subscribe to a message
void subscribeIt() { subCtrl.subscribeToBEA(); } // receive a message after subscribing subCtrl_onXMLMessage(XmlObject myMsgReceived) { }