-
1. Re: Injection not working when using thirdparty JMS library
pmuir Dec 3, 2007 6:05 AM (in response to raoul.schmidiger)Post the code for your message listener impl.
-
2. Re: Injection not working when using thirdparty JMS library
pmuir Dec 3, 2007 6:05 AM (in response to raoul.schmidiger)And more importantly, is it declared as an MDB?
-
3. Re: Injection not working when using thirdparty JMS library
svadu Dec 4, 2007 5:21 PM (in response to raoul.schmidiger)It may be generally a good practice to do the business logic in a session bean instead of using JPA directly in your MDB.
However, this is currently a problem when your app is deployed with messages already in the queue: http://jira.jboss.org/jira/browse/JBSEAM-2286 -
4. Re: Injection not working when using thirdparty JMS library
raoul.schmidiger Dec 5, 2007 5:53 AM (in response to raoul.schmidiger)Hi Pete,
No, it is not declared as a MDB. It is clear to me, that this is not the usual way to go. But what about thirdparty libs in general, well yes, that start off some threads and do callbacks on my code? I know it is not considered "good" practice but then again...@Stateful @Name("jmsListener") @Scope (ScopeType.SESSION) public class JmsMessageListener implements MessageListener, IJmsMessageListener { // factor out into properties private static final String SEND_QUEUE = "IN"; private static final String RECEIVE_QUEUE = "OUT"; private ASyncSender asyncSender; //private SyncSender syncSender; @In(create=true, required=true) private IUnderlyingService underlyingService; private IUnderlyingService underlyingServiceHack; @In(create=true, required=true) private IConnectionProvider connectionFactoryProvider; public JmsMessageListener() { System.out.println("constructor: JmsMessageListener"); } @Remove @Destroy public void remove() { System.out.println("destroyed: JmsMessageListener"); } @Create public void init() throws JMSException { MessageSessionProvider messageSessionProvider = new MessageSessionProvider(connectionFactoryProvider.getConnectionFactory()); asyncSender = new ASyncSender(messageSessionProvider, SEND_QUEUE); messageSessionProvider.setMessageListener(RECEIVE_QUEUE, this); //syncSender = new SyncSender(messageSessionProvider, SEND_QUEUE); messageSessionProvider.startConnection(); if(underlyingService == null) { System.out.println("at init, underlyingService is null"); } else { System.out.println("at init, underlyingService is not null"); underlyingServiceHack = underlyingService; } } @Override public void onMessage(Message message) { if(message instanceof ObjectMessage) { try { System.out.println("got a message: " + ((ObjectMessage) message).getObject()); } catch (JMSException e) { e.printStackTrace(); } } else { System.out.println("got a message: " + message); } if (message instanceof ObjectMessage) { ObjectMessage objectMessage = (ObjectMessage) message; try { //... } } catch (JMSException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
-
5. Re: Injection not working when using thirdparty JMS library
pmuir Dec 5, 2007 6:50 AM (in response to raoul.schmidiger)Well you need to integrate them into Seam. Seam uses EJB3 interceptors to intercept all requests to MDB (and SLSB, SFSB) and wrap them in Seam's contexts etc. If you are just calling the object directly (which I think you are) you'll need to set up the contexts yourself. You can look at the ContextHttpServletRequest for an example of how to do this for requests coming in from a servlet.