//use this send the object to the queue public class SendMessagesViaMDB{ //method to get the queue connection
public static javax.jms.QueueConnection getQueueConnection( java.util.Hashtable environment ) throws javax.naming.NamingException, javax.jms.JMSException { // Obtain initial context javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment); try { java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME); return ((javax.jms.QueueConnectionFactory) objRef).createQueueConnection(); } finally { initialContext.close(); } } /** * TO BE CALLED IN THE CLIENT SIDE * @param STUFF */ public void sendSTUFFViaMDB(Collection STUFF) { QueueConnection queueConnection = null; QueueSession jmsSession = null; try { queueConnection = getTravelAgentMailingServiceMDBQueueConnection(); jmsSession = queueConnection.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE); QueueSender sender = jmsSession.createSender(getQueueConnection(JNDI PROPS)); // create the message and set the content ObjectMessage message = jmsSession.createObjectMessage(); message.setObject((ArrayList) STUFF) //send the message sender.send(message); sender.close(); log.debug("Message is written to jms queue"); } catch (JMSException e) { log.error("Sending message via jms failed", e); } catch (NamingException e) { log.error("Sending message via jms failed",e); } catch(ModuleException moduleException) { log.error("Sending message via jms failed", moduleException); } finally { if (queueConnection != null){ try { queueConnection.close(); } catch (JMSException e) { log.error("Closing jms queue connection failed", e); } } if (jmsSession != null){ try { jmsSession.close(); } catch (JMSException e) { log.error("Closing jms session failed", e); } } } } //THE MDB public class MessagingServiceMDB implements MessageDrivenBean, MessageListener { public void onMessage(Message message){ try { ObjectMessage objMessage = (ObjectMessage)message; ArrayList msgProfiles = (ArrayList)objMessage.getObject(); MyMessageManager manager = new MyMessageManager (); manager.processMessages(msgProfiles); } catch (JMSException jmsException) { + jmsException.getMessage(), jmsException); } catch (Exception exception) { + exception.getMessage(), exception); } } View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996602#3996602 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996602 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user