Topic
  • 6 replies
  • Latest Post - ‏2019-08-27T17:49:54Z by rvs432
rvs432
rvs432
14 Posts

Pinned topic url-open with mq:// and not dpmq://

‏2019-08-21T17:08:15Z | mq url-open

Hi

i have written a gateway policy to connect to MQ and put some message in my desired queue.

if i use following it works. (BTW i have created QM! object in my api connect domain)

target: 'dpmq://QM1/?RequestQueue=my.test.queue.request;ReplyQueue=my.test.queue.reply;SetReplyTo=false;TimeOut=5000;ParseHeaders=true',

But i want to use mq://

var queuename = 'my.test.queue.request' target: 'mq://myserver.mydoamin.com:2222?QueueManager=MYQMGR;Channel=MYCHANNEL;RequestQueue=' + queuename ;

i get unexpected token error :(

any idea whats issue ?

  • swlinn
    swlinn
    1446 Posts

    Re: url-open with mq:// and not dpmq://

    ‏2019-08-26T13:45:22Z  

    your "var queuename" statement above isn't valid javascript.  Can you paste a larger portion of your code?  The error should provide you the specific line at issue.

    Regards,
    Steve

  • rvs432
    rvs432
    14 Posts

    Re: url-open with mq:// and not dpmq://

    ‏2019-08-26T19:34:09Z  
    • swlinn
    • ‏2019-08-26T13:45:22Z

    your "var queuename" statement above isn't valid javascript.  Can you paste a larger portion of your code?  The error should provide you the specific line at issue.

    Regards,
    Steve

    I m confused.

     

    This is my working code.

     

    var queuename = 'my.test.queue.request' ;
    var options = {
        target: 'dpmq://QM1/?RequestQueue=' +queuename +';timeout=1000',  // QM1 is data power object created.
        headers: urlopenHeaders,  // this is header which MQ needs
        timeOut: 1000,
        data: '<data>Hello DataPower1 GatewayScript</data>'

    };

     

    I want to make this work .

     

    var queuename = 'my.test.queue.request' ;
    var options = {
        target : 'mq://myserver.mydoamin.com:2222?QueueManager=MYQMGR;Channel=MYCHANNEL;RequestQueue=' + queuename
        headers: urlopenHeaders,  // this is header which MQ needs
        timeOut: 1000,
        data: '<data>Hello DataPower1 GatewayScript</data>'

    };

  • swlinn
    swlinn
    1446 Posts

    Re: url-open with mq:// and not dpmq://

    ‏2019-08-26T20:53:09Z  
    • rvs432
    • ‏2019-08-26T19:34:09Z

    I m confused.

     

    This is my working code.

     

    var queuename = 'my.test.queue.request' ;
    var options = {
        target: 'dpmq://QM1/?RequestQueue=' +queuename +';timeout=1000',  // QM1 is data power object created.
        headers: urlopenHeaders,  // this is header which MQ needs
        timeOut: 1000,
        data: '<data>Hello DataPower1 GatewayScript</data>'

    };

     

    I want to make this work .

     

    var queuename = 'my.test.queue.request' ;
    var options = {
        target : 'mq://myserver.mydoamin.com:2222?QueueManager=MYQMGR;Channel=MYCHANNEL;RequestQueue=' + queuename
        headers: urlopenHeaders,  // this is header which MQ needs
        timeOut: 1000,
        data: '<data>Hello DataPower1 GatewayScript</data>'

    };

    Sorry for the confusion, now that I see the entire code that is failing, variable options is a JSON object.  All properties in the object you are defining must be separated by a comma, however, in your failing case, the target property, which is a concatenation of the long mq url string and the queuename variable, there is no comma, which is where you're getting your syntax error.  Place a comma after queuename.
     

    Regards,
    Steve

  • rvs432
    rvs432
    14 Posts

    Re: url-open with mq:// and not dpmq://

    ‏2019-08-26T21:02:16Z  
    • swlinn
    • ‏2019-08-26T20:53:09Z

    Sorry for the confusion, now that I see the entire code that is failing, variable options is a JSON object.  All properties in the object you are defining must be separated by a comma, however, in your failing case, the target property, which is a concatenation of the long mq url string and the queuename variable, there is no comma, which is where you're getting your syntax error.  Place a comma after queuename.
     

    Regards,
    Steve

    there is , in my code. I accidently when I pasted it (as I had to remove my env specific values).

     

    my question is about syntax of mq url

     

    is mq://myserver.mydoamin.com:2222?QueueManager=MYQMGR;Channel=MYCHANNEL;RequestQueue=' + queuename right ?

     

     

  • swlinn
    swlinn
    1446 Posts

    Re: url-open with mq:// and not dpmq://

    ‏2019-08-26T22:11:13Z  
    • rvs432
    • ‏2019-08-26T21:02:16Z

    there is , in my code. I accidently when I pasted it (as I had to remove my env specific values).

     

    my question is about syntax of mq url

     

    is mq://myserver.mydoamin.com:2222?QueueManager=MYQMGR;Channel=MYCHANNEL;RequestQueue=' + queuename right ?

     

     

    I did a lot of testing of the mq url with gatewayscript when it was first introduced, but that has been a while now, so my memory is a little spotty, but as I recall the mq:// urls you have to specify everything for connectivity to the MQ Server that would would have had on the DataPower queue manager object.  I found this comment is some of my old test code
     

                // mq://host:port?QueueManager=queueManager;UserName=userName;
                    // Channel=channelName;ChannelTimeout=channelTimeout;
                    // channelLimit=channelLimit;Size=maxMsgSize;
                    // MQCSPUserId=MQCSPUserID;MQCSPPassword=MQCSPPassword;
    

    So you may try some of these parameters and then of course you add other parameters as needed like you have for dpmq urls, in your case the RequestQueue.  You can look them up in the knowledge center for details on these specific parameters.

    Regards,

    Steve

  • rvs432
    rvs432
    14 Posts

    Re: url-open with mq:// and not dpmq://

    ‏2019-08-27T17:49:54Z  
    • swlinn
    • ‏2019-08-26T22:11:13Z

    I did a lot of testing of the mq url with gatewayscript when it was first introduced, but that has been a while now, so my memory is a little spotty, but as I recall the mq:// urls you have to specify everything for connectivity to the MQ Server that would would have had on the DataPower queue manager object.  I found this comment is some of my old test code
     

    <pre class="html dw" dir="ltr"> // mq://host:port?QueueManager=queueManager;UserName=userName; // Channel=channelName;ChannelTimeout=channelTimeout; // channelLimit=channelLimit;Size=maxMsgSize; // MQCSPUserId=MQCSPUserID;MQCSPPassword=MQCSPPassword; </pre>

    So you may try some of these parameters and then of course you add other parameters as needed like you have for dpmq urls, in your case the RequestQueue.  You can look them up in the knowledge center for details on these specific parameters.

    Regards,

    Steve

    Thanks for the help. Your syntax did help me out. I have resolved my issue. In the end it was typo in my URL :) The URL I was pasting here was right after editing but in my code I wasn't paying attention closely :)