not able to send message to remote Tomcat and ActiveMQ queue - jms

I have a set of JMS queues configured on a Tomcat + ActiveMQ server. I have created a Resource for connectionFactory (by pointing the Broker to tcp:localhost:61616) and a resource for Queue in Server.xml inside global resource and then declared these 2 resource as in context.xml.
Now I'm trying to connect this queue from another tomcat server and send message. When trying to get lookup for connection factory with jndi name I am getting NamingException - name not bound in this context for the ConnectionFactory JNDI.
I tried to achieve like this:
set below values in properties
Provider_URL = http://Localhost:8080
INITIAL_CONTEXT_FACTORY = org.apache.naming.java.javaURLContextFactory
and then create new InitialContext with above property value and then lookup for the jndi of connectionFactory.
But its not working.
I tried other option to directly get context of the ActiveMQ by using ActiveMQContextFactory as INITIAL_CONTEXT_FACTORY and Provider_URL= tcp://localhost:61616
and I kept a simple jndi.properties file in the classpath of client tomcat server as it is mentioned in other posts. And It works well.
But I do not like it. Because when I configured the activeMQ connection and Queue as a resource in Tomcat, that means I should be able to get JNDI lookup through Tomcat and not directly to Active mq. I do not want to give ActiveMQ host:port to all my clients.
I assume there must be something incorrect on Tomcat server configuration that its connectionfactory/queue JNDI is not available for lookup outside.
I have struggle a lot today. Can someone expert point me to some possible mistake.
Thanks in advance.

Related

JMS provider URL for jboss in-vm destination

Running app on EPA 7 with log4j2. We have an appender that writes to a JMS queue.
I got it working for remote connection as below:
<JMS name="HIFAuditAppender"
destinationBindingName="jms/queue/HIFAuditQueue"
factoryBindingName="jms/RemoteConnectionFactory"
providerURL="http-remoting://127.0.0.1:8080"
username="hcmuser"
password="gators123="
factoryName="org.jboss.naming.remote.client.InitialContextFactory" />
However, the JMS producer and MDB are running in the same JVM. I want to use the jboss in-vm connector, but have not been able to determine what the providerURL should be set to.
The providerURL will be same i.e http-remoting://127.0.0.1:8080. You need to use in-vm connection factory i.e /ConnectionFactory which uses in-vm connector and used to produce/consume messages locally.

Configuring resource in Tomcat's context.xml to access remote Weblogic JMS queues

What I intend to do is access remote queues in Oracle Weblogic JMS (version 10.3.4) from a spring application deployed in Tomcat7.
For this I am trying to configure a Resource (eg JMS connection factory, queues etc) in Tomcat's context.xml file. Then access this resource using jndi lookup in the spring configuration file and provide it to the necessary beans. I have already created connection factory and queues in Weblogic JMS and they can be accessed using jndi names.
I am able to make it work successfully when using ActiveMQ instead of Weblogic JMS. However with Weblogic JMS, I am facing an issue with configuring the Resource element. I am not sure what attributes to be used with Resource tag while connecting to Oracle Weblogic JMS.
When working with ActiveMQ the resource element config looks like below
<Resource name="jms/MyConnectionFactory" auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
description="JMS Queue Connection Factory"
brokerURL="tcp://localhost:61616" brokerName="MyActiveMqBroker"/>
I am struggling to find the configuration to be used with Oracle Weblogic JMS. I have gone through documentations to see how to do it but with no luck.
Any help or pointers would be highly appreciated.
Thanks.

How to connect to remote JMS Provider?

