# AccountSubscribeJMSControl.jcx Sample

This topic inludes the source code for the AccountSubscribeJMSControl.jcx Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/jms/

## Sample Source Code

`001 package jms; 002 003 import com.bea.control.JMSControl; 004 import java.io.Serializable; 005 006 import org.openuri.bea.samples.workshop.jms.account.AccountTransactionDocument; 007 import org.openuri.bea.samples.workshop.jms.account.AccountTransactionDocument.AccountTransaction; 008 009 010 /** 011 * 012 * <p>JMS control used by AccountSubscribe.jws sample. Defines 013 * a single callback named <b>receiveUpdate</b> that is called 014 * when a message arrives on the <tt>jms.AccountUpdate</tt> 015 * topic (while subscribed).</p> 016 * 017 * <p>Note that in all messaging scenarios the sender and 018 * receiver must agree on the message format.</p> 019 * 020 * <p>Notice that this control specifies a value for 021 * receive-jndi-name but not for send-jndi-name since 022 * this control is only used to subscribe to messages.<p> 023 024 * @jc:jms receive-type="topic" receive-jndi-name="jms.AccountUpdate" 025 * connection-factory-jndi-name="weblogic.jws.jms.QueueConnectionFactory" 026 */ 027 public interface AccountSubscribeJMSControl extends com.bea.control.ControlExtension, JMSControl 028 { 029 interface Callback extends JMSControl.Callback 030 { 031 /** 032 * <p>Callback that will be invoked whenever a message arrives 033 * on the topic of interest.</p> 034 * 035 * <p>JMS controls that specify a receive-jndi-name may define 036 * exactly one callback that will be invoked when a message 037 * arrives. </p> 038 * 039 * <p>Messages arriving on this topic are expected to have the 040 * transaction type encoded in a JMS property named transactionType, 041 * the account ID encoded in a JMS property named accountIdentifier, 042 * and the transaction amount in the message body.</p> 043 * 044 * <p>JMS messages may also have JMS message headers present. Which 045 * headers (if any) that are set on arriving messages is determined by 046 * the JMS server.</p> 047 * 048 * <p>Theheaders that may be present are:<p> 049 * <ul><li> 050 * JMSCorrelationID 051 * </li><li> 052 * JMSDeliveryMode 053 * </li><li> 054 * JMSExpiration 055 * </li><li> 056 * JMSMessageID 057 * </li><li> 058 * JMSPriority 059 * </li><li> 060 * JMSRedelivered 061 * </li><li> 062 * JMSTimestamp 063 * </li><li> 064 * JMSType 065 * </li></ul> 066 * 067 * @jc:jms-headers 068 * JMSCorrelationID="{CorrelationID}" 069 * JMSDeliveryMode="{DeliveryMode}" 070 * JMSExpiration="{Expiration}" 071 * JMSMessageID="{MessageID}" 072 * JMSPriority="{Priority}" 073 * JMSRedelivered="{Redelivered}" 074 * JMSTimestamp="{Timestamp}" 075 * JMSType="{Type}" 076 * 077 * @jc:jms-property key="accountIdentifier" value="{accountID}" 078 * @jc:jms-property key="transactionType" value="{transactionType}" 079 * 080 */ 081 public void receiveUpdate( 082 // Message Body 083 AccountTransaction transaction, 084 085 // Headers 086 String CorrelationID, 087 String DeliveryMode, 088 String Expiration, 089 String MessageID, 090 String Priority, 091 String Redelivered, 092 long Timestamp, 093 String Type, 094 095 // Properties 096 String transactionType, 097 String accountID 098 ); 099 } 100 }`