MDB in WildFly 8.0.0.Alpha4
rvcoutinho Dec 18, 2013 6:37 PMHi,
I have been trying to make a simple MDB to work in WildFly 8.0.0.Alpha4 with no success so far.
Looks like the queue has been correctly registered (during initialization), and the message is sent with no exceptions. But the message driven bean is never invoked.
The Message Driven Bean is described below:
@MessageDriven(name = "Queue/AppNotification/Send", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/jms/Queue/AppNotification/Send"), @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") }) @JMSDestinationDefinition(name = "java:/jms/Queue/AppNotification/Send", interfaceName = "javax.jms.Queue", destinationName = "AppNotificationSendQueue") public class AppNotificationSender implements MessageListener { @Override public void onMessage(final Message message) { // Tries to send the application notification. try { // Gets the original notification. AppNotification appNotification = message.getBody(AppNotification.class); ... } // If the JMS message cannot be processed. catch (JMSException exception) { ... } } }
The message producer (apparently working) is defined as following:
@Stateless(name = "Component/Message/AppNotification") public class AppNotificationComponent extends AbstractGenericComponent<AppNotification, Integer> { @Resource(mappedName = "java:/ConnectionFactory") private ConnectionFactory connectionFactory; @Resource(lookup = "java:/jms/Queue/AppNotification/Send") private Queue sendQueue; public void sendMessage(AppNotification notification) { // Asserts that the message is not null. PreConditions.assertParamNotNull(DAOParamKeys.ENTITY, notification); // Validates the current message (and throws an exception for the found violations). ValidationException.throwViolationExceptions(Validation.buildDefaultValidatorFactory().getValidator() .validate(notification)); // Sends the notification to the queue. FIXME // jmsContext.createProducer().send(sendQueue, notification); Connection connection = null; try { // Creates the JMS connection. connection = connectionFactory.createConnection(); // Starts a new JMS session. Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Creates a producer for the send queue. MessageProducer messageProducer = session.createProducer(sendQueue); // Starts the JMS connection. connection.start(); // Creates a new message with the notification. ObjectMessage notificationMsg = session.createObjectMessage(notification); // Sends the message. messageProducer.send(notificationMsg); } // If message cannot be sent. catch (JMSException exception) { // FIXME exception.getCause(); } // At the end. finally { try { // Closes the JMS connection. connection.close(); } // If message cannot be sent. catch (JMSException exception) { // FIXME exception.getCause(); } } } }
Any ideas on what I am doing wrong?
Thanks in advance,
Rômulo Coutinho.