After lots of struggle i got the answer.
In JBoss EAP 7 server supports Apache ActiveMQ Artemis. which are inbuilt in JBoss EAP 7 server, but some downloaded JBoss EAP 7 servers may not contain Apache ActiveMQ Artemis, by which you may not find Messaging-ActiveMQ in jboss subsystem. For this you need to configure manually in standalone.xml file.
Below follow the steps for configuration.
Step-1
Start JBoss EAP 7 server
step-2
• Run add-user.bat file from cd /PATH/TO/JBoss-EAP-7.0/bin.
• For linux server need to ./add-user.sh command.
After running a cmd will appear.
then a cmd will appear. here you need to add new application user.
Let your:
username: jmsuser,
password: jmsuser@123,
user role: guest
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): b
Enter the details of the new user to add.
Using realm 'ApplicationRealm' as discovered from the existing property files.
Username : jmsuser
User 'jmsuser' already exists and is enabled, would you like to...
a) Update the existing user password and roles
b) Disable the existing user
c) Type a new username
(a): a
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
- The password should be different from the username
- The password should not be one of the following restricted values {root, admin, administrator}
- The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
Password :
Re-enter Password :
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[guest]: guest
Updated user 'jmsuser' to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/standalone/configuration/application-users.properties'
Updated user 'jmsuser' to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/domain/configuration/application-users.properties'
Updated user 'jmsuser' with groups guest to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/standalone/configuration/application-roles.properties'
Updated user 'jmsuser' with groups guest to file '/Users/jsensharma/NotBackedUp/Installed/wildfly-10.0.0.CR3-SNAPSHOT/domain/configuration/application-roles.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition
Setp-3
Creating a simple JMS Queue using the JBoss CLI command line utility. NOTE the JNDI name should contain “java:/jboss/exported” prefix or else the JMS queue will can not be looked up remotely.
let here your queue name is TestQ
$ cd /PATH/TO/JBoss-eap-7.0/bin
$ ./jboss-cli.sh -c
[standalone@localhost:9990 /] /subsystem=messaging-activemq/server=default/jms-queue=TestQ/:add(entries=["java:/jboss/exported/jms/queue/TestQ"])
{"outcome" => "success"}
[standalone@localhost:9990 /] :reload
{
"outcome" => "success",
"result" => undefined
}
step-4
now check your standalone.xml file, whether below xml code generated or not, if not generated then copy the below code and paste it.
Note: If standalone.xml file doesn’t contain
inside
tag then you need to add manually this in standalone.xml file
Step-5
Now try to access admin console to check whether the queue is added or not.
URL - http://localhost:9990/console/App.html
Configuration Done.
How to access JMS using JAVA
Jars for Normal Standalone program
OR
Dependency for maven project
pom.xml
4.0.0
org.jboss.quickstarts.eap
jboss-helloworld-jms
7.0.0.GA
jar
JBoss EAP Quickstart: helloworld-jms
helloworld-jms: Helloworld JMS external producer/consumer client
http://www.jboss.org/products/eap
Apache License, Version 2.0
repo
http://www.apache.org/licenses/LICENSE-2.0.html
jboss-enterprise-maven-repository
https://maven.repository.redhat.com/ga/
true
false
jboss-enterprise-maven-repository
https://maven.repository.redhat.com/ga/
true
false
UTF-8
7.0.0.GA
1.0.2.Final
2.2
1.2.1
1.8
1.8
org.jboss.bom
jboss-eap-javaee7
${version.jboss.bom.eap}
pom
import
org.jboss.eap
wildfly-jms-client-bom
pom
${project.artifactId}
org.codehaus.mojo
exec-maven-plugin
${version.exec.plugin}
org.jboss.as.quickstarts.jms.HelloWorldJMSClient1
java.logging.config.file
./helloworld-jms-logging.properties
maven-jar-plugin
${version.jar.plugin}
org.wildfly.plugins
wildfly-maven-plugin
${version.wildfly.maven.plugin}
HelloWorldJMSProducer.java
import java.util.Properties;
import java.util.logging.Logger;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class HelloWorldJMSProducer{
private static final Logger log = Logger.getLogger(HelloWorldJMSProducer.class.getName());
// Set up all the default values
private static final String DEFAULT_MESSAGE = "Hello, World! successfull";
private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
private static final String DEFAULT_DESTINATION = "jms/queue/TestQ";
private static final String DEFAULT_MESSAGE_COUNT = "1";
private static final String DEFAULT_USERNAME = "jmsuser";
private static final String DEFAULT_PASSWORD = "jmsuser@123";
private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private static final String PROVIDER_URL = "http-remoting://127.0.0.1:8888";
public static void main(String[] args) {
Context namingContext = null;
try {
String userName = System.getProperty("username", DEFAULT_USERNAME);
String password = System.getProperty("password", DEFAULT_PASSWORD);
// Set up the namingContext for the JNDI lookup
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
env.put(Context.SECURITY_PRINCIPAL, userName);
env.put(Context.SECURITY_CREDENTIALS, password);
namingContext = new InitialContext(env);
// Perform the JNDI lookups
String connectionFactoryString = System.getProperty("connection.factory", DEFAULT_CONNECTION_FACTORY);
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(connectionFactoryString);
String destinationString = System.getProperty("destination", DEFAULT_DESTINATION);
Destination destination = (Destination) namingContext.lookup(destinationString);
int count = Integer.parseInt(System.getProperty("message.count", DEFAULT_MESSAGE_COUNT));
String content = System.getProperty("message.content", DEFAULT_MESSAGE);
try (JMSContext context = connectionFactory.createContext(userName, password)) {
// Send the specified number of messages
for (int i = 0; i < count; i++) {
context.createProducer().send(destination, content);
}
System.out.println("Sent...");
}
} catch (NamingException e) {
e.printStackTrace();
log.severe(e.getMessage());
} finally {
if (namingContext != null) {
try {
namingContext.close();
} catch (NamingException e) {
log.severe(e.getMessage());
}
}
}
}
}
HelloWorldJMSConsumer.java
import java.util.Properties;
import java.util.logging.Logger;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class HelloWorldJMSConsumer {
private static final Logger log = Logger.getLogger(HelloWorldJMSConsumer.class.getName());
// Set up all the default values
private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
private static final String DEFAULT_DESTINATION = "jms/queue/TestQ";
private static final String DEFAULT_USERNAME = "jmsuser";
private static final String DEFAULT_PASSWORD = "jmsuser@123";
private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private static final String PROVIDER_URL = "http-remoting://127.0.0.1:8888";
public static void main(String[] args) {
Context namingContext = null;
try {
String userName = System.getProperty("username", DEFAULT_USERNAME);
String password = System.getProperty("password", DEFAULT_PASSWORD);
// Set up the namingContext for the JNDI lookup
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
env.put(Context.SECURITY_PRINCIPAL, userName);
env.put(Context.SECURITY_CREDENTIALS, password);
namingContext = new InitialContext(env);
// Perform the JNDI lookups
String connectionFactoryString = System.getProperty("connection.factory", DEFAULT_CONNECTION_FACTORY);
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(connectionFactoryString);
String destinationString = System.getProperty("destination", DEFAULT_DESTINATION);
Destination destination = (Destination) namingContext.lookup(destinationString);
try (JMSContext context = connectionFactory.createContext(userName, password)) {
System.out.println("Received...");
// Create the JMS consumer
JMSConsumer consumer = context.createConsumer(destination);
// Then receive the same number of messages that were sent
for (int i = 0; i < count; i++) {
String text = consumer.receiveBody(String.class, 5000);
System.out.println(text);
}
}
} catch (NamingException e) {
e.printStackTrace();
log.severe(e.getMessage());
} finally {
if (namingContext != null) {
try {
namingContext.close();
} catch (NamingException e) {
log.severe(e.getMessage());
}
}
}
}
}