Webpshere MQ temporary dynamic queues using Model queues - ibm-mq

I am using the following sample code to create a temporary replyto queue
final TemporaryQueue replyQueue = session.createTemporaryQueue();
message.setJMSReplyTo(replyQueue);
producer.send(destination, message);
This uses a default model queue SYSTEM.DEFAULT.MODEL.QUEUE to create the temporary dynamic queue.
Please just want to know if there is way to use my own model queue instead of using the default model queue.
Thanks

Check the JavaDoc for the MQConnectionFactory - there's a model queue property on the connection factory that controls this.
http://www-01.ibm.com/support/knowledgecenter/api/content/SSFKSJ_8.0.0/com.ibm.mq.javadoc.doc/WMQJMSClasses/index.html

Related

Spring AMQP Get Existing Queue Names and Argument

We have a queue in production where message TTL was set via application. Now we want to change message TTL and attach policy via rabbit CTL than setting within application. Snippet:
Map<String, Object> args = new HashMap<>();
args.put("x-message-ttl", 86400000);
for (String queueName : queueNames) {
Queue queue = new Queue(queueName, true, false, false, args);
admin.declareQueue(queue);
...
}
To achieve this in running application we want way to validate if Queue already exists do nothing otherwise create new Queue without args. It is not possible to leverage local cache as multiple publisher/subscriber nodes can restart under unplanned outage scenario. With above would be able to change TTL during Rabbit upgrade/Migration
Can you help if there is an API to fetch all existing queues and its argument properties?
Note: Overriding x-message-ttl with different value throws error.
RabbitMQ has a REST API and a java client for it.
You can use that to get information about existing elements such as queues.

Workaround to fix StreamListener constant Channel Name

I am using cloud stream to consuming messages I am using something like
#StreamListener(target = "CONSTANT_CHANNEL_NAME")
public void readingData(String input){
System.out.println("consumed info is"+input);
}
But I want to keep channel name as per my environment and it should be picked from property file, while as per Spring channel name should be constant.
Is there any work around to fix this problem?
Edit:1
Let's see the actual situation
I am using multiple queues and dlq queues and it's binding is done with rabbit-mq
I want to change my channel name and queue name as per my environment
I want to do all on same AMQP host.
My Sink Code
public interfaceProcessorSink extends Sink {
#Input(CONSTANT_CHANNEL_NAME)
SubscribableChannel channel();
#Input(CONSTANT_CHANNEL_NAME_1)
SubscribableChannel channel2();
#Input(CONSTANT_CHANNEL_NAME_2)
SubscribableChannel channle2();
}
You can pick target value from property file as below:
#StreamListener(target = "${streamListener.target}")
public void readingData(String input){
System.out.println("consumed info is"+input);
}
application.yml
streamListener:
target: CONSTANT_CHANNEL_NAME
While there are many ways to do that I wonder why do you even care? In fact if anything you do want to make it constant so it is always the same, but thru configuration properties map it to different remote destinations (e.g., Kafka, Rabbit etc). For example spring.cloud.stream.bindings.input.destination=myKafkaTopic states that channel by the name input will be mapped to (bridged with) Kafka topic named myKafkaTopic'.
In fact, to further prove my point we completely abstracted away channels all together for users who use spring-cloud-function programming model, but that is a whole different discussion.
My point is that I believe you are actually creating a problem rather the solving it since with externalisation of the channel name you create probably that due to misconfiguration your actual bound channel and the channel you're mentioning in your properties are not going to be the same.

Durable subscriber with JMS Connector Alpakka

Using Alpakka, we can create a non-durable subscriber for any topic using the below code:
Source<String, NotUsed> jmsTopicSource = JmsSource
.textSource(JmsSourceSettings
.create(connectionFactory)
.withTopic("topic")
.withBufferSize(10)
);
Does anyone have an idea how to make this topic subscriber durable?
I don't think the creation of durable consumers is supported in Alpakka's JMS connector, as of version 0.9. In the internal API, JmsConnector is calling Session#createConsumer:
private[jms] def createConsumer()(implicit ec: ExecutionContext): Future[jms.MessageConsumer] =
Future {
session.createConsumer(destination)
}
There doesn't appear to be a way to invoke any of the methods (e.g., Session#createDurableConsumer) that the JMS Session object provides to create durable consumers.

Using ODP.NET OracleAQQueue.Listen on a Multiconsumer Queue

I have a client app that connects to an Oracle AQ multi-consumer queue. I want to use OracleAQQueue.Listen to listen for new messages on the queue. API docs show that the Listen method can be used for multi-consumer queues. My code for listening to the queue is shown below.
string consumerName = "APPINST1";
using (OracleConnection con = new OracleConnection(connectionString))
{
con.Open();
OracleAQQueue queue = new OracleAQQueue("MY_Q");
queue.MessageType = OracleAQMessageType.Udt;
queue.UdtTypeName = "MY_Q_MSG";
queue.DequeueOptions.DeliveryMode = OracleAQMessageDeliveryMode.Persistent;
queue.Connection = con;
Console.WriteLine("Listening for messages...");
queue.Listen(new string[] { consumerName });
}
The problem that I'm having is that on the line of code where I call queue.Listen(), I get the Oracle exception:
ORA-25295: Subscriber is not allowed to dequeue buffered messages
Googling for advice on this particular error hasn't been too helpful. I've removed and re-added my subscriber to the queue several times to no avail. My guess is that I'm not setting some property correctly before I make the call to Listen, but I can't figure out the issue.
Any ideas?
I ran across the following note in the Streams Advanced Queuing User's Guide, in Chapter 10 - Oracle Streams AQ Operations Using PL/SQL:
Note: Listening to multiconsumer queues is not supported in the Java API.
Although I can't find it explicitly stated anywhere, I'm guessing the same rule applies to the ODP.NET API.
You must set the visibility attribute to IMMEDIATE to use buffered messaging.

mulitple queues in EJB messagedriven annotation

I have 3 queues and these three queues need to be listened by MDBbean and accordingly based on reading input, i will split out the task for each category of input.
As of now, the code is working fine for only one queue and i don't know how to implement it for more than one queue. Could you please guide me
#MessageDriven(mappedName="receiver1")
public class MDBMessages implements MessageListener
How i can make my MDBMessage to listen for receiver2 and receiver 3 queue.
Thanks
Prabhakar
From Documentation :
A message-driven bean is defined for a
single messaging type, in accordance
with the message listener interface it
employs.
Therefore it will not be possible to map a MDB for multiple destination types.
Haven't tried, but you can try configuring MDB in ejb-jar.xml with different JNDI names pointing to the same class & add different destination to each of them. If configuration works, then MDBMessages will be able to listen messages for all specified queues in xml.
use the deployment descriptor to create multiple instances of your mdb. Each instance listens to one queue.
also there are brokers (like activeMQ) that allow one mdb to listen on multiple destinations of the same type (queue, topic), if they use the activemq resource adapter.
#Consumer(activationConfig = { #ActivationConfigProperty(
propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#**ActivationConfigProperty(propertyName = "destination",
propertyValue = "queue/MyTasksProcess"),**
public class MyProcessorMDBean implements Downloader {
public void processSomething(Serializable anyParameter){
//Do the actual processing
}
for a given message driven bean you can rout your message to single queue so can use only single destination type in your bean class.

Resources