Creating and deleting jms queues using jmx in websphere 8.5 - jms

I am searching for a way to create and delete jms queues using jmx through a java client.
I know we do get AdminClient for jmx administration. But I am not able to get which mbean
we can use to create and delete jms queues.

The ConfigService mentioned by Marcin is a low level API that allows to manipulate configuration objects directly. That my be tricky. E.g. if you need to create a SIB destination, then you need to manipulate at least two different types of configuration objects, namely SIB destinations (children of the bus defined at the cell scope) and queue points (children of the messaging engine at the server or cluster scope), and you need to make sure that you link them properly.
Probably it will be easier for you to use the CommandMgr API as described in this post. That API is the direct equivalent of the AdminTask object in wsadmin.

You may work with WAS configuration (and create/delete JMS queues in particular) using ConfigService. This article explains how to obtain and use ConfigService:
http://www.ibm.com/developerworks/websphere/techjournal/0307_wang/wang.html
Although it's been written for WAS 5.1, it's still up to date.

Related

Using multiple MQ servers in Java Spring Boot

I have a Java Spring Boot application, and I need to send messages over IBM MQ and then listen for a response on a corresponding queue. I have a primary and (possibly multiple) fail-over MQ hosts. The queue names are different on each host (I have no control over this) so I need to have a different connection factory for each host.
I've looked at the mq-jms-spring code, and think I can adapt this to my needs. However, our current code, which works a comma separated list of hosts (and was written by someone else), creates both a connection factory and a transaction manager using that connection factory. It can use multiple hosts, but since the queue names are different for each host the fail-overs, well, fail. I'm assuming I need to create multiple transaction managers if I have multiple connection factories.
My questions are:
Do I need a transaction manager in this case?
If yes, then do I need a 1-1 relationship of connection factory to transaction manager?
If yes, how do I use the multiple transaction managers? I use the connection factory to write to the queue, but how do I notify spring which transaction factory to use? Does Spring automatically know this or is there some way I need to configure this?

Switching from IBM MQ to Tibco EMS

We are creating new application, which is going to use IBM's MQ as a JMS provider for a short term and switch to Tibco EMS within a year.
My question is how involving the changes would be from the Application code perspective.
So far reading from JMS documentation, my impression is it should only require minimal changes. Does anyone have experience with it and provide some input on the work involved in switching between JMS provider.
I've done POCs where I swapped out connection factories and used WMQ JMS Classes to send to various providers (TIBCO, ActiveMQ, etc), to prove out the interchangeability. I've also done full swaps from one vendors JMS to another. In theory, it should be very simple.
The biggest change will be with the connection factories. Everything JMS specific will be the same between providers. The more tightly coupled the code is to the connection factories, the more complex it will be to change the app itself. Outside of this, you may need to change vendor specific implementation of objects, such as MQQueue vs Queue.
One addition thing to keep in mid is dependent on the IBM endpoints. If you are using "target queue managers" on any producers, these will need to change. WMQ has a specific URI to reach queues on specific Queue Managers in a cluster ( "queue://target_qm/queue_name/" ). If any application uses this URI it will need to ensure it makes the proper changes here as well.

Is it possible for Spring-XD to listen to more than one JMS broker at a time?

I've managed to get Spring Xd working for a scenario where I have data coming in from one JMS broker.
I potentially am facing a scenario where data ingestion could happen from different sources thereby needing me to connect to different brokers.
Based on my current understanding, I'm not quite sure how to do this as there exists a JMS config file which allows you to setup only one broker.
Is there a workaround to this?
At the moment, you would have to create a separate jms-[provider]-infrastructure-context.xml for each broker (in modules/common), say call the provider activemq2.
Then use --provider=activemq2 in the module definition.
(I recently used this technique to test sonicmq and hornetq providers).

Not able to create jms queues in websphere programatically using standalone java client

I wrote a java client to connect to jms in websphere.
I was able to connect and produce and consume message.
Problem I am facing is when I do Session.createQueue(), websphere jms is not creating a new queue.
Please could some one throw some light on this issue...
Thanks in advance...
If you are working with WebSphere MQ as the messaging provider within WebSphere Application Server the queue will need to be created on the WebSphere MQ QueueManager first. This can be done either via the graphical WMQ Explorer or via the command line using the 'runmqsc' tool.
Information can be found for these via the WMQ InfoCentre - suggest doing a websearch for "WMQ Library" to get the latest link, currently though it is http://www-01.ibm.com/software/integration/wmq/library/index.html
Topics though don't need to be pre-created - though they can be if required. Various properties can be set different to the default.
If the Queue doesn't need to be permanent, for example as a temporary reply to then look into creating a temporary queue from the JMS Connection.
createQueue doesn't create a new queue. It simply creates a javax.jms.Queue object from a vendor specific identifier. javax.jms.Queue objects are just references to existing queues. Typically, you retrieve javax.jms.Queue objects from JNDI; createQueue is only useful in scenarios where using JNDI is not possible or not desirable.
Note: there is one exception to this, namely JMS providers that support autocreation of queues (I think ActiveMQ has such a feature).

How to create physical queue in JMS at run time

Want to know how to create physical queue in JMS at run time.
when I search for this I got Creating JMS Queues at runtime
But when I read http://activemq.apache.org/how-do-i-create-new-destinations.html I come to know queue which mention in Creating JMS Queues at runtime is not creating any physical queue at server side.
Please correct me if I m wrong. If any one know to create physical queue at run time please replay.
Thanks in advance.
The creation of "normal" queues is not adressed by the JMS standard. Depending on what you want to do there are two approaches:
use temporary queues -> however they have many restrictions, most commonly they are used forrequest-reply scenarios
use the API of the JMS provider - however your solution will be depending on this specific provider then
The JMS standard only addresses sending and receiving data from objects like queues and topics. Creation of JMS artefacts is vendor specific and most often requires using:
1)specific vendor APIs (not JMS)
2)command/admin messages aimed at the JMS server (command agents on activemq)
3)JMX API
I have used JMX method, which is the most powerful, but also the most work.
JMX Method for activemq (version 5.0+)
a) JMS Server Setup
1) Enable JMX in activemq startup scripts and activemq.xml files
2) If you are authenticating to to the server, make sure your user has admin privileges setup in activemq.xml (see http://activemq.apache.org/security.html)
3)restart activemq server
b) Your Client Code
1) create an instance of org.apache.activemq.broker.jmx.BrokerViewMBean (you will need to connect with some JMX connectivity code which is a bit messy)
2) use its addQueue method. This will create a queue on the server
(The process is similar for hornetq but since you mentioned Activemq I have omitted hornetq details here.)
I have used this method myself and it works.
An alternative is to use Command Agents in Activemq, but I have no personal experience with these. These are special messages contain admin commands and may do what you want as well.

Resources