examples.jms.topic
Class TopicReceive
java.lang.Object
|
+--examples.jms.topic.TopicReceive
- All Implemented Interfaces:
- javax.jms.MessageListener
- public class TopicReceive
- extends java.lang.Object
- implements javax.jms.MessageListener
This example shows how to establish a connection to and receive
messages from a JMS topic. The classes in this package operate
on the same JMS topic. Run the classes together to observe messages
being sent and received. This class is used to receive messages from
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 for the topic. |
static java.lang.String |
JNDI_FACTORY
Defines the JNDI context factory. |
static java.lang.String |
TOPIC
Defines the topic. |
Method Summary |
void |
close()
Closes JMS objects. |
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. |
void |
onMessage(javax.jms.Message msg)
Message listener interface. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JMS_FACTORY
public static final java.lang.String JMS_FACTORY
- Defines the JMS connection factory for the topic.
JNDI_FACTORY
public static final java.lang.String JNDI_FACTORY
- Defines the JNDI context factory.
TOPIC
public static final java.lang.String TOPIC
- Defines the topic.
TopicReceive
public TopicReceive()
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
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 contexttopicName
- name of topic- Throws:
javax.naming.NamingException
- if problem occurred with JNDI context interfacejavax.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.
- Throws:
java.lang.Exception
- if execution fails
onMessage
public void onMessage(javax.jms.Message msg)
- Message listener interface.
- Specified by:
onMessage
in interface javax.jms.MessageListener
- Parameters:
msg
- message
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.