|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to set timeToLive on JMS producer globally via com.ibm.m |
« View previous topic :: View next topic » |
Author |
Message
|
metalpalo |
Posted: Wed May 03, 2023 10:32 pm Post subject: How to set timeToLive on JMS producer globally via com.ibm.m |
|
|
Newbie
Joined: 03 May 2023 Posts: 7
|
Hi All,
At first I apologize if my message is on incorrect group.
Im developing spring application sending messages to IBM MQ server(version is irrelevant I think).
For this purpose application has maven dependency library "com.ibm.mq.allclient:9.2.3.0"
I've tried also newest and also older one but no effect.
Within the application manually created JmsTemplate is constructed with available ConnectionFactory bean.
ConnectionFactory bean is defined something like this in one configuration class:
Code: |
@Bean
public ConnectionFactory ibmConnectionFactory(IbmConnectorProperties connectorProperties)
throws JMSException {
//IbmConnectorProperties is my class with properties neccesary for connection
MQConnectionFactory factory = new MQConnectionFactory();
factory.setHostName(connectorProperties.getHostname());
factory.setPort(connectorProperties.getPort());
factory.setQueueManager(connectorProperties.getQueueManager());
factory.setChannel(connectorProperties.getChannel());
factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
factory.setMQConnectionOptions(MQConstants.MQPMO_NONE);
//property messageExpiryTime contains value in seconds
if (connectorProperties.getMessageExpiryTime() != null) {
factory.setLongProperty(CommonConstants.TIME_TO_LIVE,
connectorProperties.getMessageExpiryTime().getSeconds() * 1000);
//docs told something that 10th of seconds but I'm focusing on timeToLive
factory.setLongProperty(WMQConstants.WMQ_EXPIRY,
connectorProperties.getMessageExpiryTime().getSeconds() * 1000);
}
return factory;
}
|
When I call jmsTemplate via execute method it automatically provides session(MQSession) and producer(MQMessageProvider) and then call producer.send(message)
The MQMessageProvider contains delegate JmsMessageProducerImpl(concretely JmsQueueSenderImpl). My chunk of code with jmsTemplate's usage:
Code: |
private void send(Message message) {
jmsTemplate.execute(
(session, messageProducer) -> {
try {
//I would like to avoid manually set timeToLive here(commented line),
//I dont have access to properties from connectionFactory, also cast to MQSession and load it from there not acceptable
//messageProducer.setTimeToLive(10000); //it sets timeToLive long property in map and expiration works well on IBM server
messageProducer.send(message);
} finally {
//just log message
}
return null;
});
}
|
I've debuged construction of whole chain and found that JmsMessageProducerImpl disposes of properties(some clone) overtaken from connection factory.
But in the middle of constructor method following properties are set to default values: deliveryMode, priority, timeToLive and so on:
Code: |
this.setIntProperty("deliveryMode", 2);
this.setIntProperty("priority", 4);
this.setLongProperty("timeToLive", 0L);
this.setLongProperty("deliveryDelay", 0L);
|
When looking at decompiled methods getTimeToLive|setTimeToLive I see that they read/write long property "timeToLive" from/into internal properties(map).
So my question is if possible to set this property globally via connectionFactory construction?
I would like to avoid explicit call setTimeToLive method on producer before send or call another overloaded send method with timeToLive parameter.
As I mentioned I dont have access to concrete MQ classes there, I would like to keep it abstract and use possibilities of your driver.
Maybe another question is how is possible to set expiry destination property. When debugging I see that destination has also timeToLive property with higher priority that one from producer.
Can somebody help me?
Thanks
brmetalpalo |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat May 06, 2023 6:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20745 Location: LI,NY
|
Destinations are defined in JNDI and can have their expiry set there.
Alternatively you can use the form queue:///QNAME?expiry=xyz
Hope it helps  _________________ MQ & Broker admin |
|
Back to top |
|
 |
metalpalo |
Posted: Tue May 09, 2023 5:59 am Post subject: |
|
|
Newbie
Joined: 03 May 2023 Posts: 7
|
Sorry, Im newbie in IBM MQ.
But If I good understood expiration is possible to set somehow via JNDI only on destination level right?
Some good example?
Does exists general(global) setting on producer level?
thanks
brmetalpalo |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 10, 2023 12:38 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20745 Location: LI,NY
|
metalpalo wrote: |
Sorry, Im newbie in IBM MQ.
But If I good understood expiration is possible to set somehow via JNDI only on destination level right?
Some good example?
Does exists general(global) setting on producer level?
thanks
brmetalpalo |
Why would you want to set it at the producer level as the producer can be anonymous and send to multiple destinations.
The setting is correctly set at the destination level, so keep it there.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
metalpalo |
Posted: Wed May 10, 2023 3:47 am Post subject: |
|
|
Newbie
Joined: 03 May 2023 Posts: 7
|
fjb_saper wrote: |
Why would you want to set it at the producer level as the producer can be anonymous and send to multiple destinations.
The setting is correctly set at the destination level, so keep it there.  |
I see that expiry on destination has higher priority then producer but from my perspective I would like to use indentical timeToLive for all queues within the application. Just asking if possible
When talking about destination expiry how can I set it via JNDI?
Is necessary to set something on IBM server or just inside application?
thanks |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|