activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dirful_zone <...@i-s.com.cn>
Subject How can consumer monitor the producer via Spring
Date Mon, 10 Aug 2009 08:09:09 GMT

Hi, this is dirful.
I've study amq for several weeks. I have also searched the forum
carefully.I'm sorry to say that I'm so confused. I didn't get it.:(

This is my problem:
I make a project via Struts FrameWork,Spring and tomcat. I injected JNDI
into "context.xml" of tomcat like this:
    <Resource name="jms/ConnectionFactory"    
  auth="Container"      
  type="org.apache.activemq.ActiveMQConnectionFactory"    
  description="JMS Connection Factory"  
  factory="org.apache.activemq.jndi.JNDIReferenceFactory"    
  brokerURL="vm://192.168.201.249"    
  brokerName="LocalActiveMQBroker"/>  
    
<Resource name="jms/Queue1"    
auth="Container"    
type="org.apache.activemq.command.ActiveMQQueue"  
description="my Queue1"  
factory="org.apache.activemq.jndi.JNDIReferenceFactory"    
physicalName="FOO.BAR"/>

And I rewrited the xml of Spring,too. Then I made a MessageProducer and a
MessageConsumer.
If the MessageProducer and MessageConsumer is in the same apllication(just
call it projectA),It works! Just sending a message, it can real time
receiving the message.In addtion,the receiving method is written in Action.

But now, I wanted if A application sent a message, B application recived it,
and  B sent , A recieved. I modified the "context.xml" like this
    <Resource name="jms/ConnectionFactory"    
  auth="Container"      
  type="org.apache.activemq.ActiveMQConnectionFactory"    
  description="JMS Connection Factory"  
  factory="org.apache.activemq.jndi.JNDIReferenceFactory"    
  brokerURL="vm://192.168.201.249"    
  brokerName="LocalActiveMQBroker"/>  
    
<Resource name="jms/Queue1"    
auth="Container"    
type="org.apache.activemq.command.ActiveMQQueue"  
description="my Queue1"  
factory="org.apache.activemq.jndi.JNDIReferenceFactory"    
physicalName="FOO.BAR"/>  

<Resource name="jms/Queue2"    
auth="Container"    
type="org.apache.activemq.command.ActiveMQQueue"  
description="my Queue2"  
factory="org.apache.activemq.jndi.JNDIReferenceFactory"    
physicalName="FOO1.BAR"/>

And this is one of my applictiaonContext.xml,the other one is similar:

    <bean id="jmsConnectionFactory"   
        class="org.springframework.jndi.JndiObjectFactoryBean">   
        <property name="jndiName"
value="java:comp/env/jms/ConnectionFactory"></property>   
    </bean>   
   
    <bean id="jmsQueue1"   
        class="org.springframework.jndi.JndiObjectFactoryBean">   
        <property name="jndiName"
value="java:comp/env/jms/Queue1"></property>   
    </bean>  
        <bean id="jmsQueue2"   
        class="org.springframework.jndi.JndiObjectFactoryBean">   
        <property name="jndiName"
value="java:comp/env/jms/Queue2"></property>   
    </bean>   
   
    <bean id="jmsTemplate"   
        class="org.springframework.jms.core.JmsTemplate">   
        <property name="connectionFactory"
ref="jmsConnectionFactory"></property>   
        <property name="defaultDestination" ref="jmsQueue2"></property>   
    </bean>   
   
    <bean id="sender" class="message.Sender">   
        <property name="jmsTemplate" ref="jmsTemplate"></property>   
    </bean>   
   
    <bean id="receive" class="message.Receiver"></bean>   
    <bean id="listenerContainer"   
       
class="org.springframework.jms.listener.DefaultMessageListenerContainer">   
        <property name="connectionFactory"
ref="jmsConnectionFactory"></property>   
        <property name="destination" ref="jmsQueue1"></property>   
        <property name="messageListener" ref="receive"></property>   
    </bean>   

I'm depressed. It didn't work very well. When A send a message, B's listener
didn't work.Sometimes, when B send a message, at the same time, it can
recieve the message. But this isn't what I hope.
Could you give me some directions,sir? How can I do monitor the sending
message in two applications?

I have annother question,too.

Er, you see that I injected JNDI into "context.xml", it can send a message
successfully. and I want to make a static Main method In another application
to receive the message( just test). I'm confused that, If I don't use
JNDI,the url is...,the broker is...,password?username? how can I write it?
I made it like this:

connectionFactory = new ActiveMQConnectionFactory(
				ActiveMQConnection.DEFAULT_USER,
				ActiveMQConnection.DEFAULT_PASSWORD,
				"vm://192.168.201.249");
			connection = connectionFactory.createConnection();
			connection.start();
			session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
			destination = session.createQueue("FOO.BAR");
			consumer = session.createConsumer(destination);

I got a waring:Waiting to Lock the Store activemq-data\192.168.201.249.

I appreciate any your help. Best whishes!

dirful
08/10/2009

-- 
View this message in context: http://www.nabble.com/How-can-consumer-monitor-the-producer-via-Spring-tp24895824p24895824.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message