com.j_spaces.jms
Class GSMessageProducerImpl

java.lang.Object
  extended by com.j_spaces.jms.GSMessageProducerImpl
All Implemented Interfaces:
MessageProducer, QueueSender, TopicPublisher
Direct Known Subclasses:
GSQueueSenderImpl, GSTopicPublisherImpl

public class GSMessageProducerImpl
extends Object
implements MessageProducer, QueueSender, TopicPublisher

GigaSpaces implementation of the javax.jms.MessageProducer interface. A client uses a MessageProducer object to send messages to a destination. A MessageProducer object is created by passing a Destination object to a message-producer creation method supplied by a m_session.

MessageProducer is the parent interface for all message producers.

A client also has the option of creating a message producer without supplying a destination. In this case, a destination must be provided with every send operation. A typical use for this kind of message producer is to send replies to requests using the request's JMSReplyTo destination.

A client can specify a default delivery mode, priority, and time to live for messages sent by a message producer. It can also specify the delivery mode, priority, and time to live for an individual message.

A client can specify a time-to-live value in milliseconds for each message it sends. This value defines a message expiration time that is the sum of the message's time-to-live and the GMT when it is sent (for transacted sends, this is the time the client sends the message, not the time the transaction is committed).

See Also:
TopicPublisher, QueueSender, Session.createProducer(javax.jms.Destination)

Constructor Summary
GSMessageProducerImpl(GSSessionImpl sess, Destination m_dest, IMessageConverter messageConverter)
           
 
Method Summary
 void close()
          Cancels the AckDataEntry notify delegator, using its Lease.cancel() Also it removes the current producer from the producers list held by the m_session.
 int getDeliveryMode()
           
 Destination getDestination()
           
 boolean getDisableMessageID()
           
 boolean getDisableMessageTimestamp()
           
 int getPriority()
           
 String getProducerID()
           
 Queue getQueue()
           
 long getTimeToLive()
           
 Topic getTopic()
           
 void publish(Message message)
           
 void publish(Message message, int deliveryMode, int priority, long timeToLive)
           
 void publish(Topic topic, Message message)
           
 void publish(Topic topic, Message message, int deliveryMode, int priority, long timeToLive)
           
 void send(Destination destination, Message message)
           
 void send(Destination _destination, Message _message, int _deliveryMode, int _priority, long _timeToLive)
          Sends a message with given delivery parameters for an unidentified message producer.
 void send(Message message)
           
 void send(Message message, int deliveryMode, int priority, long timeToLive)
           
 void send(Queue queue, Message message)
           
 void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive)
           
 void setDeliveryMode(int deliveryMode)
          Sets the messages DeliveryMode for all the messages which will be sent via this producer in the m_session level. available DeliveryModes are: DeliveryMode.PERSISTENT - the default and DeliveryMode.NON_PERSISTENT
 void setDisableMessageID(boolean value)
           
 void setDisableMessageTimestamp(boolean value)
           
 void setPriority(int priority)
          Sets the priority for all the messages which be sent via this producer in the m_session level.
 void setProducerID(String m_producerID)
           
 void setTimeToLive(long timeToLive)
          Sets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GSMessageProducerImpl

public GSMessageProducerImpl(GSSessionImpl sess,
                             Destination m_dest,
                             IMessageConverter messageConverter)
                      throws JMSException
Parameters:
sess - - The Session the producer belongs to
m_dest - - The destination (Queue or Topic) that the producer sends messages to
m_producerID -
Throws:
JMSException
Method Detail

setDisableMessageID

public void setDisableMessageID(boolean value)
                         throws JMSException
Specified by:
setDisableMessageID in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.setDisableMessageID(boolean)

getDisableMessageID

public boolean getDisableMessageID()
                            throws JMSException
Specified by:
getDisableMessageID in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.getDisableMessageID()

setDisableMessageTimestamp

public void setDisableMessageTimestamp(boolean value)
                                throws JMSException
Specified by:
setDisableMessageTimestamp in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.setDisableMessageTimestamp(boolean)

setProducerID

public void setProducerID(String m_producerID)

getDisableMessageTimestamp

public boolean getDisableMessageTimestamp()
                                   throws JMSException
Specified by:
getDisableMessageTimestamp in interface MessageProducer
Returns:
m_timestampDisabled
Throws:
JMSException
See Also:
MessageProducer.getDisableMessageTimestamp()

setDeliveryMode

public void setDeliveryMode(int deliveryMode)
                     throws JMSException
Sets the messages DeliveryMode for all the messages which will be sent via this producer in the m_session level. available DeliveryModes are: DeliveryMode.PERSISTENT - the default and DeliveryMode.NON_PERSISTENT

Specified by:
setDeliveryMode in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.setDeliveryMode(int)

