Broker 10.5 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | JMS Marshalling | Marshalling and Connection Factories
Marshalling and Connection Factories
The set up of marshalling objects on a connection factory is done once per connection. To set up marshalling, you use the webMethods connection factory interface WmConnectionFactory. This interface defines the following methods for marshalling:
*Set the outbound marshalling object (setMarshalOut())
*Set the inbound marshalling object (setMarshalIn())
*Set/get the inbound marshaller class name (setMarshalInClassName(), getMarshalInClassName())
*Set/get the outbound marshaller class name (setMarshalOutClassName(), getMarshalOutClassName())
The first two methods offer the greatest flexibility in using the marshalling feature, allowing you to pass in a user data object containing context information. These methods are useful when writing marshalling code.
The last two methods are employed when setting marshalling properties in a connection factory with the JMSAdmin command-line tool. The methods store class names and bind objects to JNDI. However, if these methods are used, you cannot configure a user data object; a Null value is always returned for a user data object.
Changing the marshalling objects on a WmConnectionFactory affects new connections created from that factory. Existing connections continue to use the marshalling objects that were set when they were created.
Following are complete definitions of the marshalling-related methods of the webMethods WmConnectionFactory interface:
public interface WmConnectionFactory {
public void setMarshalOut(WmMarshalOut marshaller, Object userData)
throws JMSException;
public WmMarshalOut getMarshalOut() throws JMSException;
public void setMarshalOutClassName(String className)
throws JMSException;
public String getMarshalOutClassName() throws JMSException;
public void setMarshalIn(WmMarshalIn marshaller, Object userData);
throws JMSException
public WmMarshalIn getMarshalIn() throws JMSException;
public void setMarshalInClassName(String className);
throws JMSException;
public String getMarshalInClassName() throws JMSException;
Below is some sample code that shows how to implement WmConnectionFactory:
Counter counter = new Counter();
WmConnectionFactory factory;
Connection conn;
// Create the connection factory
factory = WmJMSFactory.getConnectionFactory();
// Set up the marshalling methods.
factory.setMarshalOut(new SimpleMarshalOut(), counter);
factory.setMarshalIn(new SimpleMarshalIn(), counter);
// Set up the ConnectionFactory's other properties as needed.
// Set up the JMS connection.
conn = factory.createConnection();