I appreciate your messages. But I still have other issues.
Before I used embedded ActiveMQ in Tomcat, now I want to seperate activeMQ
from Tomcat. I want to run standalone ActiveMQ and I want to use a
DataSource, How do I convert the following two configurations in Tomcat into
ones in ActiveMQ.
<Resource name="jdbc/OracleSamh" auth="Container"
type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
maxActive="40"
maxIdle="2"
maxWait="10000"
username="admin"
password="99"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:dev"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true" />
<Resource name="jms/ConnectionFactory" auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://localhost:61616"
brokerName="LocalActiveMQBroker"/>
Jack Britton wrote:
>
> jxie,
>
> For example a method that creates a connection to a broker and registers
> a listener and starts the connection:
>
>
> protected Connection createConnection(String topicName, String clientID,
> String url)throws Exception{
> TopicConnectionFactory conFactory = new
> ActiveMQConnectionFactory(url);
> TopicConnection connection = conFactory.createTopicConnection( );
> TopicSession subSession = connection.createTopicSession(false,
> Session.AUTO_ACKNOWLEDGE);
> TopicSubscriber subscriber =
> subSession.createSubscriber(chatTopic);
> subscriber.setMessageListener(this);
> <---------------------------------- here is your listener, it will
> automagically call the onMessage() method.
> connection.start();
> }
>
>
>
>
> Adrian Co wrote:
>> Just set it as the message listener of your consumer and start the
>> connection that created the consumer and it should be automatically
>> registered with the JMS broker. or I might be misunderstanding your
>> problem...
>>
>> jxie wrote:
>>> I do have a class implement MessageListener as indicated by the
>>> following
>>> code:
>>>
>>> public class BBSFileHandler implements MessageListener {
>>> public void onMessage(final Message message) {
>>>
>>> }
>>> }
>>>
>>> I don't know how to register this in standalone ActiveMQ. Don't I
>>> have to
>>> add some configuration parameters?
>>>
>>>
>>>
>>>
>>> Adrian Co wrote:
>>>
>>>> One option is to use the JMS API.
>>>>
>>>> http://java.sun.com/javaee/5/docs/api/javax/jms/MessageConsumer.html#setMessageListener(javax.jms.MessageListener)
>>>>
>>>>
>>>>
>>>> jxie wrote:
>>>>
>>>>> So I have to register the message listener. I don't know how to do it.
>>>>> Would
>>>>> you please give me some examples including configuration files.
>>>>>
>>>>>
>>>>> Adrian Co wrote:
>>>>>
>>>>>> After you set the message listener, starting the connection should
>>>>>> register your listener to the broker.
>>>>>>
>>>>>> jxie wrote:
>>>>>>
>>>>>>> How do I make activemq to start a message listener (onMessage)
>>>>>>> automatically
>>>>>>> afte it is started? Now I embedded ActiveMQ with Tomcat, I want to
>>>>>>> seperate
>>>>>>> ActiveMQ from Tomcat so I can run one Tomcat instance and one
>>>>>>> ActiveMQ
>>>>>>> instance in a multiple CPU machine.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> James
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>
>
--
View this message in context:
http://www.nabble.com/start-message-listener-tf2542136.html#a7094234
Sent from the ActiveMQ - User mailing list archive at Nabble.com.