|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
GET SUBSCRIPTION FIELD WITH PCF |
View previous topic :: View next topic |
Author |
Message
|
pcouas |
Posted: Thu Aug 22, 2019 7:13 am Post subject: GET SUBSCRIPTION FIELD WITH PCF |
|
|
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 |
|
 |
RogerLacroix |
Posted: Thu Aug 22, 2019 12:21 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 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 |
|
 |
hughson |
Posted: Thu Aug 22, 2019 2:51 pm Post subject: Re: GET SUBSCRIPTION FIELD WITH PCF |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 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 |
|
 |
fjb_saper |
Posted: Thu Aug 22, 2019 8:41 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 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 |
|
 |
pcouas |
Posted: Fri Aug 23, 2019 2:49 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Fri Aug 23, 2019 4:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
|
Back to top |
|
 |
pcouas |
Posted: Fri Aug 23, 2019 5:07 am Post subject: |
|
|
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 |
|
 |
hughson |
Posted: Fri Aug 23, 2019 8:09 pm Post subject: Re: GET SUBSCRIPTION FIELD WITH PCF |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 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; |
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 |
|
 |
hughson |
Posted: Fri Aug 23, 2019 8:19 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 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 |
|
 |
hughson |
Posted: Fri Aug 23, 2019 8:24 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 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 |
|
 |
fjb_saper |
Posted: Fri Aug 23, 2019 11:04 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
|
Back to top |
|
 |
pcouas |
Posted: Thu Aug 29, 2019 12:37 am Post subject: |
|
|
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 |
|
 |
hughson |
Posted: Thu Aug 29, 2019 1:20 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 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 |
|
 |
pcouas |
Posted: Thu Aug 29, 2019 1:31 am Post subject: |
|
|
Voyager
Joined: 06 Sep 2011 Posts: 79
|
|
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
|
|
|
|