activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stephanion2002 <stephanion2...@gmail.com>
Subject Not able to run TOMCAT+SPRING+ACTIVEMQ app
Date Tue, 14 Sep 2010 16:15:53 GMT

Hi,

I am trying to run a web application based on spring consisting of
standalone AMQ & Tomcat. I am not able to see my message being
produced/consumed anywhere. This is my code:

TopicSender
=========
import java.io.Serializable;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.jms.Topic;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

public class TopicMessageSender {
private JmsTemplate jmsTemplate;
private Topic topic;

public void produce(final Serializable object) {
System.out.println(“inside produce”);
this.jmsTemplate.send(this.topic, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
ObjectMessage mm = session.createObjectMessage();
mm.setObject(object);
return mm;
}
});
}

@Required
public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}

@Required
public void setTopic(Topic topic) {
this.topic = topic;
}
}

TopicMessageListener1
==================
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;

public class TopicMessageListener1 implements MessageListener{

@Override
public void onMessage(Message message) {
try {
if (message instanceof ObjectMessage) {
ObjectMessage mapMessage = (ObjectMessage) message;
Object obj = mapMessage.getObject();
System.out.println(“Printing from Subs1″+obj);
}
} catch (Exception e) {
// handle exception
}
}
}

Employee
=========
import java.io.Serializable;
import java.util.Date;

public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
String lName=”Garg”;
String fName=”Kshitiz”;
double salary = 25000;
Date hireDate = new Date();
String address=”Gurgaon”;
public String getlName() {
return lName;
}
public void setlName(String lName) {
this.lName = lName;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
this.fName = fName;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public java.util.Date getHireDate() {
return hireDate;
}
public void setHireDate(java.util.Date hireDate) {
this.hireDate = hireDate;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}

Relevant config file settings
====================
 <!-- ActiveMQ Integration starts here -->
    <!-- below are the connection settings for the ActiveMQ -->
    <bean id="connectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL">
                  <value>tcp://localhost:61616</value>
                </property>
            </bean>
        </property>
    </bean>
   
    <!-- Spring JMS Template -->
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
            <ref local="connectionFactory"/>
        </property>
    </bean>

          
    <bean id="tMsgSnd" class="com.hp.activeMQ.TopicMessageSender">
          <property name="jmsTemplate" ref="jmsTemplate" />
          <property name="topic" ref="topicOne" />
    </bean>
   
    <!-- Generate a Topic -->
    <bean id="topicOne" class="org.apache.activemq.command.ActiveMQTopic">
          <constructor-arg value="TOPIC.ONE" />
    </bean>
   
    <!-- Configure a message listener for the above topic -->
    <bean name="topicMessageListener"
class="com.hp.activeMQ.TopicMessageListener1"/>
    <jms:listener-container connection-factory="connectionFactory"
cache="none" destination-type="topic">
          <jms:listener destination="TOPIC.ONE" ref="topicMessageListener"
/>
    </jms:listener-container>

    <!-- Configure a message listener for the above topic -->
    <bean name="topicMessageListener2"
class="com.hp.activeMQ.TopicMessageListener2"/>
    <jms:listener-container connection-factory="connectionFactory"
cache="none" destination-type="topic">
          <jms:listener destination="TOPIC.ONE" ref="topicMessageListener2"
/>
    </jms:listener-container>



I am not able to figure out the exact problem. Can someone please help me ?
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Not-able-to-run-TOMCAT-SPRING-ACTIVEMQ-app-tp2539218p2539218.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message