/cmt/src/main/java/org/jboss/as/quickstarts/cmt/mdb/HelloWorldMDB.java
Java | 60 lines | 28 code | 5 blank | 27 comment | 2 complexity | 60de55ad4b34f8698f4df03027e679a8 MD5 | raw file
- /*
- * JBoss, Home of Professional Open Source
- * Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.jboss.as.quickstarts.cmt.mdb;
- import java.util.logging.Logger;
- import javax.ejb.ActivationConfigProperty;
- import javax.ejb.MessageDriven;
- import javax.jms.JMSException;
- import javax.jms.Message;
- import javax.jms.MessageListener;
- import javax.jms.TextMessage;
- /**
- * <p>
- * A simple Message Driven Bean that asynchronously receives and processes the messages that are sent to the queue.
- * </p>
- *
- * @author Serge Pagop (spagop@redhat.com)
- *
- */
- @MessageDriven(name = "HelloWorldMDB", activationConfig = {
- @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
- @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/CMTQueue"),
- @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
- public class HelloWorldMDB implements MessageListener {
- private final static Logger LOGGER = Logger.getLogger(HelloWorldMDB.class.toString());
- /**
- * @see MessageListener#onMessage(Message)
- */
- public void onMessage(Message rcvMessage) {
- TextMessage msg = null;
- try {
- if (rcvMessage instanceof TextMessage) {
- msg = (TextMessage) rcvMessage;
- LOGGER.info("Received Message: " + msg.getText());
- } else {
- LOGGER.warning("Message of wrong type: " + rcvMessage.getClass().getName());
- }
- } catch (JMSException e) {
- throw new RuntimeException(e);
- }
- }
- }