Jason Stedman [
http://community.jboss.org/people/jstedman] created the discussion
"Re: Messaging configuration in AS 7"
To view the discussion, visit:
http://community.jboss.org/message/619727#619727
--------------------------------------------------------------
So, I tried the solution proposed by Tom, it seems very logical and "should"
work... it would seem.
Unfortunately I am doing something terribly wrong in my implementation somehow.
You see, the EJB I am creating (pretty much copied from his code, very slight
modification) actually compiles, gets "deployed" by the jboss7 server... sorta..
but does not actually attach to the queue. And I say it gets "deployed" sorta
because it doesnt actually execute any code in the deployment, the log says it deployed,
the admin web console shows it under deployments as being enabled, but adding logger
statements in the constructor does not result in anything printing out. Even putting code
specifically to throw exceptions does not result in any output from this bean, well except
"12:53:07,084 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 2)
Deployed "abean-ejb-0.0.1-SNAPSHOT.jar"
JConsole shows queue/AQueue as being active and the web service that puts messages on the
queue actually does increment the queue counter in JConsole, so it can't be a naming
issue. This is further supported by the fact that putting a name that definitely is
garbage into ABean does not result in a naming exception.
Any ideas?
{//Codeblock
import javax.ejb.*;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.NamingException;
import org.apache.log4j.Logger;
@Stateless
@Singleton
@Startup
public class ABean implements MessageListener
{
public void onMessage(Message aMsg)
{
LOGGER.info("Found a message!" + aMsg.toString());
}
public static final String JMS_QUEUE_NAME = "queue/AQueue";
private static final Logger LOGGER = Logger.getLogger(ABean.class);
Context ic;
MessageConsumer mc;
public ABean(){
LOGGER.info("ABean Constructor Called");
try {
ConnectionFactory cf = (ConnectionFactory)
ic.lookup("ConnectionFactory");
Connection c;
c = cf.createConnection();
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination d = (Destination)ic.lookup(JMS_QUEUE_NAME);
mc = s.createConsumer(d);
mc.setMessageListener(this);
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}//end Codeblock
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/619727#619727]
Start a new discussion in JBoss AS7 Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]