I want high level steps to connect to remote JMS Provider.
I have some client application which wants to lookup in JNDI on FileSystem based to get the connection factory for JMS provider.
I understand that in JMS Administeration (MQ Explorer), we can create the Connection factories. This is creating .bindings file.How can I use this .bindings file into my client application system?
Should the Client Application system contain the JMS Administerator to create the .bindings in the same system or .bindings alone should be imported to the client system?
If Filesystem is used,then a path specifying the .binding is given as Provider url. This provider url (EG: F:/JMS) seems to be the path present in JMS Provider system.If .bindings file imported in client system, then how the client can recognise the path of .bindings file?
And What is the purpose of having ServerConnection channel in the Connection Factories definition when MQClient mode is used?When the JMS client connects through JNDI bindings, why Server Connection channel is required?
Q1)
How can I use this .bindings file into my client application system?
The .bindings file must be placed on file server that can be accessed by your client system. For example place the .bindings file on file server MyFileSvr's D:\JNDI-Directory folder. Then in your client machine D:\ folder must be mounted as a drive, say as F drive. Then in your application you can reference the .bindings file as
// Instantiate the initial context
String contextFactory = "com.sun.jndi.fscontext.RefFSContextFactory";
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
environment.put(Context.PROVIDER_URL, "file:/F:/JNDI-Directory");
Context context = new InitialDirContext(environment);
System.out.println("Initial context found!");
// Lookup the connection factory
JmsConnectionFactory cf = (JmsConnectionFactory) context.lookup(connectionFactoryFromJndi);
Q2)
Should the Client Application system contain the JMS Administerator to create the .bindings in the same system?or .bindings alone should be imported to the client system?
See the answer for Q1 above. It's good practice to keep the bindings file on a shared drive so that multiple client application can access.
Q3)
If Filesystem is used,then a path specifying the .binding is given as Provider url.This provider url (EG: F:/JMS) seems to be the path present in JMS Provider system.If .bindings file imported in client system,then how the client can recognise the path of .bindings file?
Again see answer for Q1.
Q4)
And What is the purpose of having ServerConnection channel in the Connection Factories definition when MQClient mode is used? When the JMS client connects through JNDI bindings ,why Server Connection channel is required?
A server connection channel defines the required properties for MQ client applications (JMS or otherwise) connect to a IBM MQ queue manager. A connection factory object in JNDI bindings will have, among others,the following defined for an application to connect to a IBM MQ queue manager
1) Host name where queue manager is running
2) Port where queue manager is listening
3) Server Connection channel name.
4) Queue manager name.
Bottom line JNDI bindings and Server connection channel are not same.
Please read through online documentation of IBM MQ as well as MQ Redbooks.

How websphere server creates and manages JMS resources internally

When we set up a queue connection factory, a topic connection factory, a queue, a topic in websphere application server throguh the console, what exactly happens?
The server stores the configuration details in an xml and at server startup, it creates the connection factory(ies), topic(s),queue(s) and puts them in a pool?
I ask because the actual queue(s) and topics(s) itself do not reside on the App server, they reside on a separate (remote) websphere MQ server. So why do we need to 'create' the queues in Websphere App server?
The configuration is metadata for connecting to the remote objects. When the server starts (or an app restarts, or configuration is refreshed), the server reads the .xml, then binds Reference objects into JNDI. The actual connection factories aren't created/pooled until the Reference is first looked up.
I don't have enough experience with JMS to answer your second question, but presumably the metadata is required for the queue in order to access it remotely.

Setting up MDBs to consume JMS messages in Weblogic 10.3.5

I'm trying to set up part of an application which uses MDBs to consume messages from a JMS Queue. I've looked through the Oracle documentation but can't seem to make sense of it. Examples on the internet seem to be for situations where your JMS server is the same weblogic server where you are consuming but in my case there is a separate server.
I've found this post Weblogic EJB connection to external Tibco EMS JMS Queue which gives broad strokes but seems to be written more for experienced weblogic users.
Specifically with the linked here is where I'm having trouble:
Create a foreign server with all the normal details (local/remote JNDI lookup names for destination and connection factories).
Not sure how to do this.
Create a local WL user with the same name as the remote EMS user, including password.
I cannot do this as my password is less than 8 characters
Create an ejb credential mapping (NOT security credential mapping)
do this by clicking on the relevant deployment, click on the relevant ejb name in the list, then Security tab then Credentials Mapping tab.
add the same name for WLS and Remote users (password doesn't seem to be necessary here).
Under Security I see Application/Module Scope tabs and Roles/Policies underneath those.
Can anyone give more detailed steps on how to set up a simple MDB in Weblogic 10.3.5 which consumes JMS messages from an external server (Tibco EMS)?
I have an ldap url, a selector (to filter out unwanted messages, not completely necessary), username and password, Queue name, EMS server url (which specifies a port), connection factory ldap. What do I do with this information?
You can configure a foreign server in weblogic and inside the foreign server you can provide the connection factory & destination details. The username, passwd & queue name that you have will be required to create these weblogic admin objects.
Weblogic foreign server configuration
While creating the destination you can provide the local jndi name which you can use in your MDB Activation configuration to connect to.

Resources