How to connect to remote JMS Provider? - jms

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.

Related

not able to send message to remote Tomcat and ActiveMQ queue

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.

Difference between bindings file and jndi properties file

Can you please let me know when to use .bindings file and when to use jndi properties file?
The .bindings file is created by the JNDI FileSystem context (com.sun.jndi.fscontext.RefFSContextFactory) when data is stored by the MQ JMSAdmin tool or other JNDI tool. It contains a representation of the JNDI data, for example your Connection Factory settings such as hostname, port, etc.
In the case of MQ, the .bindings file is not used directly by MQ code, it is used by the JNDI code to create the MQ JMS objects which are then returned to the application.
The JNDI properties file (or the JMSAdmin.config file if you're using JMSAdmin) stores the connection settings to allow the JNDI code to connect to the JNDI repository (for example, the FileSystem context, LDAP server etc.). It does not contain data such as Connection Factory settings.

Use same .binding file in another WebSphere MQ

I use WebSphere MQ 7.0, followed necessary steps and configured it. Can I use same .binding file in another WebSphere MQ ?
WebSphere MQ\java\bin\JMSAdmin.config entries as below
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
PROVIDER_URL=file:/C:/JNDI-Directory
The .bindings file is the backing store for the FileSystem JNDI provider. You would typically conenct the JMS based applications to this to load the Connection Factories and Destinations.
A single JNDI store can hold multiple objects and they don't all have to represent connections to a single Queuemanager.
So if you're asking do I need another JNDI store for another queuemanager, no not necessarily.

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