ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » Sub getting deleted when java client closes

Post new topic  Reply to topic
 Sub getting deleted when java client closes « View previous topic :: View next topic » 
Author Message
riyaz_tak
PostPosted: Sat Sep 26, 2020 11:52 pm    Post subject: Sub getting deleted when java client closes Reply with quote

Voyager

Joined: 05 Jan 2012
Posts: 92

Hi Team,

OS SOlaris 10
IBM MQ 8.0.0.5
Protocol AMQP

I have created ONE topic

def topic (ToCLient) TOPICSTR(ToCLient)

I have created Qalias which is redirecting message to this Topic

DEF QALIAS(ABC_LQ) TARGTYPE(TOPIC) TARGET(ToCLient)

There is java client which connects to this TOPIC and fetch messages :


Connection connection = null;
Context context = new InitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("myFactoryLookup");
connection = connectionFactory.createConnection();
connection.setClientID("123"); // Why do we need clientID while publishing the TOPIC from consumer / publisher
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic priceTopic = (Topic) context.lookup("myTopicLookup1");
MessageConsumer subscriber1 = session.createDurableSubscriber(priceTopic, "cleintSub1");
System.out.println("TOPIC "+priceTopic);

connection.start();
while(true){
TextMessage message1 = (TextMessage) subscriber1.receive(1000);
if(message1!=null)
System.out.println("Subscriber 1 received : " + message1.getText());


}

When this java client is up and running then I can see sub created in IBM MQ :

dis tpstatus(ToCLient) type(sub)
dis sbstatus SUBID(xxxxxx)

But when i close the java client then this sub also vanishes from IBM MQ (sub is getting created only when java client runs and closes when java client stops).

Why is it so ?

To overcome this issue i create one sub in IBM MQ and put some messages to this topic (java client was running this time)

When I started java client then it received all the messages but when the client stops it again delete the sub which i created explicitly.

WHat is happening?

I need durable sub which is not deleted and when client is up then it can send message to client or if client is not running then store the message till then .
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Sep 27, 2020 10:49 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

If a durable administrative sub was deleted open a PMR with IBM.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
riyaz_tak
PostPosted: Mon Sep 28, 2020 2:42 am    Post subject: Reply with quote

Voyager

Joined: 05 Jan 2012
Posts: 92

IBM Doesn't support 8.0.0.5.

When client connects then EXPIRY of sub became zero although I set it explicitly to UNLIMITED.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Sep 28, 2020 4:43 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

riyaz_tak wrote:
IBM Doesn't support 8.0.0.5.


So tell whoever accepted the business risk of not updating MQ that they just lost the bet.

A normal subscription behaves as you describe - it's created when the subscriber starts running and is deleted when it stops.

A durable subscription is created when the administrator types the command, and lasts until it is explicitly deleted.

If a subscriber is able to delete a durable subscription then I agree with my associate; it's a bug. You could also try running the subscriber as something other than mqm.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
markt
PostPosted: Mon Sep 28, 2020 8:42 am    Post subject: Reply with quote

Knight

Joined: 14 May 2002
Posts: 502

Quote:
A durable subscription is created when the administrator types the command, and lasts until it is explicitly deleted.


That is partly true. But it is certainly possible for applications to create durable subs too. In JMS there is the createDurableSubscriber method for precisely that purpose; you can then stop the app, restart it, and reconnect to the same subscription collecting any publications from while you were away. I've done it multiple times in MQ JMS apps.

Having said that, one important thing about this question is the use of an AMQP client. Not the normal MQ JMS client. There are limitations around which AMQP features are supported by the qmgr. I don't know if durable subs is one of those limitations. There are also limitations around formal support of any AMQP client - only the qmgr end of the connection is really supported in the sense of being able to open a Case/PMR.
Back to top
View user's profile Send private message
riyaz_tak
PostPosted: Tue Sep 29, 2020 12:43 am    Post subject: Reply with quote

Voyager

Joined: 05 Jan 2012
Posts: 92

I am also using JMS API to create durable subscriber but the issue is when I create it dynamically then EXPIRY of sub is set to 0 and I guess because of this sub is getting deleted from MQ once java client closes.

I am using apache Qpid to create durable subscriber .

MessageConsumer subscriber1 = session.createDurableSubscriber(topic, "sub1");

dis sub SUBID("hex id ")

