Not able to send message to a Topic configured on WildFly 9.Need help
chandrasachin16 Aug 3, 2015 12:04 AMHi All,
I am trying to deploy message driven bean on WildFly 9.0.0 (wildfly-9.0.0.Final) which I am doing for the first time.My jar contaning the MDB is getting deployed properly,but when I try to put a message through a java client it doesn't work.The exception which I get while running my client is as below-
java.lang.UnsupportedOperationException: Cannot specify destination if producer has a default destination-
My test Client java file is as below--
public class TestClient {
public final static String JNDI_FACTORY="org.jboss.naming.remote.client.InitialContextFactory";
//*************** Using the RemoteConnectionFactory JNDI name *************************
public final static String JMS_FACTORY="jms/RemoteConnectionFactory";
//*************** Created Queue's JNDI name *************************
private static TopicConnectionFactory tConFactory;
private static TopicConnection tCon;
private static TopicSession tSession;
private static Topic topic;
public static void main(String[] args) throws JMSException, NamingException {
Context context=getInitialContext();
tConFactory = (TopicConnectionFactory) context.lookup(JMS_FACTORY);
//*************** Creating Queue Connection using the UserName & Password *************************
tCon = tConFactory.createTopicConnection("sachin2","Mycomputer@1234");//<------------- Change the UserName & Password
tSession = tCon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
topic = (Topic) context.lookup("jms/topic/test");
TopicPublisher publisher=tSession.createPublisher(topic);
System.out.println("before writing message...................");
TextMessage msg=tSession.createTextMessage();
msg.setText("Hello sachin........");
System.out.println("After setting message...................");
publisher.send(topic, msg);
System.out.println("After sending...................");
tCon.start();
}
private static Context getInitialContext() throws NamingException{
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,"http-remoting://localhost:8080");
jndiProps.put(Context.SECURITY_PRINCIPAL, "sachin2");
jndiProps.put(Context.SECURITY_CREDENTIALS, "Mycomputer@1234");
jndiProps.put("jboss.naming.client.ejb.context", true);
Context ctx = new InitialContext(jndiProps);
return ctx;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////// Wild Fly Server logs//////////////////////////////////////////////////////////////////////////////////////////////////////////
The similar thing was working on Jboss AS 7.
If you see the logs below it shows the MDB is started(highlighted in bold)
java:/ConnectionFactory
2015-08-03 09:21:18,617 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 74) HQ221003: trying to deploy queue jms.queue.DLQ
2015-08-03 09:21:18,631 INFO [org.jboss.as.messaging] (ServerService Thread Pool -- 76) WFLYMSG0002: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
2015-08-03 09:21:18,637 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 73) HQ221003: trying to deploy queue jms.topic.testTopic
2015-08-03 09:21:18,638 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-2) WFLYJCA0007: Registered connection factory java:/JmsXA
2015-08-03 09:21:18,645 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 75) HQ221003: trying to deploy queue jms.queue.ExpiryQueue
2015-08-03 09:21:18,697 INFO [org.hornetq.ra] (MSC service thread 1-2) HornetQ resource adaptor started
2015-08-03 09:21:18,700 INFO [org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-2) IJ020002: Deployed: file://RaActivatorhornetq-ra
2015-08-03 09:21:18,704 INFO [org.jboss.as.connector.deployment] (MSC service thread 1-2) WFLYJCA0002: Bound JCA ConnectionFactory [java:/JmsXA]
2015-08-03 09:21:18,704 INFO [org.jboss.as.messaging] (MSC service thread 1-4) WFLYMSG0002: Bound messaging object to jndi name java:jboss/DefaultJMSConnectionFactory
2015-08-03 09:21:19,350 INFO [org.jboss.ws.common.management] (MSC service thread 1-3) JBWS022052: Starting JBoss Web Services - Stack CXF Server 5.0.0.Final
2015-08-03 09:21:21,131 INFO [org.jboss.as.ejb3] (MSC service thread 1-3) WFLYEJB0042: Started message driven bean 'AcccountMessageProcessor' with 'hornetq-ra.rar' resource adapter
2015-08-03 09:21:21,260 INFO [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0010: Deployed "AccountEJB.jar" (runtime-name : "AccountEJB.jar")
My standalone-full.xml jms configuration is below where I have configured my topic as below-
<jms-destinations>
<jms-queue name="ExpiryQueue">
<entry name="java:/jms/queue/ExpiryQueue"/>
</jms-queue>
<jms-queue name="DLQ">
<entry name="java:/jms/queue/DLQ"/>
</jms-queue>
<jms-topic name="testTopic">
<entry name="java:jboss/exported/jms/topic/test"/>
</jms-topic>
</jms-destinations>
I am not sure why this is not happening though the entry of topic starts with java:jboss/exported
Can anybody please guide me.
Regards
Sachin