toolbox.jms
Class JmsProducerImpl

Package class diagram package JmsProducerImpl
java.lang.Object
  extended by toolbox.jms.JmsObject
      extended by toolbox.jms.JmsProducerImpl
All Implemented Interfaces:
JmsProducer

public class JmsProducerImpl
extends JmsObject
implements JmsProducer

Default JmsProducer implementation. This implementation provides queue sender and topic publisher functionalities.


Field Summary
 
Fields inherited from class toolbox.jms.JmsObject
m_exposeContext, m_jndiConfig
 
Constructor Summary
JmsProducerImpl()
          Default constructor.
 
Method Summary
 javax.jms.Message createMessage(int type)
          Create a message of the specified type.
 void destroy()
          Destroy this producer.
 void init(java.lang.String name, java.util.Map props, javax.jms.ExceptionListener exLsnr)
          Initialise this producer with the given name identifier and configuration properties.
 java.lang.String send(javax.jms.Message msg)
          Send the given message using this producer.
 java.lang.String send(javax.jms.Message msg, javax.jms.Destination destination)
          Send the given message using this producer.
 void setMessageListener(javax.jms.MessageListener listener)
          Use this MessageListener to receive replies.
 void start()
          Tell the reply consumer to start listening.
 void stop()
          Tell the reply consumer to stop listening.
 
Methods inherited from class toolbox.jms.JmsObject
destroyObject, getConnection, getDestination, getName, getSession, getType, initObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface toolbox.jms.JmsProducer
getName
 

Constructor Detail

JmsProducerImpl

public JmsProducerImpl()
Default constructor.

Method Detail

init

public void init(java.lang.String name,
                 java.util.Map props,
                 javax.jms.ExceptionListener exLsnr)
          throws JmsException
Initialise this producer with the given name identifier and configuration properties. This producer implementation supports the following configuration properties in the given props map:

Specified by:
init in interface JmsProducer
Parameters:
name - String containing the name identifier of this producer.
props - Map instance containing the configuration for this producer.
exLsnr - ExceptionListener instance that this producer must use to monitor it's broker connection.
Throws:
JmsException - if the producer cannot be initialised.

createMessage

public javax.jms.Message createMessage(int type)
                                throws JmsException
Create a message of the specified type. This method support the following types:

Specified by:
createMessage in interface JmsProducer
Parameters:
type - int indicating the type of message. Refer to JmsConstants.
Returns:
Message instance.
Throws:
JmsException - if the message cannot be created.

send

public java.lang.String send(javax.jms.Message msg)
                      throws JmsException
Send the given message using this producer. If this producer is of type point_to_point if will be sent to a queue and published to a topic if the producer is of type publish_subscribe.

Specified by:
send in interface JmsProducer
Parameters:
msg - Message instance to send.
Returns:
The message id of the sent message.
Throws:
JmsException - if the message cannot be sent.

send

public java.lang.String send(javax.jms.Message msg,
                             javax.jms.Destination destination)
                      throws JmsException
Send the given message using this producer. If this producer is of type point_to_point it will be sent to a queue and published to a topic if the producer is of type publish_subscribe.

Specified by:
send in interface JmsProducer
Parameters:
msg - Message instance to send.
destination - Use this destination as the target queue or topic.
Returns:
The message id of the sent message.
Throws:
JmsException - if the message cannot be sent.

setMessageListener

public void setMessageListener(javax.jms.MessageListener listener)
Use this MessageListener to receive replies.

Specified by:
setMessageListener in interface JmsProducer
Parameters:
listener - MessageListener that must be used.

start

public void start()
           throws JmsException
Tell the reply consumer to start listening.

Specified by:
start in interface JmsProducer
Throws:
JmsException

stop

public void stop()
          throws JmsException
Tell the reply consumer to stop listening.

Specified by:
stop in interface JmsProducer
Throws:
JmsException

destroy

public void destroy()
Destroy this producer.

Specified by:
destroy in interface JmsProducer