package jboss5.ejb3.mdb;

import java.util.HashMap;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB;
import javax.ejb.EJBException;
import javax.ejb.MessageDriven;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.naming.InitialContext;

        activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName="destination", propertyValue="queue/Queue1"),
@EJB(name = "EJB3MessageDrivenLocal1", beanInterface = EJB3MessageDrivenLocal.class)

public class EJB3MessageDrivenBean implements MessageDrivenBean, MessageListener
    ObjectMessage msg = null;
    private MessageDrivenContext mdc = null;

    public EJB3MessageDrivenBean() {}

    public void setMessageDrivenContext(MessageDrivenContext mdc) {
        this.mdc = mdc;

    public void onMessage(Message inMessage) {

    public void ejbRemove() throws EJBException {
        // TODO Auto-generated method stub



Above code is my message driven bean and working fine for single queue 'Queue1'. Now i want to associate Queue2 to same mdb.
I can do the same thing by creating another mdb class "EJB3MessageDrivenBean2" and by just changing activationConfig property as follow.


        activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName="destination", propertyValue="queue/Queue2"),



but in this method i have to replicate my code and in future if i have to associate another queue Queue3 then i have to again replicate java file.

Any other method by changing in xml file or any other method.