You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by hasonemaster <ha...@gmail.com> on 2014/03/19 19:19:01 UTC
ActiveMQ Stomp Tomee Problem
Hi
I have past many days trying to use stomp as protocol of messaging in
activeMQ and tomee.
I have made a test to send messages(e.g : "Hello world") from a backoffice
deployed in tomee to a client spring, this test work very well with tcp but
it doesn't work with stomp.
Here's my code :
server side :
====> Pom :
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>${jettison-version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-stomp</artifactId>
<version>5.8.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
.....
<groupId>org.apache.openejb.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>${tomee-maven-plugin.version}</version>
<extensions>true</extensions>
....
<libs>
<lib>org.codehaus.jettison:jettison:${jettison-version}</lib>
<lib>org.apache.activemq:activemq-stomp:5.8.0</lib>
</libs>
.....
====> Tomee :
<Resource id="MyResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig =
broker:(stomp://localhost:61613)?persistent=false
ServerUrl = vm://localhost
</Resource>
<Resource id="MyJmsConnectionFactory"
type="javax.jms.ConnectionFactory">
ResourceAdapter = MyResourceAdapter
</Resource>
<Container id="MyJmsMdbContainer" ctype="MESSAGE">
ResourceAdapter = MyResourceAdapter
</Container>
<Resource id="MyQueue" type="javax.jms.Queue"/>
<Resource id="MyTopic" type="javax.jms.Topic"/>
Code de test :
@Resource(name = "MyJmsConnectionFactory")
private ConnectionFactory factory;
@Resource(name = "MyQueue")
private Queue myQueue;
.......
public void sendMessage() {
Connection connection = factory.createConnection();
Session session = connection.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(myQueue);
connection.start();
producer.send(session.createTextMessage("Hello world"));
producer.close();
session.close();
connection.close();
}
Client side :
===> POM :
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-stomp</artifactId>
<version>5.9.0</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.4</version>
</dependency>
=====> Spring xml :
<bean id="amqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<constructor-arg index="0" value="stomp://localhost:61613"
/>
</bean>
<bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg ref="amqConnectionFactory" />
</bean>
<bean id="messageReceiver"
class="com.services.common.MessageQueueListener" />
<jms:listener-container connection-factory="connectionFactory"
destination-type="queue">
<jms:listener destination="myQueue" ref="messageReceiver" />
</jms:listener-container>
=====> MessageQueueListener :
public class MessageQueueListener implements MessageListener {
Logger log = LoggerFactory.getLogger(getClass());
public void onMessage(Message message) {
log.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<< message recieved");
if (message != null && message instanceof TextMessage) {
try {
log.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
" + ((TextMessage) message).getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}
Please Help me!!!!
--
View this message in context: http://openejb.979440.n4.nabble.com/ActiveMQ-Stomp-Tomee-Problem-tp4668273.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.