JMS in AS7
gmiller Jul 15, 2011 4:06 PMThis used to work in AS6 -- I have tried to modify things to work in AS7, but can't quite get it working. I am not getting any exceptions, but the messages are not being sent or maybe they are and not being delivered to the message bean.
Any Ideas of what to try next?
I am using AS7 running:
./standalone.sh --server-config=standalone-preview.xml
standalone-preview.xml -- parts
<jms-destinations>
<jms-queue name="stock_market_service_tick_queue">
<entry name="queue/stock_market_service_tick_queue"/>
</jms-queue>
</jms-destinations>
package com.skyviewsoftware.stockmarket.test;
import com.skyviewsoftware.stockmarket.TickPB;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.ManagedBean;
import javax.annotation.Resource;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Queue;
import javax.jms.Session;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@ManagedBean
@Path("stockmarket/test")
public class TestRWS
{
@POST
@Path("sendtickmessage")
public void sendTickMessage()
{
Connection theConnection = null;
Session theSession = null;
MessageProducer theProducer = null;
try
{
theConnection = connectionFactory.createConnection();
theSession = theConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
theProducer = theSession.createProducer(tickQueue);
ObjectMessage theMessage = theSession.createObjectMessage();
TickPB theTick = new TickPB(null, Calendar.getInstance(), null, 0L);
theMessage.setObject(theTick);
theProducer.send(theMessage);
}
catch (Exception inException)
{
logger.log(Level.SEVERE, inException.getMessage(), inException);
}
finally
{
try
{
if (theProducer != null)
{
theProducer.close();
}
if (theSession != null)
{
theSession.close();
}
if (theConnection != null)
{
theConnection.close();
}
}
catch (JMSException inException)
{
logger.log(Level.SEVERE, inException.getMessage(), inException);
}
}
}
private static final Logger logger = Logger.getLogger(TestRWS.class.getName());
@Resource(name = "RemoteConnectionFactory", mappedName = "java:/RemoteConnectionFactory")
private ConnectionFactory connectionFactory;
@Resource(name = "stock_market_service_tick_queue", mappedName = "java:/queue/stock_market_service_tick_queue")
private Queue tickQueue;
}
import com.skyviewsoftware.stockmarket.TickPB;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
@MessageDriven(name="TickMB", activationConfig =
{
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "AUTO_ACKNOWLEDGE"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue="queue/stock_market_service_tick_queue")
})
public class TickMB implements MessageListener
{
public TickMB()
{
}
@Override
public void onMessage(Message inMessage)
{
try
{
TickPB theTick = (TickPB) ((ObjectMessage) inMessage).getObject();
}
catch (JMSException inException)
{
logger.log(Level.SEVERE, inException.getMessage(), inException);
}
}
private static final Logger logger = Logger.getLogger(TickMB.class.getName());
}