title: Converting WebLogic MDBs to Spring Message-Driven POJOs
body: <p>I have an application built on WebLogic 11b (10.3.4) using MDBs. I'm trying to convert these to Spring MDPs. Here is the MDB in question:</p>
  
  <pre><code>@MessageDriven(activationConfig = {
          @ActivationConfigProperty(propertyName = "ejbName", propertyValue = "RecipientEventRouterBean"),
          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
          @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
          @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable") })
  public class RecipientEventRouterBean extends TraxMessageRouter {
  
      @Resource
      private int appInstance;
  
      @Resource
      private String appName;
  
      @Resource(mappedName = "jms/TraxErrorQ")
      private Queue errorQueue;
  
      @Resource(name = "TraxCF")
      private ConnectionFactory errorQueueConnectionFactory;
  
      @EJB
      private Logger loggingService;
  
      @Resource
      private int maxJMSXDeliveryCount;
  
      @Resource
      private boolean validate;
  
      @EJB
      protected RecipientRegistrationService recService;
  
      @Override
      @PostConstruct
      public void init() {
  
          if (appName == null) {
              throw new EJBException("appName is null");
          }
  
          try {
              super.traxFactory = TraxFactory.getInstance(Application.fromValue(appName));
              super.processor = new ObjectFactory().createApplicationInstance();
              super.processor.setName(appName);
              super.processor.setInstance(this.appInstance);
              super.errorQueueConnectionFactory = this.errorQueueConnectionFactory;
              super.errorQueue = this.errorQueue;
              super.maxJMSXDeliveryCount = this.maxJMSXDeliveryCount;
              super.validate = this.validate;
              super.loggingService = this.loggingService;
          } catch (Exception e) {
              throw new EJBException(e);
          }
  
          super.init();
      }
  
      @Override
      protected TraxMessageService getTraxMessageService() {
  
          return recService;
      }
  
  }
  </code></pre>
  
  <p>The parent of the MDB, TraxMessageRouter, implements the MessageListener interface.</p>
  
  <p>I've created the MDP beans in the jms-applicationContext.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
      &lt;!-- Spring JMS Destination Resolver --&gt;
      &lt;bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver"&gt;
          &lt;property name="cache" value="true" /&gt;
      &lt;/bean&gt;
  
  
      &lt;!-- Spring JMS Queue Connection Factory leveraging a single connection --&gt;
      &lt;!-- SingleConnectionFactory will return the same Connection on all createConnection calls and ignore calls to close --&gt;
      &lt;bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
          &lt;property name="jndiName" value="jms/TraxCF" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"&gt;
          &lt;property name="connectionFactory" ref="connectionFactory" /&gt;
          &lt;property name="destinationResolver" ref="jmsDestinationResolver" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jmsSender" class="com.mycompany.web.service.jms.JMSSender"&gt;
          &lt;property name="jmsTemplate" ref="jmsTemplate" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jmsReceiver" class="com.mycompany.web.service.jms.JMSReceiver"&gt;
          &lt;property name="jmsTemplate" ref="jmsTemplate" /&gt;
      &lt;/bean&gt; 
  
      &lt;bean id="jmsQueue" class="javax.jms.Topic" /&gt;  
  
      &lt;!-- this is the Message Driven POJO (MDP) --&gt;
      &lt;bean id="messageListener" class="com.mycompany.messaging.RecipientEventRouterBean" /&gt;
  
      &lt;!-- and this is the message listener container --&gt;
      &lt;bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"&gt;
          &lt;property name="connectionFactory" ref="connectionFactory"/&gt;
          &lt;property name="destination" ref="jmsQueue"/&gt;
          &lt;property name="messageListener" ref="messageListener" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>How do I convert the @MessageDriven annotation into the proper Spring syntax? Can I just comment it out now? </p>
  
  <p>I have several more EventRouterBeans. Do they all get bean declarations in the jms-ApplicationContext.xml or can I add the parent, TraxMessageRouter, to the xml?</p>
  
  <p>What other changes to the config files need to be done? Is there a good guide on how to transition from MDBs to MDPs? Is there a good guide on how to transition from EJB 3 to Spring?</p>