I am testing the connectivity of Wildfly16 / JBoss 7.2 with ActiveMQ Artemis 2.7.
I have written a simple MDB, and it can consume messages from the remote ActiveMQ Artemis server.
I get correctly the payload (text message) and the CorrelationId, but the received MessageId is null! This looks weird and is very annoying as I want to implement request/reply.
Below the code of the MDB
import java.util.Properties;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.ejb3.annotation.ResourceAdapter;
@ResourceAdapter("activemq-ra-remote")
@MessageDriven(name = "JmsTestMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "testReqQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class WildflyMdb implements MessageListener {
private static final Logger LOGGER = Logger.getLogger(WildflyMdb.class.toString());
public void onMessage(Message rcvMessage) {
TextMessage txtMessage = null;
try {
if (rcvMessage instanceof TextMessage) {
txtMessage = (TextMessage) rcvMessage;
LOGGER.info("Received Message from queue: MessageId=" + rcvMessage.getJMSMessageID() +
", CorrelationId=" + rcvMessage.getJMSCorrelationID() +
", Text='" + txtMessage.getText() + "'");
LOGGER.info("rcvMessage (toString): " + rcvMessage.toString());
} catch (Exception e) {
LOGGER.severe("EXCEPTION:" + e.getMessage());
}
}
When I send following message with my Java client :
I get the following log from the MDB in Wildfly:
16:23:29,694 INFO [class com.fluide.mdb.WildflyMdb] (Thread-360 (ActiveMQ-client-global-threads)) Received Message from queue: MessageId=null, CorrelationId=CID:20190624180910, Text='This is my test message'
16:23:29,695 INFO [class com.fluide.mdb.WildflyMdb] (Thread-360 (ActiveMQ-client-global-threads)) rcvMessage (toString): ActiveMQMessage[null]:PERSISTENT/ClientMessageImpl[messageID=946860, durable=true, address=testReqQueue,userID=null,properties=TypedProperties[__AMQ_CID=ID:DEVTEMP-PC-49242-1561392550500-0:1,_AMQ_GROUP_SEQUENCE=0,__HDR_BROKER_IN_TIME=1561392550749,_AMQ_ROUTING_TYPE=1,__HDR_ARRIVAL=0,__HDR_REPLY_TO=[0000 0011 6401 000D 7465 7374 5265 7370 5175 6575 65),__HDR_COMMAND_ID=5,JMSCorrelationID=CID:20190624180910,__HDR_PRODUCER_ID=[0000 0039 7B01 0025 4944 3A44 4556 5445 4D50 2D50 432D 3439 3234 322D 3135 ... 31 3339 3235 3530 3530 302D 313A 3100 0000 0000 0000 0100 0000 0000 0000 01),__HDR_MESSAGE_ID=[0000 004C 6E00 017B 0100 2549 443A 4445 5654 454D 502D 5043 2D34 3932 3432 ... 0000 0000 0001 0000 0000 0000 0001 0000 0000 0000 0001 0000 0000 0000 0000),__HDR_DROPPABLE=false]]
As you can see, the MessageId
returns as null which doesn't look right.
Any ideas?
Since you're sending the message with a standalone Java client using the OpenWire protocol from activemq-all-5.12.0.jar
and receiving the message with an MDB on Wildfly/EAP using the Artemis core protocol I believe you're hitting this bug in ActiveMQ Artemis which causes messages sent and received with different protocols to have null a message ID. A pull-request has been sent already so the issue should be fixed for 2.10.0.
If you don't want to wait for 2.10.0 to be released then you can work-around the issue by using the Artemis core JMS client implementation from your standalone Java application. Just drop in the Artemis client jar (from the <ARTEMIS_HOME>/lib/client directory) and change the initial context factory to org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
.