MessageDriven Bean Duvida

1 resposta
S

Voltando ao EJB 3.0

tenho o seguinte exemplo:

import javax.annotation.PreDestroy;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@MessageDriven(activationConfig = {
		@ActivationConfigProperty(propertyName="destinationType",
								  propertyValue="javax.jms.Queue")
		})
public class LogBean implements MessageListener {

	public LogBean() {
		System.out.println("LogBean created.");
	}

	@PreDestroy
	public void remove() {
		System.out.println("LogBean destroyed.");
	}

	public void onMessage(Message message) {
		if(message instanceof TextMessage) {
			TextMessage textMessage = (TextMessage) message;
			try {
				String text = textMessage.getText();
				System.out.println("Received message : " + text);
			} catch(JMSException e) {
				e.printStackTrace();
			}
		}
	}
}

meu arquivo build

<?xml version="1.0"?>
<project name="EJBTutorial" basedir="." default="init">

	<property name="src" value="src"/>
	<property name="bin" value="bin" />
	<property name="lib" value="lib" />
	<property name="session.jar.file" value="jar/business.ejb3"/>
	<property name="deploy.home" value="C:\\Arquivos de programas\\jboss-4.0.5.GA\\server\\default\\deploy"/>

	<path id="classpath.base">
		<fileset dir="${lib}">
			<include name="*.jar" />
		</fileset>
	</path>

	<target name="init">
		<echo>Iniciando build do EJB tutorial</echo>
	</target>

	<target name="clean" depends="init">
		<delete dir="${bin}"></delete>
	</target>

	<target name="prepare" depends="init">
		<mkdir dir="${bin}" />
	</target>

	<target name="compile" depends="init, clean, prepare">
		<javac srcdir="${src}" destdir="${bin}" verbose="false">
			<classpath refid="classpath.base" />
		</javac>
	</target>

	<target name="packageejbsession" depends="compile">
		<jar jarfile="${session.jar.file}">
			<fileset dir="${bin}">
				<include name="com/**"/>
				<exclude name="com/service/**"/>
				<exclude name="com/testes/**"/>
			</fileset>
		</jar>
	</target>

	<target name="deployejb" depends="packageejbsession">
			<copy file="${session.jar.file}" todir="${deploy.home}" />
	</target>

</project>

quando dou o deploy aparece o seguinte erro.

--- MBeans waiting for other MBeans ---
ObjectName: jboss.j2ee:jar=business.ejb3,name=LogBean,service=EJB3
  State: FAILED
  Reason: org.jboss.deployment.DeploymentException: Required config property Req
uiredConfigPropertyMetaData@12fae6c[name=destination descriptions=[DescriptionMe
taData@d11f32[language=pt]]] for messagingType 'javax.jms.MessageListener' not f
ound in activation config [ActivationConfigProperty(destinationType=javax.jms.Qu
eue)] ra=jboss.jca:service=RARDeployment,name='jms-ra.rar'

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:jar=business.ejb3,name=LogBean,service=EJB3
  State: FAILED
  Reason: org.jboss.deployment.DeploymentException: Required config property Req
uiredConfigPropertyMetaData@12fae6c[name=destination descriptions=[DescriptionMe
taData@d11f32[language=pt]]] for messagingType 'javax.jms.MessageListener' not f
ound in activation config [ActivationConfigProperty(destinationType=javax.jms.Qu
eue)] ra=jboss.jca:service=RARDeployment,name='jms-ra.rar'

Tenho que configurar alguma coisa para poder rodar o bean??!!

Vlw!!!

1 Resposta

S

Bem fiz funcionar…

Adicionou nas configuração da @MessageDrive

@ActivationConfigProperty(propertyName="destination",propertyValue="queue/InputMessageQueue")

codigo complete

import javax.annotation.PreDestroy;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@MessageDriven(activationConfig = {
		@ActivationConfigProperty(propertyName="destination",propertyValue="queue/InputMessageQueue"),
		@ActivationConfigProperty(propertyName="destinationType",
								  propertyValue="javax.jms.Queue")
		})
public class LogBean implements MessageListener {

	public LogBean() {
		System.out.println("LogBean created.");
	}

	@PreDestroy
	public void remove() {
		System.out.println("LogBean destroyed.");
	}

	public void onMessage(Message message) {
		if(message instanceof TextMessage) {
			TextMessage textMessage = (TextMessage) message;
			try {
				String text = textMessage.getText();
				System.out.println("Received message : " + text);
			} catch(JMSException e) {
				e.printStackTrace();
			}
		}
	}
}

Eu tenho outra duvida…

Bem eu tenho um sistema j2se stand-alone, e eu gostaria de pegar um objeto desse sistema e usar no meu MessageDrive para ele descartar a mensagem de acordo com o estado do meu objeto???

Alguem teria ideia??? eu tentei com rmi mas num ta funcionando não!!!
Vlw!!!

Criado 12 de julho de 2007
Ultima resposta 12 de jul. de 2007
Respostas 1
Participantes 1