SUBID("hex id ")
SUB(:private:123:TOCLIENT) TOPICSTR(TOCLIENT)
TOPICOBJ(SYSTEM.BASE.TOPIC) DISTYPE(RESOLVED)
DEST(SYSTEM.MANAGED.DURABLE.XXXXXXXXXX)
DESTQMGR(xxxxxx) PUBAPPID( )
SELECTOR( ) SELTYPE(NONE)
USERDATA(010)
PUBACCT(xxxxx)
DESTCORL(xxxxxx)
DESTCLAS(MANAGED) DURABLE(YES)
EXPIRY(0) PSPROP(MSGPROP)
PUBPRTY(ASPUB) REQONLY(NO)
SUBSCOPE(ALL) SUBLEVEL(1)
SUBTYPE(API) VARUSER(FIXED)
WSCHEMA(TOPIC) SUBUSER(mqm)
CRDATE(2020-09-29) CRTIME(07:35:0
ALTDATE(2020-09-29) ALTTIME(07:35:0
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Sep 29, 2020 4:17 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

markt wrote:
Quote:
A durable subscription is created when the administrator types the command, and lasts until it is explicitly deleted.


That is partly true. But it is certainly possible for applications to create durable subs too. In JMS there is the createDurableSubscriber method for precisely that purpose; you can then stop the app, restart it, and reconnect to the same subscription collecting any publications from while you were away. I've done it multiple times in MQ JMS apps.


Wretched Java and it's wretched JMS, which is highly wretched.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hughson
PostPosted: Tue Sep 29, 2020 1:38 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand

To prove to yourself that it is the application deleting the durable subscription when it ends normally, break the connection abnormally. Control-C it or kill it or yank out the network cable or whatever. You should see that the durable subscription is still there on the queue manager because the application won't have the opportunity to close and remove it.

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
riyaz_tak
PostPosted: Tue Sep 29, 2020 8:55 pm    Post subject: Reply with quote

Voyager

Joined: 05 Jan 2012
Posts: 92

SUB Properties when java client is not running :

dis sub SUBID(xxxxxxxxxxxxxxxxx)
4 : dis sub SUBID(xxxxxxxxxx)
AMQ8096: WebSphere MQ subscription inquired.
SUBID(xxxxxxxx)
SUB(:private:123:TOCLIENT) TOPICSTR(TOCLIENT)
TOPICOBJ( ) DISTYPE(RESOLVED)
DEST(SYSTEM.MANAGED.DURABLE.xxxxxxx)
DESTQMGR(xxxxxxx) PUBAPPID( )
SELECTOR( ) SELTYPE(NONE)
USERDATA( )
PUBACCT(xxxxx)
DESTCORL(xxxxxx)
DESTCLAS(MANAGED) DURABLE(YES)
EXPIRY(UNLIMITED) PSPROP(MSGPROP)
PUBPRTY(ASPUB) REQONLY(NO)
SUBSCOPE(ALL) SUBLEVEL(1)
SUBTYPE(ADMIN) VARUSER(ANY)
WSCHEMA(TOPIC) SUBUSER(root)
CRDATE(2020-09-30) CRTIME(04:47:05)
ALTDATE(2020-09-30) ALTTIME(04:47:05)


Sub property as soon as I start java client :




dis sub SUBID(xxxxx)
5 : dis sub SUBID(xxxx)
AMQ8096: WebSphere MQ subscription inquired.
SUBID(xxxx)
SUB(:private:123:TOCLIENT) TOPICSTR(TOCLIENT)
TOPICOBJ( ) DISTYPE(RESOLVED)
DEST(SYSTEM.MANAGED.DURABLE.xxxxx)
DESTQMGR(xxxxx) PUBAPPID( )
SELECTOR( ) SELTYPE(NONE)
USERDATA(010)
PUBACCT(xxxxx)
DESTCORL(xxxxx)
DESTCLAS(MANAGED) DURABLE(YES)
EXPIRY(0) PSPROP(MSGPROP)
PUBPRTY(ASPUB) REQONLY(NO)
SUBSCOPE(ALL) SUBLEVEL(1)
SUBTYPE(ADMIN) VARUSER(ANY)
WSCHEMA(TOPIC) SUBUSER(mqm)
CRDATE(2020-09-30) CRTIME(04:47:05)
ALTDATE(2020-09-30) ALTTIME(04:48:57)


As you can see that EXPIRY has zero value when I start java although it had UNLIMITED against EXPIRY earlier.

I created SUB(:private:123:TOCLIENT) explicitly although if I don't create one then java client create sub with the same name with EXPIRY(0).
Back to top
View user's profile Send private message
hughson
PostPosted: Tue Sep 29, 2020 9:01 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand

If you are concerned that EXPIRY(0) means that your subscription is closed as soon as your application lets go of it, have you tried the test I suggested above?

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
riyaz_tak
PostPosted: Tue Sep 29, 2020 9:23 pm    Post subject: Reply with quote

Voyager

Joined: 05 Jan 2012
Posts: 92

yes I tried and sub is getting deleted after sometime when I press CONTROL+C.
I believe issue is EXPIRY (0) because once I press control+c then sub is deleted within 5 minutes.
Back to top
View user's profile Send private message
exerk
PostPosted: Wed Sep 30, 2020 11:29 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

Not sure if this is relevant:

SUBUSER(root) when the java client is not running.

SUBUSER(mqm) when it is.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
hughson
PostPosted: Wed Sep 30, 2020 9:21 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1914
Location: Bay of Plenty, New Zealand

exerk wrote:
Not sure if this is relevant:

SUBUSER(root) when the java client is not running.

SUBUSER(mqm) when it is.


When a subscription is resumed (as is the case here), it's various properties will be updated to show the current owner of the subscription. This in itself does not explain why the QPID JMS interface thinks EXPIRY(0) is required, but does explain the change in SUBUSER.

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
riyaz_tak
PostPosted: Wed Sep 30, 2020 10:25 pm    Post subject: Reply with quote

Voyager

Joined: 05 Jan 2012
Posts: 92

SUBUSER (root) is created when I create it explicitly in MQ console :

def sub(':xxxx') TOPICSTR(toClient) DESTCLAS(MANAGED)

and when java client runs then it changes SUBUSER changes to mqm.
Back to top
View user's profile Send private message
exerk
PostPosted: Thu Oct 01, 2020 2:24 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

Thank you Morag and riyaz_tak, for helping my understanding (which is poor) in regard to pub/sub.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » Sub getting deleted when java client closes
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.