0
votes

I have a running springboot code which acts a listener and consumes messages from Jboss EAP 7 queue when the code is deployed on STS Tomcat server.

I now need to deploy the same code on the jboss EAP 7 server where the queue is present.

When I deploy the code, I get a message that the war has been deployed successfully. After that NO ERROR or SUCCESS logs are printed.

However, when I check the queue, it shows no consumers. I have tried checking the logs in debugging mode and all I get is the below message. How can I deploy this on jboss and is any specific configuration required? same code is working if we deploy on Tomcat and consume from jboss Q

2019-06-13 22:05:30,715 FINE  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 133) Completed initializing Mojarra (2.2.12-jbossorg-2 ) for context ''{0}''
2019-06-13 22:05:30,715 FINE  [javax.enterprise.resource.webcontainer.jsf.timing] (ServerService Thread Pool -- 133)  [TIMING] - [1025ms] : Initialization of context 
2019-06-13 22:05:30,716 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 133) WFLYUT0021: Registered web context: /
2019-06-13 22:05:30,730 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 129) WFLYSRV0010: Deployed "Sample-0.0.1.war" (runtime-name : "Sample-0.0.1.war")
2019-06-13 22:05:30,730 DEBUG [org.jboss.as.server.deployment.scanner] (ServerService Thread Pool -- 133) Updating status after deployment notification for Sample-0.0.1.war
2019-06-13 22:05:32,942 DEBUG [org.apache.activemq.artemis.core.server] (activemq-expiry-reaper-thread) Cannot expire from jms.queue.ExpiryQueue into jms.queue.ExpiryQueue

My Queue Configuration is as given below:

    @Bean JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,
    DefaultJmsListenerContainerFactoryConfigurer configurer) throws NamingException  { 
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(getConnectionFactory());        
    return factory;

}   

private ConnectionFactory getConnectionFactory() throws NamingException {

    Context namingContext = null;        
    final Properties env = new Properties();
    String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
    String JBOSSQ_USERNAME = "admin";
    String JBOSSQ_PASSWORD = "admin";
    String INTIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
    String PROVIDER_URL = "http-remoting://127.10.10.101:8080";


    env.put(Context.INITIAL_CONTEXT_FACTORY,INTIAL_CONTEXT_FACTORY);
    env.put(Context.PROVIDER_URL,System.getProperty(Context.PROVIDER_URL,PROVIDER_URL));

    try {
        namingContext = new InitialContext(env);

    } catch (NamingException e) {

        e.printStackTrace();
    }


    ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(DEFAULT_CONNECTION_FACTORY);
    UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter = new UserCredentialsConnectionFactoryAdapter(); 
    userCredentialsConnectionFactoryAdapter.setUsername(JBOSSQ_USERNAME); 
    userCredentialsConnectionFactoryAdapter.setPassword(JBOSSQ_PASSWORD); 
    userCredentialsConnectionFactoryAdapter.setTargetConnectionFactory(connectionFactory); 
    return userCredentialsConnectionFactoryAdapter;

    }

My Consumer code is like below:

    @JmsListener(destination = "testingQ", containerFactory = "myFactory")
public void receiveMessage(String msg) {

    System.out.println("Received :" + msg);
1
Share your consumer code and queue configurations - Abhijeet
I have updated the consumer code and queue configuration in the question above. Can you please suggest how this code can be deployed on jboss instead of tomcat? - Ralph Rockmore

1 Answers

0
votes

According to the configuration provided in your code, you are using jms/RemoteConnectionFactory as your default connection factory which means you are trying to connect to queue which created on remote JMS server. It will work if your application is deployed on one server and your JMS is on a different server(remote server). That is why this was successfully working when your application is on Tomcat server and JMS on JBoss server.

To fix the issue, you have to use InVMConnectionFactory. Create a local connection factory and related configurations and refer created connection factory in your code. If created connection factory with JNDI entry as "jms/ConnectionFactory" then your configuration will be like this

String DEFAULT_CONNECTION_FACTORY = "jms/ConnectionFactory";

Note: Also check if your other configurations like PROVIDER_URL(protocol+host+port),context factory are correct.