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 IndexIBM MQ Java / JMSGET SUBSCRIPTION FIELD WITH PCF

Post new topicReply to topic
GET SUBSCRIPTION FIELD WITH PCF View previous topic :: View next topic
Author Message
pcouas
PostPosted: Thu Aug 22, 2019 7:13 am Post subject: GET SUBSCRIPTION FIELD WITH PCF Reply with quote

Voyager

Joined: 06 Sep 2011
Posts: 79

Hi,

I tried to get all value from an subscription object with PCF command in Java
I search to know if my values are correct ??

regards
Code:

 public static final FieldPCF<Subscription> NAME = new FieldPCF<>(String.class, CMQCFC.MQCACF_SUB_NAME);
    public static final FieldPCF<Subscription> SUBID = new FieldPCF<>(String.class, CMQCFC.MQCACF_SUBSCRIPTION_IDENTITY);

    public static final FieldPCF<Subscription> SUBSCRIPTIONTYPE  = new FieldPCF<>(int.class,  CMQCFC.MQIACF_SUB_TYPE,ValuesMappingPCFSubscription.SUBSCRIPTION_TYPE);
    // MQCACF_OBJECT_STRING
    public final static FieldPCF<Subscription> TOPICSTRING = new FieldPCF<>(String.class, CMQC.MQCA_TOPIC_STRING);
    public final static FieldPCF<Subscription> TOPICOBJ = new FieldPCF<>(String.class, CMQC.MQCA_TOPIC_NAME);
    public final static FieldPCF<Subscription> DESTCLAS= new FieldPCF<>(int.class, CMQCFC.MQCACF_DESTINATION, ValuesMappingPCFSubscription.DESTCLAS); //todo
    public static final FieldPCF<Subscription> DESTCRRLID = new FieldPCF<>(int.class, CMQCFC.MQBACF_SUB_CORREL_ID);
    public final static FieldPCF<Subscription> VARUSER= new FieldPCF<>(int.class, CMQCFC.MQIACF_VARIABLE_USER_ID, ValuesMappingPCFSubscription.VARUSER);
    public static final FieldPCF<Subscription> SUBUSER = new FieldPCF<>(int.class, CMQCFC.MQCACF_SUB_USER_ID );

    public final static FieldPCF<Subscription> PUBAPPID = new FieldPCF<>(String.class, CMQCFC.MQCACF_APPL_IDENTITY_DATA);
    public final static FieldPCF<Subscription> PUBACCT = new FieldPCF<>(String.class, CMQCFC.MQBACF_ACCOUNTING_TOKEN);
    public final static FieldPCF<Subscription> SELECTOR = new FieldPCF<>(String.class, CMQCFC.MQCACF_SUB_SELECTOR);
    public final static FieldPCF<Subscription> SELECTORTYPE = new FieldPCF<>(int.class, CMQCFC. MQIACF_SELECTOR_TYPE);
    //public final static FieldPCF<Subscription> USERDATA = new FieldPCF<>(String.class, CMQCFC.MQCACF_SUBSCRIPTION_USER_DATA);
    public final static FieldPCF<Subscription> USERDATA = new FieldPCF<>(String.class, CMQCFC.MQCACF_SUB_USER_DATA);
    public static final FieldPCF<Subscription> DURABLE = new FieldPCF<>(int.class, CMQCFC.MQIACF_DURABLE_SUBSCRIPTION);
    public final static FieldPCF<Subscription> EXPIRY= new FieldPCF<>(int.class, CMQCFC.MQIACF_EXPIRY, ValuesMappingPCFSubscription.EXÏRY);
    public final static FieldPCF<Subscription> PSPROP= new FieldPCF<>(int.class, CMQCFC.MQIACF_PUBSUB_PROPERTIES, ValuesMappingPCFSubscription.PSPROP);
    public static final FieldPCF<Subscription> PUBPTY= new FieldPCF<>(int.class, CMQCFC.MQIACF_PUB_PRIORITY);
    public final static FieldPCF<Subscription> REQONLY= new FieldPCF<>(int.class, CMQCFC.MQIACF_REQUEST_ONLY, ValuesMappingPCFSubscription.REQONLY);
    public static final FieldPCF<Subscription> SUBTYPE= new FieldPCF<>(int.class, CMQCFC.MQIACF_SUB_TYPE); //ou cela est t'il utilise ??
    public final static FieldPCF<Subscription> SUBSCOPE= new FieldPCF<>(int.class, CMQCFC.MQIACF_SUBSCRIPTION_SCOPE, ValuesMappingPCFSubscription.SUBSCOPE);
    public static final FieldPCF<Subscription> SUBLEVEL = new FieldPCF<>(int.class, CMQCFC.MQIACF_SUB_LEVEL);
    public final static FieldPCF<Subscription> WILDCARD= new FieldPCF<>(int.class, CMQCFC.MQIACF_WILDCARD_SCHEMA, ValuesMappingPCFSubscription.WILDCARD);

Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Thu Aug 22, 2019 12:21 pm Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3252
Location: London, ON Canada

