package de.acardo.test;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJBException;
import javax.ejb.MessageDriven;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;
import org.apache.log4j.Logger;
import org.jboss.ejb3.annotation.Depends;
/*
* Diverse Bindungen fuer den interna Bereich
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/QueueJobStarterEJB3Bean"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "", propertyValue = "") }, name = "QueueJobStarterEJB3Bean", description = "Dies ist die erneute Implementation der gleichen Bean in EJB3", mappedName = "queue/QueueJobStarterEJB3Bean")
@Depends("boss.mq.destination:service=Queue,name=QueueJobStarterEJB3Bean")
public class QueueJobStarterEJB3Bean implements MessageListener,
MessageDrivenBean {
/**
*
*/
private static final long serialVersionUID = 5956028741586188799L;
private MessageDrivenContext messageContext = null;
private Logger log;
public void onMessage(Message message) {
System.out.println("Starte on message");
try {
if (message instanceof ObjectMessage) {
//interna -- sry aber ist ja nicht von relevanc
} else {
this.log.warn("WRONG MESSAGEFORMAT:\n" + message);
}
} catch (Exception ex) {
this.log.error(SystemProperties.getStackTrace(ex, 0));
}
}
/**
*
*/
public void ejbCreate() {
this.log = Logger.getLogger(QueueJobStarterEJB3Bean.class);
}
/**
*
*/
public void ejbRemove() throws EJBException {
this.log = null;
this.setMessageContext(null);
}
/**
* @param messageContext
* the messageContext to set
*/
private void setMessageContext(MessageDrivenContext messageContext) {
this.messageContext = messageContext;
}
/**
* gewuenst durch die Spec
*/
public QueueJobStarterEJB3Bean() {
// TODO Auto-generated constructor stub
}
public void setMessageDrivenContext(MessageDrivenContext _messageContext)
throws EJBException {
this.setMessageContext(_messageContext);
}
}