0

i am using jboss 7.1 and configure the sender to send the message into Hornet queue. I can see in Jboss admin console that message count is increasing once sender sends the message but MDB is not consuming the message. Both sender and consumer are running in same application(same java process/jvm). Below is the configuration in jboss Standalone-full.xml.

 <jms-connection-factories>
                    <connection-factory name="InVmConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/ConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <connection-factory name="RemoteConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="netty"/>
                        </connectors>
                        <entries>
                            <entry name="RemoteConnectionFactory"/>
                            <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <pooled-connection-factory name="hornetq-ra">
                        <transaction mode="xa"/>
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/JmsXA"/>
                        </entries>
                    </pooled-connection-factory>
                </jms-connection-factories>

                <jms-destinations>
                    <jms-queue name="testQueue">
                        <entry name="queue/MyQueue"/>
                        <entry name="java:jboss/exported/jms/queue/test"/>
                    </jms-queue>
                </jms-destinations>

Message sender:

Context context = new InitialContext();
QueueConnectionFactory factory = (QueueConnectionFactory)context.lookup("ConnectionFactory");
QueueConnection connection = factory.createQueueConnection();
QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
Queue queue = (Queue)context.lookup("queue/MyQueue");
QueueSender sender = session.createSender(queue);

//1. Sending TextMessage to the Queue 
TextMessage message = session.createTextMessage();
message.setText("Hello EJB3 MDB Queue!!!");
sender.send(message);

MDB:

@MessageDriven(name="MessageDistributor", activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/MyQueue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class MessageReceiver implements MessageListener  {  
 public void onMessage(Message message) {
        System.out.println("Message received from Queue...");
    }
}

There is no error or exception in jboss logs. I can see message going to queue but not consumed by MDB. Thanks in Advance.

code1234
  • 121
  • 1
  • 2
  • 11
  • something's bugging me about having the sender being AUTO_ACKNOWLEDGE, haven't done HornetQ but I seem to remember having problems with that in ActiveMQ...also see you are using XA, is it possible that the message has been written but the transaction not completed and therefore can't get message passed to MDB? Otherwise things look proper. – Scott Sosna Feb 11 '16 at 01:54
  • @ScottSosna .. Thanks for the reply. I tried by removing AUTO_ACKNOWLEDGE but still MDB is not picking up. I used same configuration and created 2 separate application running on Jboss and everything is working. – code1234 Feb 11 '16 at 03:36
  • I was actually thinking about sender, not consumer, but I'm not sure. – Scott Sosna Feb 11 '16 at 12:50

1 Answers1

0

Your sender should be sending to "/jms/queue/test" not "queue/MyQueue". Only "/jms/queue/test" is exposed externally. That assuming it's running in a separate JVM.

Tom Ross
  • 36
  • 3