Weblogic: receiving messages from a remote HornetQ destination

I’ve talked in former posts about setting up a JMS bridge between Weblogic and HornetQ and how to secure that connection, but the bridge is just appropriate for sending messages from Weblogic to HornetQ, the proper way for receiving data send to HornetQ queues in Weblogic is to implement a Message Driven Bean (MDB), as you can read on the documentation of Weblogic. How to connect the MDB deployed in Weblogic to a HornetQ destination? After a research, I think that the best answer is a Foreign Server.

First of all, I copied the following HornetQ client libraries to a folder residing in a filesystem of my Weblogic server:

  • hornetq-core-client.jar
  • hornetq-jms-client.jar
  • netty.jar
  • jnp-client.jar
  • jboss-logging.jar

Later on, I set the PRE_CLASSPATH variable pointing it to these libraries into the script setDomainEnv and started Weblogic. The next step was to create a new JMS System Module on the console, accepting the defaults.  After that, I edited the module and setup a new Foreign Server with the defaults and I entered its configuration: Weblogic Foreign Server Main Configuration

The following step was to link the destinations (topics and queues) and the connection factories I previously setup on HornetQ. To do this I used the wizards provided by the Weblogic console, it’s easy, I just have to point out that I had to edit the configuration of my connection factory to add the security credentials:

Details of a Foreign Connection Factory

Finally, I mapped the queue and the connection factory in my MDB, here you have an example:

@MessageDriven(mappedName = "jms/Test/TestQueue")
         connectionFactoryJNDIName = "jms/Test/TestXAConnectionFactory")
public class TestMDB implements MessageListener {
    static final Logger logger = LoggingHelper.getServerLogger();

    public void onMessage(Message message) {
        TextMessage msg = null;

        try {
            if (message instanceof TextMessage) {
                msg = (TextMessage) message;
                logger.info("MESSAGE BEAN: Message received: " + msg.getText());
            } else {
                logger.warning("Message of wrong type: " + 
        } catch (JMSException e) {
            logger.severe("TestMDB.onMessage: JMSException: " + e.toString());
        } catch (Throwable te) {
            logger.severe("TestMDB.onMessage: Exception: " + te.toString());

4 Comments on “Weblogic: receiving messages from a remote HornetQ destination”

  1. pinak1514 says:

    Thank you for this post. It is really helpful. But I am new to this so just want to ask you which MDB you have modified?

  2. fcosfc says:

    Hi pinak1514,

    For basic examples about Message-Driven Beans, please read the Java EE Tutorial: http://docs.oracle.com/javaee/6/tutorial/doc/bnbpo.html

    The only different element is the annotation MessageDestinationConfiguration for the use of the HornetQ connection factory.


    Paco Saucedo.

    • pinak1514 says:

      Hi fcosfc,
      Thank you for the mdb tutorial link. That is awesome one. But Still have a question, may be it sounds silly to you. But, I am not able to figure out the MDB you have created where should i put that MDB? Do I have to deploy it somewhere if yes then where and how?
      Please suggest.

      • fcosfc says:

        Hi pinak1514,

        That’s a very basic question, so I sincerely recommend you to review the Java EE Tutorial in order to have the full picture.

        Anyway, the best option is to create an EJB project with your favourite IDE and deploy it to your Weblogic application server.

        I hope this information will be useful for you.


        Paco Saucedo.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s