Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Message Driven bean implements other interface than MessageListener?

I am new to java enterprise and trying to understand message driven beans. I have implemented a MDB, together with a remote interface, willing my MDB to implement both MessageListener and the remote interface RemoteEjbSenderInterface. Just like that:

@Remote
public interface RemoteEjbSenderInterface
{
public void sendMessage(String mess) throws JMSException;
}

and the MDB

@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName =    
                                       "messageSelector", propertyValue = "SenderType = 
                                        Receiver"),
                    @ActivationConfigProperty(propertyName =  
                                        "destinationType", propertyValue = 
                                        "javax.jms.Queue"),
                    @ActivationConfigProperty(propertyName = 
                                        "destination", propertyValue = "queue/test")})
public class EjbSender implements MessageListener, RemoteEjbSenderInterface
{
 ...    
}

the problem is that when deploying the application, I get an error saying:

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: EJB 3.1 FR 5.4.2 MessageDrivenBean com.ericsson.ejb.sender.EjbSender does not implement 1 interface nor specifies message listener interface

this makes me think maybe message driven bean can ONLY implement MessageListener interface and nothing else?

Thanks in advance for your help

like image 213
user3635684 Avatar asked Feb 13 '23 23:02

user3635684


1 Answers

If you implement multiple interfaces, you should specify which one is the message listener interface using the attribute messageListenerInterface of the @MessageDriven annotation.

Example:

@MessageDriven(messageListenerInterface=MessageListener.class)
like image 105
Erwin Bolwidt Avatar answered Feb 15 '23 13:02

Erwin Bolwidt