getDeliveryMode

public int getDeliveryMode()
                    throws JMSException
Specified by:
getDeliveryMode in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.getDeliveryMode()

setPriority

public void setPriority(int priority)
                 throws JMSException
Sets the priority for all the messages which be sent via this producer in the m_session level.

Specified by:
setPriority in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.setPriority(int)

getPriority

public int getPriority()
                throws JMSException
Specified by:
getPriority in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.getPriority()

setTimeToLive

public void setTimeToLive(long timeToLive)
                   throws JMSException
Sets the default length of time in milliseconds from its dispatch time that a produced message should be retained by the message system.

Time to live is set to zero by default.

Specified by:
setTimeToLive in interface MessageProducer
Parameters:
timeToLive - the message time to live in milliseconds; zero is unlimited, while then it is calculated according to the space ttl Lease.Forever which is Long.max_value
Throws:
JMSException - if the JMS provider fails to set the time to live due to some internal error.
See Also:
MessageProducer.getTimeToLive(), Message.DEFAULT_TIME_TO_LIVE

getTimeToLive

public long getTimeToLive()
                   throws JMSException
Specified by:
getTimeToLive in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.getTimeToLive()

getDestination

public Destination getDestination()
                           throws JMSException
Specified by:
getDestination in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.getDestination()

close

public void close()
           throws JMSException
Cancels the AckDataEntry notify delegator, using its Lease.cancel() Also it removes the current producer from the producers list held by the m_session.

Specified by:
close in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.close()

send

public void send(Message message)
          throws JMSException
Specified by:
send in interface MessageProducer
Specified by:
send in interface QueueSender
Throws:
JMSException
See Also:
MessageProducer.send(javax.jms.Message)

send

public void send(Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws JMSException
Specified by:
send in interface MessageProducer
Specified by:
send in interface QueueSender
Throws:
JMSException
See Also:
MessageProducer.send(javax.jms.Message, int, int, long)

send

public void send(Destination destination,
                 Message message)
          throws JMSException
Specified by:
send in interface MessageProducer
Throws:
JMSException
See Also:
MessageProducer.send(javax.jms.Destination, javax.jms.Message)

send

public void send(Destination _destination,
                 Message _message,
                 int _deliveryMode,
                 int _priority,
                 long _timeToLive)
          throws JMSException
Sends a message with given delivery parameters for an unidentified message producer.

Specified by:
send in interface MessageProducer
Throws:
UnsupportedOperationException - When the producer did not properly identify itself.
JMSSecurityException - If the user if not a WRITER on the specified destination.
IllegalStateException - If the producer is m_closed, or if the connection is broken.
JMSException - If the request fails for any other reason.
See Also:
MessageProducer.send(javax.jms.Destination, javax.jms.Message, int, int, long)

toString

public String toString()
Overrides:
toString in class Object

getProducerID

public String getProducerID()
Returns:
m_producerID

getQueue

public Queue getQueue()
               throws JMSException
Specified by:
getQueue in interface QueueSender
Throws:
JMSException
See Also:
QueueSender.getQueue()

send

public void send(Queue queue,
                 Message message)
          throws JMSException
Specified by:
send in interface QueueSender
Throws:
JMSException
See Also:
QueueSender.send(javax.jms.Queue, javax.jms.Message)

send

public void send(Queue queue,
                 Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws JMSException
Specified by:
send in interface QueueSender
Throws:
JMSException
See Also:
QueueSender.send(javax.jms.Queue, javax.jms.Message, int, int, long)

getTopic

public Topic getTopic()
               throws JMSException
Specified by:
getTopic in interface TopicPublisher
Throws:
JMSException
See Also:
TopicPublisher.getTopic()

publish

public void publish(Message message)
             throws JMSException
Specified by:
publish in interface TopicPublisher
Throws:
JMSException
See Also:
MessageProducer.send(javax.jms.Message)

publish

public void publish(Topic topic,
                    Message message)
             throws JMSException
Specified by:
publish in interface TopicPublisher
Throws:
JMSException
See Also:
javax.jms.TopicPublisher#send(javax.jms.Topic, javax.jms.Message)

publish

public void publish(Message message,
                    int deliveryMode,
                    int priority,
                    long timeToLive)
             throws JMSException
Specified by:
publish in interface TopicPublisher
Throws:
JMSException
See Also:
MessageProducer.send(javax.jms.Message, int, int, long)

publish

public void publish(Topic topic,
                    Message message,
                    int deliveryMode,
                    int priority,
                    long timeToLive)
             throws JMSException
Specified by:
publish in interface TopicPublisher
Throws:
JMSException
See Also:
javax.jms.TopicPublisher#send(javax.jms.Topic, javax.jms.Message, int, int, long)