[jboss-user] [JBoss Seam] - Re: Calling Seam's component from MDB thew java.lang.Illegal

tonylmai do-not-reply at jboss.com
Mon Aug 27 16:24:39 EDT 2007


Hi Pete,

Here is my Seam's component:

@Scope(ScopeType.APPLICATION)
  | @Name("wcTickerPlant")
  | @Startup
  | @Restrict("#{identity.loggedIn}")
  | public class TickerPlant {
  |     private Map<String, Quote> quotesMap = new ConcurrentHashMap<String, Quote>();
  |     ...
  | 
  |     @Create
  |     public void refreshQuotes() {
  |         ....
  |     }
  |     
  |     @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
  |     public void updateFullQuote(FullQuote quote) {
  |         quotesMap.put(quote.getSymbol(), new Quote(quote));
  |     }
  | 
  |     ....
  | }

And my MDB

@MessageDriven(activationConfig = {
  |       @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic")
  |       , @ActivationConfigProperty(propertyName="destination", propertyValue=ClientConfiguration.MARKET_DATA_TOPIC_NAME)
  | //      , @ActivationConfigProperty(propertyName="DLQMaxResent", propertyValue="10")
  |                 })
  | @Name("quotesListener")
  | public class QuoteBroadcastListener implements javax.jms.MessageListener {
  |     @Logger
  |     private Log logger;
  |     
  |     @In("wcTickerPlant")
  |     private TickerPlant tickerPlant;
  |     
  |     @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
  |     public void onMessage(Message msg) {
  |         if (msg == null || !(msg instanceof ObjectMessage)) {
  |             return;
  |         }
  |         
  |         if (logger != null) {
  |             logger.debug("Received message as=%1", msg);
  |         }
  |         Serializable payload = null;
  |         try {
  |             payload = ((ObjectMessage) msg).getObject();
  |         } catch (JMSException e) {
  |             if (logger != null) {
  |                 logger.fatal("Unable to obtain payload in msg. Exception=", e.getLocalizedMessage());
  |             }
  |             return;
  |         }
  |         
  |         // What type of object is it?
  |         if (payload instanceof FullQuoteBroadcastMessage) {
  |             FullQuoteBroadcastMessage fullQuoteMsg = (FullQuoteBroadcastMessage) payload;
  |             FullQuote fullQuote = fullQuoteMsg.getFullQuote();
  |             tickerPlant.updateFullQuote(fullQuote);
  |         } else if (payload instanceof ...) {
  |             ...
  |         }
  |     }
  | }

Let me know if you find anything wrong. Thanks again Pete.
-tony

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078500#4078500

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078500



More information about the jboss-user mailing list