What is that? Yuk.

Here is Java MQ/PCF code to get information on all of the subscriptions in a queue manager:

Code:
PCFMessage request = new PCFMessage(CMQCFC.MQCMD_INQUIRE_SUBSCRIPTION);
request.addParameter(CMQCFC.MQCACF_SUB_NAME, new String("*"));

PCFMessage[] responses = agent.send(request);

for (int i = 0; i < responses.length; i++)
{
   if ((responses[i]).getCompCode() == CMQC.MQCC_OK)
   {
      String subName   = responses[i].getStringParameterValue(CMQCFC.MQCACF_SUB_NAME);
      String topicName = responses[i].getStringParameterValue(CMQC.MQCA_TOPIC_NAME);
      String topicStr  = responses[i].getStringParameterValue(CMQC.MQCA_TOPIC_STRING);
      int durable      = responses[i].getIntParameterValue(CMQCFC.MQIACF_DURABLE_SUBSCRIPTION);
      int subType      = responses[i].getIntParameterValue(CMQCFC.MQIACF_SUB_TYPE);
      System.out.println("subName="+subName.trim()+" : topicName="+topicName.trim()+" : topicStr="+topicStr.trim() + " : durable="+durable+" : subType="+subType);
   }
}


Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
hughson
PostPosted: Thu Aug 22, 2019 2:51 pm Post subject: Re: GET SUBSCRIPTION FIELD WITH PCF Reply with quote

Padawan

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

pcouas wrote:

Code:

    public final static FieldPCF<Subscription> DESTCLAS= new FieldPCF<>(int.class, CMQCFC.MQCACF_DESTINATION, ValuesMappingPCFSubscription.DESTCLAS); //todo

I can tell you just by a brief glance, that this one doesn't look correct. DESTCLAS should have values MANAGED or PROVIDED. DEST (MQCACF_DESTINATION) is the name of the PROVIDED queue.

If you want to know whether you are using the correct constant values, why not compare your code to the page in Knowledge Center that tells you how to use the PCF command MQCMD_INQUIRE_SUBSCRIPTION.

You can find it here:

Inquire Subscription

And to understand what the response values are, also refer to this page:

Inquire Subscription (Response)

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
fjb_saper
PostPosted: Thu Aug 22, 2019 8:41 pm Post subject: Reply with quote

Grand High Poobah

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

@pcouas
Wouahw looks like nothing beats doing it the hard way!!!.
Please look at Roger's post.
Using the PCFMessageAgent and the PCFMessage and it's methods is much more elegant and helps a lot with maintainability.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
pcouas
PostPosted: Fri Aug 23, 2019 2:49 am Post subject: Reply with quote

Voyager

Joined: 06 Sep 2011
Posts: 79

Hi

What is constant NAME with value -1 for expiry ?
What is constant NAME with value 2 for subscope

regards

