Jboss Messaging JMS - java

I successfully managed to send the message to queue name ReceiverQueue on my localhost Jboss server, how can I retrieve message I sent to it or how do I check if there is any messages in the queue if any retrieve them. or can I get an explanation of some sort what is the best way to do this. Thank you
A working send/receive tutorial would be accept as well. Anything that will get me to just send to the queue and receive message from that queue will get accepted answer.
I'm using Spring.
I want a solution that does it using application context with bean injection ..

Standard JMS API steps:
1. Create a javax.naming.Context with the access details of the server
context = new InitialContext(environment)
2. Look up javax.jms.QueueConnectionFactory in the context. Factory name is specific to the JMS server
factory = (QueueConnectionFactory)context.lookup(factoryName)
3. Create a javax.jms.QueueConnection
connection = factory.createQueueConnection(...)
4. Create a javax.jms.QueueSession
session = connection.createQueueSession(...)
5. Look up your javax.jms.Queue in the context
queue = (Queue) context.lookup(qJndiName)
Till now it is the same as sending....
6. Create a javax.jms.QueueReceiver with the session
receiver = session.createReceiver(queue)
7. JMS API provides 2 ways to retrieve a message:
7.a Wait for a message with one of the receiver.receive() methods
7.b Implement javax.jms.MessageListener in your class and register it as the listener
receiver.setMessageListener(this)
JMS API will call your onMessage() method whenever a new message arrives
8. Don't forget to start the listener:
connection.start()
9. Close the context (very important, when you access multiple JMS servers from the same program):
context.close()
The above is a typical solution from a stand-alone application. In EJB environment you should use message driven beans. You can find ino on them on http://java.sun.com/javaee/6/docs/tutorial/doc/gipko.html and a tutorial on http://schuchert.wikispaces.com/EJB3+Tutorial+5+-+Message+Driven+Beans
Here is the working example you've asked for:
import java.util.Hashtable;
import javax.naming.*;
import javax.jms.*;
public class JMSJNDISample implements MessageListener {
public static final String JNDI_URL = "jnp://localhost:1099";
public static final String JNDI_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
public static final String JMS_USER = null;
public static final String JMS_PASSWORD = null;
public static final String JMS_CONNECTION_FACTORY = "MyConnectionFactory";
public static final String QUEUE_JNDI_NAME = "ReceiverQueue";
QueueConnection qConn = null;
QueueSession qSession = null;
QueueSender qSender = null;
QueueReceiver qReceiver = null;
public JMSJNDISample () {
}
public void init() throws JMSException, NamingException {
// Set up JNDI Context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, JNDI_URL);
if (JMS_USER != null)
env.put(Context.SECURITY_PRINCIPAL, JMS_USER);
if (JMS_PASSWORD != null)
env.put(Context.SECURITY_CREDENTIALS, JMS_PASSWORD);
Context jndiContext = new InitialContext(env);
// Lookup queue connection factory
QueueConnectionFactory cFactory = (QueueConnectionFactory)jndiContext.lookup(JMS_CONNECTION_FACTORY);
// Create Connection
if (JMS_USER == null || JMS_PASSWORD == null)
qConn = cFactory.createQueueConnection();
else {
qConn = cFactory.createQueueConnection(JMS_USER, JMS_PASSWORD);
}
// Create Session
qSession = qConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// Lookup Queue
Queue queue = (Queue) jndiContext.lookup(QUEUE_JNDI_NAME);
// Create Queue Sender
qSender = qSession.createSender(queue);
// Create Queue Receiver
qReceiver = qSession.createReceiver(queue);
qReceiver.setMessageListener(this);
// Start receiving messages
qConn.start();
// Close JNDI context
jndiContext.close();
}
public void sendMessage (String str) throws JMSException {
TextMessage msg = qSession.createTextMessage(str);
qSender.send(msg);
}
public void onMessage (Message message) {
try {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage)message;
System.out.println("Text Message Received: "+textMessage.getText());
} else {
System.out.println(message.getJMSType()+" Message Received");
}
} catch (JMSException je) {
je.printStackTrace();
}
}
public void destroy() throws JMSException {
if (qSender != null) qSender.close();
if (qReceiver != null) qReceiver.close();
if (qSession != null) qSession.close();
if (qConn != null) qConn.close();
}
public static void main(String args[]) {
try {
JMSJNDISample sample = new JMSJNDISample();
// Initialize connetion
sample.init();
// Send Message
sample.sendMessage("Hello World");
// Wait 2 sec for answer
Thread.sleep(2000);
// Disconnect
sample.destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
}

Other than having a MessageDrivenBean listening to that queue?
EDIT:
You are using spring just to create the payload, right? JMS is a JavaEE spec. You don't need to use Spring for actually sending/receiving messages. You don't have to manually check whether there are messages in the queue etc., either. All you need to do is have an MDB(MessageDrivenBean) set up like this,
#MessageDriven(activationConfig = {
#ActivationConfigProperty(
propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(
propertyName = "destination", propertyValue = "queue/myqueue")
})
public class MyMessageDrivenBean implements MessageListener {
public void onMessage(Message message) {
ObjectMessage objMsg = (ObjectMessage) message;
Payload payload = (Payload)objMsg.getObject();
//do stuff
}
}
And then send some JMS messages.
#Stateless
public class QueuerBean implements QueuerLocal {
#Resource(mappedName = "java:/JmsXA")
private ConnectionFactory jmsConnectionFactory;
#Resource(mappedName = "queue/myqueue")
private Queue queue;
private void queue(MyPayload payload) {
try {
Connection connect = jmsConnectionFactory.createConnection();
Session session = connect.createSession(false,
Session.DUPS_OK_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
// create a JMS message and send it
ObjectMessage objMsg = session.createObjectMessage(payload);
producer.send(objMsg);
producer.close();
session.close();
connect.close();
} catch (JMSException e) {
log.error("Bad thing happened", e);
}
}
}
The queue is configured by the annotation. When a message is sent, JBoss will automatically trigger the MDB.

Here's an example showing how to set up a message-driven POJO in Spring. I'd recommend following this idiom if you're already using Spring.
As for the part about seeing how many messages are on the queue, I'd say you should be using the admin console for JBOSS, not your code.

I would recommend also using a tool like HermesJMS (http://www.hermesjms.com/confluence/display/HJMS/Home) to inspect the queue manager and queues. It's a great debugging tool.

Related

how can I check if a queue exists on Activemq

I have this method that throws me an exception when the data queue doesn't exists, but is not. Do you have other way to solve this?
public void checkDataQueue(String dataQueue) throws JMSException {
Connection connection = null;
Session session = null;
connection = jmsTemplate.getConnectionFactory().createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(dataQueue);
QueueBrowser browser = session.createBrowser(queue);
}
ActiveMQ 5.x creates Queues on demand by default so you may have changed the default configuration to disallow this in which case the error should be expected to happen if you are hitting a non-existent queue and you should check for and handle that. If you need to be sure then the broker provides a JMX interface to query for information on broker statistics etc. There are also other ways of monitoring such as using Rest style calls over the Jolokia management interface.
thank you Tim, I solved it with these method.
public boolean existDataQueue(String dataQueue) throws JMSException {
boolean response = false;
ActiveMQConnectionFactory activeMQConnectionFactory =
new ActiveMQConnectionFactory();
activeMQConnectionFactory.setBrokerURL(brokerUrl);
ActiveMQConnection connection = (ActiveMQConnection)activeMQConnectionFactory.createConnection();
connection.start();
DestinationSource ds = connection.getDestinationSource();
Set<ActiveMQQueue> queues = ds.getQueues();
for (ActiveMQQueue activeMQQueue : queues) {
try {
if(activeMQQueue.getQueueName().equalsIgnoreCase(dataQueue)) {
response = true;
}
} catch (JMSException e) {
e.printStackTrace();
}
}
connection.close();
return response;
}

How can I set expire time of queue message using ActiveMQ by Java Programming?

In this code, I am using setJMSExpiration(1000) for expire message of one second in queue from publisher side. But From Consumer Side, It is returning properly message after 1 second instead of null.
public class RegistrationPublisher extends Thread{
public void run() {
publisherQueue("Registration.Main.*");
}
public void publisherQueue(String server){
try {
String url="tcp://192.168.20.49:61616";
// Create a ConnectionFactory
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(server);
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
String text = "Test";
TextMessage message = session.createTextMessage(text);
message.setJMSExpiration(1000);// For Expire message in one second
producer.send(message);
producer.close();
session.close();
connection.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String args[]) throws IOException{
RegistrationPublisher registrationPublisher=new RegistrationPublisher();
registrationPublisher.start();
}
}
You do this by configuring the JMS MessageProducer to do it for you via the send method that accepts a TTL or by calling setTimeToLive on the producer which adds the same TTL to all sent messages. The JMS APIs for the message version are clear that calling the setters on the message have no effect.
void setJMSExpiration(long expiration) throws JMSException
Sets the message's expiration value.
This method is for use by JMS providers only to set this field when a message is sent. This message cannot be used by clients to configure the expiration time of the message. This method is public to allow a JMS provider to set this field when sending a message whose implementation is not its own.
I first also thought that is was possible to set expiration directly on the message in the post-processor, but as Tim Bish said above, this is not the intended way to do it, and the value will get reset to 0 afterward. I couldn't access to the producer directly neither to set a time to live, because this object was in library org.springframework.jms (I was following this documentation).
One thing I could do was to set to time to live on the jmsTemplate:
import org.springframework.jms.core.JmsTemplate;
#Service
public class MyJmsServiceImpl implements MyJmsService {
#Inject
private JmsTemplate jmsTemplate;
private void convertAndSendToResponseQueue(String targetQueueName, String correlationid, Object message) {
// Set time to live
jmsTemplate.setExplicitQosEnabled(true);
jmsTemplate.setTimeToLive(5000);
jmsTemplate.convertAndSend(targetQueueName, message, new JmsResponsePostProcessor(correlationid));
}
}

How to append errors from the server in a queue using log4j and then to consume them from a client existing in another project

I tried to create a log4j filter that sends all error logs from my tomcat server in a JMS QUEUE and from there to do whatever I want with them.
First I test the functionality because is first time I am working with ActiveMQ, first time I am trying to make a log4j filter:
I added a JMSAppender to log4j2.xml as specified here
<Appenders>
<JMS name="jmsQueue" destinationBindingName="errorLogQueue"
factoryName="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
factoryBindingName="ConnectionFactory"
providerURL="tcp://localhost:61616"/>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="jmsQueue"/>
</Root>
</Loggers>
and I created a class to test the functionality:
public class Log4JjmsAppenderWithActiveMQ implements MessageListener, Runnable{
public static Logger logger2 = LogManager.getLogger(Log4JjmsAppenderWithActiveMQ.class);
public static void main(String[] args) {
(new Thread(new Log4JjmsAppenderWithActiveMQ())).start();
}
#Override
public void run() {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
factory.setTrustAllPackages(true);
Connection connection = null;
Session session = null;
Destination destination = null;
MessageConsumer consumer = null;
try {
connection = factory.createConnection();
connection.start();
session = connection.createSession(false, session.AUTO_ACKNOWLEDGE);
destination = session.createQueue("errorLogQueue");
consumer = session.createConsumer(destination);
consumer.setMessageListener(this);
logger2.error("error 1");
logger2.error("error 2");
logger2.info("info 1");
logger2.debug("debug 1");
} catch (JMSException | InterruptedException e) {
e.printStackTrace();
} finally {
try {
consumer.close();
session.close();
connection.close();
} catch (JMSException e) {
e.printStackTrace();
}
}
}
#Override
public void onMessage(Message message) {
Log4jLogEvent event = null;
try {
event = (Log4jLogEvent)((ActiveMQObjectMessage)message).getObject();
} catch (JMSException e) {
e.printStackTrace();
}
LocalDate date = Instant.ofEpochMilli(event.getTimeMillis()).atZone(ZoneId.systemDefault()).toLocalDate();
System.out.println("Received log [" + event.getLevel() + "]: "+ event.getMessage()+" at time: "+date);
}
}
Running the app I get what I expected. Only errors are logged:
Received log [ERROR]: error 1
Received log [ERROR]: error 2
and also the ActiveMQ says that from 4 logged infos the two with level error were enqueued and dequeued error message.
Well, is first time I am working with ActiveMQ and also I don't know much about configuring servers.
So, my test worked but now I want to run this app when the tomcat starts and to send in the queue the errors that are on the server.
I think I have to change the providerURL value. If so, as host should I put my server host and for port should I use the port used for my server?
My #WebListener class implements ServletContextListener and in it's contextInitialized() method I configure the JMS server by calling the method bellow:
private void configActiveMQServer() {
ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
factory.setTrustAllPackages(true);
Connection connection = null;
Session session = null;
Destination destination = null;
try {
connection = factory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = session.createQueue("errorLogQueue");
} catch (JMSException e) {
e.printStackTrace();
}
}
well, logging on the server the errors doesn't get into the queue.
Maybe the jmsAppender is not the one I am looking for...
So, I am trying to create a custom appender by extending AppenderSkeleton following examples lke: this and this documentation - search for "Appenders" in the documentation to see.
For now, my custom appender looks like:
package com.h4p.server;
import java.io.Serializable;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Level;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAliases;
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
import org.apache.logging.log4j.core.layout.PatternLayout;
#Plugin(name = Log4JErrorAppender.PLUGIN_NAME, category = "Core", elementType = Appender.ELEMENT_TYPE, printObject = true)
#PluginAliases(value="Log4JErrorAppender")
public class Log4JErrorAppender extends AppenderSkeleton{
public static final String PLUGIN_NAME = "Log4JErrorAppender";
#Override
public void close() {
System.out.println("xxx");
}
#Override
public boolean requiresLayout() {
return false;
}
#Override
protected void append(LoggingEvent event) {
if(event.getLevel() == Level.ERROR) {
}
}
#PluginFactory
public static Log4JErrorAppender createAppender(#PluginAttribute("name") String name,
#PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
#PluginElement("Layout") Layout<? extends Serializable> layout,
#PluginElement("Filters") Filter filter) {
if (name == null) {
System.out.println("No name provided for Log4JErrorAppender");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new Log4JErrorAppender();
}
}
and in log4j2.xml I declared:
<Log4JErrorAppender name="errorQueue"/>
but I have this error:
localhost-startStop-1 ERROR appenders Appenders has no parameter that matches element Log4JErrorAppender
Could you please give me a good guide to create a custom appender in order to satisfy my need?
The main question is how to get the errors from my server and send (append) them to a queue from where I can consume the error messages from a client in another project? What log4j appender should I use? Give me some examples.
Thanks!
Everything you did is fine. To break it down, these are the components of your "system":
Log producer - Tomcat that runs an application that produces logs and publishes them to ActiveMQ. Note here, JMSAppender is exactly what you need. You can see an example in the official ActiveMQ documentation: How to use JMS Appender
ActiveMQ instance - you need to set up a standalone ActiveMQ server.
I think I have to change the providerURL value. If so, as host should I put my server host and for port should I use the port used for my server?
You need to provide the host and port as parameters to the JMS Appender (exactly as you did in the log4j xml config).
Log consumer - this can the same application as in (1) or a different one. The correct way to consume messages is by implementing a MessageListener and handling incoming messages in onMessage(..)
As it seems, it's not clear for you how to bootstrap the last component (3). What you need to do is to initialize your message listener inside contextInitialized(...). When you do that, you will have to bind it to a specific topic/queue. This needs to be the same as the one you publish logs to in (1). You can see a brief example below:
public class LogMessageListenerExample implements ServletContextListener
{
#Override
public void contextInitialized(ServletContextEvent arg0)
{
ConnectionFactory conn = createConnectionFactory();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
MessageConsumer consumer = session.createConsumer(sess.createTopic("topic/queue-name-to-listen"));
LogMessageListener listener = new LogMessageListener();
consumer.setMessageListener(listener);
}
private ConnectionFactory createConnectionFactory()
{
// create connection factory with host and port for your ActiveMQ instance
}
}
public class LogMessageListener implements MessageListener
{
public void onMessage(Message message)
{
// handle message
}
}

JMS how to get mulitple messages with JMSMessageListener

I m trying to sent to a consumer a message from client. Consumer expects many message types like Booking or Confirmation. So when i get the message i m trying to see if the message is instance of Booking or Confirmation. So far the instance of is not working, i cant see if the object is Booking or Confirmation. Besides my JMSMessageListener doesnt seem to be the best way of doing the scenario.
The scenario is :
Client sends a Booking to agent, agent forwards the message to different consumers, agent gets confirmation from consumers and sends a confirmation back.
Any ideas why instance of not working and for this scenario, is this a good way to implement a JMSMessageListener to an agent for multiple purposes ?
//JMS Message Listener
public class JMSAgentMessageListener implements MessageListener {
private ConnectionFactory factory = null;
private Connection connection = null;
private Session session = null;
private Destination BookingQueue = null;
private Destination consolidatorQueue1 = null;
private Destination consolidatorQueue2 = null;
private MessageConsumer consumer = null;
private Destination agentConfirmQueue = null;
private static MessageProducer producer = null;
final static Logger logger = Logger.getLogger(TravelAgent.class);
private Destination customerConfirmQueue = null;
#Override
public void onMessage(Message message) {
try {
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory( "tcp://localhost:61616");
// Create a Connection
Connection connection = connectionFactory.createConnection();
session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
if (message instanceof Booking) {
Booking booking = (Booking) message;
logger.info("# Received order for " + booking.getCustomer());
customerConfirmQueue = message.getJMSReplyTo();
logger.info("# The travel agent forwards booking orders to the airfare consolidators");
ObjectMessage messageToConsilator1 = session . createObjectMessage ( booking ) ;
agentConfirmQueue = session.createQueue("AgentConfirmQueue");
consolidatorQueue1 = session.createQueue("ConsolidatorQueue1");
messageToConsilator1.setJMSReplyTo(agentConfirmQueue);
messageToConsilator1.setJMSDestination(consolidatorQueue1);
producer = session.createProducer(consolidatorQueue1);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.send(messageToConsilator1);
}else if(message instanceof Confirmation){
logger.info("# The travel agent recieved booking orders to the airfare consolidators");
Confirmation confirmation = (Confirmation) message;
logger.info(confirmation.getMessage()+"received");
logger.info("# The travel agent notfiying the customers");
ObjectMessage messageToClient = session . createObjectMessage ( confirmation ) ;
customerConfirmQueue = session.createQueue("customerConfirmQueue");
producer = session.createProducer(customerConfirmQueue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.send(messageToClient);
}
producer.close();
session.close();
connection.close();
} catch (JMSException e) {
logger.error("couldnt get the message");
}
}
}
Message isn't in the hierarchy of your class inheritance tree. JMS offers, different types of messages that can be disseminated, Text, Object, etc., all inheriting from Message. It is these types that you could call instance of on. Once Message is cast to an ObjectMessage, you can then call getObject() and then cast it/check instanceof for your types.
I'd recommend limiting types of messages that can be sent on a topic as it lends itself to some messier code. I try to avoid using instanceof if at all possible by refactoring the code in a way that makes it unnecessary. To reduce the need for instanceof, I'd create a topic per type of information being conveyed or develop your classes in such a way that they inherit from the same parent or implement the same interface.

Message Driven Bean with a Datasource

My question is how do I configure an EJB 3.0 style message driven bean to use a configured JMS datasource in jboss.
For example, my MDB looks something like:
#MessageDriven(mappedName = "ExampleMDB", activationConfig = {
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "MyTopic"),
#ActivationConfigProperty(propertyName = "channel", propertyValue = "MyChannel"),
})
#ResourceAdapter(value = "wmq.jmsra.rar")
#TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
#TransactionManagement(TransactionManagementType.BEAN)
public class MyMDB implements MessageListener {
.....
}
But I would like the bean to attached to a given JMS datasource ( in the case of jboss 4.2.2 this is in deploy/jms/jms-ds.xml). Perhaps this is not even possible but is worth asking.
If I understood your problem correctly, MyMDB listens to a topic on WebLogic, and you want to use an additional JMS destination provided by JBoss, defined in a deployed configuration file and identified by its JNDI name (by default, deploy/jms/jms-ds.xml only contains the configuration for the JMS provider and connection factories -- no data sources).
The easiest way is to let the container inject the JMS destination and a connection factory via its JNDI name (in JBoss the JMS destinations are configured by deploying xxx-service.xml files). On startup you can then initialize the connection, and perform cleanup as soon as the MDB is released.
The following examples shows injection (#Resource) and resource managemend (#PostConstruct and #PreDestroy). The JMS connection and destination is used in useJmsDestination(String) to send a text message.
public class MyMDB implements MessageListener {
#Resource(mappedName = "queue/YourQueueName") // can be topic too
private Queue targetDestination;
#Resource(mappedName = "QueueConnectionFactory") // or ConnectionFactory
private QueueConnectionFactory factory;
private Connection conn;
public void onMessage(Message m) {
// parse message and do what you need to do
...
// do something with the message and the JBoss JMS destination
useJmsDestination(messageString);
}
private void useJmsDestination(String text) {
Session session = null;
MessageProducer producer = null;
try {
session = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(targetDestination);
TextMessage msg = session.createTextMessage(text);
producer.send(msg);
} catch (JMSException e) {
throw new RuntimeException(e);
} finally {
try {
if (producer != null) {
producer.close();
}
if (session != null) {
session.close();
}
} catch (JMSException e) {
// handle error, should be non-fatal, as the message is already sent.
}
}
}
#PostConstruct
void init() {
initConnection();
// other initialization logic
...
}
#PreDestroy
void cleanUp() {
closeConnection();
// other cleanup logic
...
}
private void initConnection() {
try {
conn = factory.createConnection();
} catch (JMSException e) {
throw new RuntimeException("Could not initialize connection", e);
}
}
private void closeConnection() {
try {
conn.close();
} catch (JMSException e) {
// handle error, should be non-fatal, as the connection is being closed
}
}
}
I hope this can help you.
I think what you are asking is "How do I specify the JNDI location of the JMS datasource to use for an MDB?"
In which case the answer is:
#ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue = "java:/DefaultJMSProvider")
Also, take a look at the following page which provides loads of useful details on configuring MDBs in jBoss:
http://www.jboss.org/community/docs/DOC-9352

Categories

Resources