Subscribing to topic on different AS version
seacuke23 Sep 9, 2013 11:17 AMI have a simple publisher/subscriber that I'm trying to get working across different servers. I need a subscriber MDB to run on a JBoss EAP 6.1 server being driven by a topic on a JBoss 7.1.1 server. My hornetq versions appear to be 2.3.1.Final-redhat-1 on EAP and 2.2.13.Final on 7.1.1. My simple example works as I'd expect it when I'm using either both EAP servers or both 7.1.1 servers, but when I try my desired configuration (EAP 6.1 - 7.1.1) I get the following:
09:12:16,866 INFO [org.hornetq.ra] (default-threads - 1) HQ151001: Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@18
dad2f destination=topic3 destinationType=javax.jms.Topic ack=Auto-acknowledge durable=false clientID=null user=testuser password=**** maxSession=15)
And I never end up connecting or getting any messages in the MDB.
My code follows:
@Singleton @Startup public class NotifierSingleton { @Resource private TimerService ts; @Resource(lookup = "java:/topic/mytopic3") private Destination d; @Resource(lookup = "java:/ConnectionFactory") private ConnectionFactory cf; private static final Logger l = Logger.getLogger(NotifierSingleton.class); @PostConstruct public void pc() { ts.createIntervalTimer(5000, 5000, new TimerConfig(null, false)); } @Timeout public void timeout() { Connection conn = null; Session sess = null; MessageProducer mp = null; try { conn = cf.createConnection(); sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); mp = sess.createProducer(d); l.info("Sending message"); mp.send(sess.createTextMessage("notification message")); } catch (Exception e) { l.error("", e); } finally { if (mp != null) { try { mp.close(); } catch (Exception e) { l.error("", e); } } if (sess != null) { try { sess.close(); } catch (Exception e) { l.error("", e); } } if (conn != null) { try { conn.close(); } catch (Exception e) { l.error("", e); } } } } }
public class MyTopicSubscriber implements MessageListener { private static final Logger l = Logger.getLogger(MyTopicSubscriber.class); /** * @see javax.jms.MessageListener#onMessage(javax.jms.Message) */ @Override public void onMessage(Message arg0) { System.out.println("here"); l.info("Received message - " + arg0); if (arg0 instanceof TextMessage) { try { l.info("Message contents - " + ((TextMessage) arg0).getText()); } catch (JMSException e) { l.error("Failed to get text from message.", e); } } } } }
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1"> <display-name>TopicSubscription</display-name> <enterprise-beans> <message-driven> <ejb-name>TopicSubscriber</ejb-name> <ejb-class>com.marcdejose.test.TopicSubscription.MyTopicSubscriber</ejb-class> <activation-config> <activation-config-property> <activation-config-property-name>destinationType</activation-config-property-name> <activation-config-property-value>javax.jms.Topic</activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name>destination</activation-config-property-name> <activation-config-property-value>topic3</activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name>connectorClassName</activation-config-property-name> <activation-config-property-value>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name>connectionParameters</activation-config-property-name> <activation-config-property-value>host=localhost;port=5545</activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name>user</activation-config-property-name> <activation-config-property-value>testuser</activation-config-property-value> </activation-config-property> <activation-config-property> <activation-config-property-name>password</activation-config-property-name> <activation-config-property-value>testpass</activation-config-property-value> </activation-config-property> </activation-config> </message-driven> </enterprise-beans> </ejb-jar>
I thought maybe I should try driving my MDB from the resource adapter from the same version of HornetQ as I have running on 7.1.1, but believe I ran into this bug:
https://issues.jboss.org/browse/HORNETQ-1030?page=com.atlassian.jirafisheyeplugin:fisheye-issuepanel
Do I have something misconfigured? Should I expect my MDB on EAP to work with the libraries in place or is it correct that I should be using the HornetQ RA with the same version? Should I have posted this in the AS forum?