My currebt JSON Rest answer
[code]
{
"date": "2019-08-23 12:44:26",
"fieldmq": {
"subname": "SYSTEM.DEFAULT.SUB",
"subtype": "ADMIN",
"topicstr": "",
"topicobj": "",
"destclas": "PROVIDED",
"destqmgr": "",
"destcrrlid": 0,
"varuserid": "ANY",
"subuser": "",
"pubappid": "",
"selector": "",
"selectortype": "NONE",
"userdata": "",
"durable": "YES",
"psprop": "MESSAGEPROPERTY",
"pubpty": "PUBLISHED",
"reqonly": "ALL",
"sublevel": 1,
"wschema": "TOPIC",
"displaytype": "RESOLVED"
},
[code]
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Aug 23, 2019 4:44 am Post subject: Reply with quote

Grand High Poobah

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

pcouas wrote:
Hi

What is constant NAME with value -1 for expiry ?
What is constant NAME with value 2 for subscope

regards


If you had checked the PCF response for inquire subscription, you would have found following: MQConstants.MQTSCOPE_ALL

For expiry please read https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.1.0/com.ibm.mq.ref.adm.doc/q088050_.htm
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
pcouas
PostPosted: Fri Aug 23, 2019 5:07 am Post subject: Reply with quote

Voyager

Joined: 06 Sep 2011
Posts: 79

my mistake CMQC.MQSCOPE_ALL !

And for expiry what is constant name -1?
int MQCIH_PASS_EXPIRATION = 1;
int MQCIH_UNLIMITED_EXPIRATION = 0;
Back to top
View user's profile Send private message
hughson
PostPosted: Fri Aug 23, 2019 8:09 pm Post subject: Re: GET SUBSCRIPTION FIELD WITH PCF Reply with quote

Padawan

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

pcouas wrote:
Hi

What is constant NAME with value -1 for expiry ?
What is constant NAME with value 2 for subscope


pcouas wrote:
my mistake CMQC.MQSCOPE_ALL !

And for expiry what is constant name -1?
int MQCIH_PASS_EXPIRATION = 1;
int MQCIH_UNLIMITED_EXPIRATION = 0;


hughson wrote:
And to understand what the response values are, also refer to this page:

Inquire Subscription (Response)


As noted before the page that describes the responses (linked above) should tell you all of this.

Unfortunately, it doesn't list the constant for expiry. The other place it is handy to read when looking specifically at subscriptions is the MQ API call, since whether you make a subscription programmatically or administratively, they are ultimately using the same values.

The MQSD (Subscription Descriptor) is the structure that an application making a subscription with the MQSUB call would provide all these values. Looking at the SubExpiry field we can see that apart from it being an integer value, there is also one special value, MQEI_UNLIMITED. If you look up the value of this constant, you will see that it has the value -1. Do not use the MQCIH_ constants here, they only apply to the MQCIH structure.

The constants for the SUBSCOPE parameter however, are documented in the link I gave you for this command. They are the MQTSCOPE_ constants. You have two possible values,
  • MQTSCOPE_ALL (2)
  • MQTSCOPE_QMGR (1)
Do not use the MQSCOPE_ constants, they are for a topic object.

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
hughson
PostPosted: Fri Aug 23, 2019 8:19 pm Post subject: Reply with quote

Padawan

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

pcouas wrote:
I tried to get correlid value without success in subscription
Code:
String ci1      = response.getStringParameterValue(CMQCFC.MQBACF_DESTINATION_CORREL_ID); //BAD Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to java.lang.String

To attempt to answer this question where your thread has been locked in favour of this one (not sure why since you are asking a specific question there), I think your problem is likely because you are attempting to getStringParameterValue when the output is not a string. Correl ID is a bytes field. This is why it's constant starts MQBACF instead of MQCACF. B for Bytes, C for Character.

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
hughson
PostPosted: Fri Aug 23, 2019 8:24 pm Post subject: Reply with quote

Padawan

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

pcouas wrote:
Hi

I tried to get Identity without success
Code:
String subName   = response.getStringParameterValue(CMQCFC.MQCACF_SUBSCRIPTION_IDENTITY); //Exception in thread "main" com.ibm.mq.pcf.PCFException: MQJE001: Code achevement '2', Motif '3015

Another question that has been forwarded to this thread for some unknown reason.

The return code 3015 is MQRCCF_CFST_PARM_ID_ERROR. You are trying to use MQCACF_SUBSCRIPTION_IDENTITY on an Inquire Subscription command, but it is not part of that command. Again, please read closely the pages I pointed you to earlier that describe how to use the command.

In case you are interested, MQCACF_SUBSCRIPTION_IDENTITY is part of the Queued Pub/Sub interface - nothing to do with the PCF Inquire Subscription command you are working with.

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
fjb_saper
PostPosted: Fri Aug 23, 2019 11:04 pm Post subject: Reply with quote

Grand High Poobah

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

From https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.1.0/com.ibm.mq.ref.adm.doc/q088050_.htm

Code:
SubID (MQCFBS)
    The internal, unique key identifying a subscription (parameter identifier: MQBACF_SUB_ID).

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
pcouas
PostPosted: Thu Aug 29, 2019 12:37 am Post subject: Reply with quote

Voyager

Joined: 06 Sep 2011
Posts: 79

Yes that's an Byte array
Code:

  private  String toHex(String original) {

        if (original == null) return null;

        char[] chars = original.toCharArray();
        StringBuffer buffer = new StringBuffer(original.length() * 2);

        for (int i = 0; i < chars.length; i++){
            buffer.append(Integer.toString((chars[i] & 0xff) + 0x100, 16).substring(1));
        }

        return buffer.toString();
    } // end of method toHex()
Back to top
View user's profile Send private message
hughson
PostPosted: Thu Aug 29, 2019 1:20 am Post subject: Reply with quote

Padawan

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

Are you all working now? Or is there a question in your last post?

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
pcouas
PostPosted: Thu Aug 29, 2019 1:31 am Post subject: Reply with quote

Voyager

Joined: 06 Sep 2011
Posts: 79

Yes All is Ok thanks
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexIBM MQ Java / JMSGET SUBSCRIPTION FIELD WITH PCF
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.