001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *       http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.samples.order;
018    
019    import java.io.BufferedWriter;
020    import java.io.File;
021    import java.io.FileWriter;
022    import java.io.IOException;
023    import java.util.Date;
024    
025    import javax.annotation.Resource;
026    import javax.ejb.MessageDriven;
027    import javax.ejb.ActivationConfigProperty;
028    import javax.ejb.EJBException;
029    import javax.ejb.MessageDrivenBean;
030    import javax.ejb.MessageDrivenContext;
031    import javax.jms.JMSException;
032    import javax.jms.Message;
033    import javax.jms.MessageListener;
034    import javax.jms.TextMessage;
035    
036    //
037    // MessageDrivenBean that listens to items on the
038    // 'OrderQueue' queue and processes them accordingly.
039    //
040    @MessageDriven(activationConfig = {
041                       @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
042                       @ActivationConfigProperty(propertyName="destination", propertyValue="OrderQueue")
043                   })
044    public class OrderRecvMDB implements MessageListener {
045    
046        private static final String ORDER_MGMT_INFO = "order_mgmt.properties";
047        private static final String ORDER_REPO = "order.repo";
048    
049        public OrderRecvMDB() {
050    
051        }
052    
053        /*
054         * Process a message. <br>
055         * 
056         * @param message The message to process. 
057         */
058        public void onMessage(Message message) {
059            TextMessage textMessage = (TextMessage) message;
060            try {
061                System.out.println("Order Received \n"+ textMessage.getText());
062            }
063            catch ( JMSException e ) {
064                e.printStackTrace();
065            }
066        }
067    }