WebLogic Server 6.0 Code Examples, BEA Systems, Inc.

examples.jms.topic
Class TopicSend

java.lang.Object
  |
  +--examples.jms.topic.TopicSend

public class TopicSend
extends java.lang.Object

This examples shows how to establish a connection and send messages to the JMS topic. The classes in this package operate on the same topic. Run the classes together to observe message being sent and received. This class is used to send messages to the topic.

Author:
Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.

Field Summary
static java.lang.String JMS_FACTORY
          Defines the JMS connection factory.
static java.lang.String JNDI_FACTORY
          Defines the JNDI context factory.
protected  javax.jms.TextMessage msg
           
protected  javax.jms.TopicConnection tcon
           
protected  javax.jms.TopicConnectionFactory tconFactory
           
protected  javax.jms.Topic topic
           
static java.lang.String TOPIC
          Defines the topic.
protected  javax.jms.TopicPublisher tpublisher
           
protected  javax.jms.TopicSession tsession
           
 
Constructor Summary
TopicSend()
           
 
Method Summary
 void close()
          Closes JMS objects.
protected static javax.naming.InitialContext getInitialContext(java.lang.String url)
          Get initial JNDI context.
 void init(javax.naming.Context ctx, java.lang.String topicName)
          Creates all the necessary objects for sending messages to a JMS Topic.
static void main(java.lang.String[] args)
          main() method.
protected static void readAndSend(TopicSend ts)
          Prompts, reads, and sends a message.
 void send(java.lang.String message)
          Sends a message to a JMS topic.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JMS_FACTORY

public static final java.lang.String JMS_FACTORY
Defines the JMS connection factory.

JNDI_FACTORY

public static final java.lang.String JNDI_FACTORY
Defines the JNDI context factory.

msg

protected javax.jms.TextMessage msg

tcon

protected javax.jms.TopicConnection tcon

tconFactory

protected javax.jms.TopicConnectionFactory tconFactory

topic

protected javax.jms.Topic topic

TOPIC

public static final java.lang.String TOPIC
Defines the topic.

tpublisher

protected javax.jms.TopicPublisher tpublisher

tsession

protected javax.jms.TopicSession tsession
Constructor Detail

TopicSend

public TopicSend()
Method Detail

close

public void close()
           throws javax.jms.JMSException
Closes JMS objects.
Throws:
javax.jms.JMSException - if JMS fails to close objects due to internal error

getInitialContext

protected static javax.naming.InitialContext getInitialContext(java.lang.String url)
                                                        throws javax.naming.NamingException
Get initial JNDI context.
Throws:
javax.naming.NamingException - if problem occurs with JNDI context interface

init

public void init(javax.naming.Context ctx,
                 java.lang.String topicName)
          throws javax.naming.NamingException,
                 javax.jms.JMSException
Creates all the necessary objects for sending messages to a JMS Topic.
Parameters:
ctx - JNDI initial context
topicName - name of topic
Throws:
NamingExcpetion - if problem occurred with the JNDI context interface
javax.jms.JMSException - if JMS fails to initialize due to internal error

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
main() method.
Parameters:
args - WebLogic Server URL
Throws:
java.lang.Exception - if operation fails

readAndSend

protected static void readAndSend(TopicSend ts)
                           throws java.io.IOException,
                                  javax.jms.JMSException
Prompts, reads, and sends a message.
Parameters:
ts - TopicSend
Throws:
java.io.IOException - if problem occurs during read/write operation
javax.jms.JMSException - if JMS fails due to internal error

send

public void send(java.lang.String message)
          throws javax.jms.JMSException
Sends a message to a JMS topic.
Throws:
javax.jms.JMSException - if JMS fails to send message due to internal error

Documentation is available at
http://e-docs.bea.com/wls/docs60

Copyright © 2000 BEA Systems, Inc. All Rights Reserved.