Need help in implementing MQ support in Mountebank

1,239 views
Skip to first unread message

sumit.pra...@gmail.com

unread,
Mar 15, 2018, 2:09:09 AM3/15/18
to mountebank-discuss
Hi All,

I have been trying to extend Mountebank to build support for MQ. Has someone tried this before ?

In my case what I have been able to achieve so far using Mountebank is somewhat encouraging, but would need inputs to take it to closure.

I am able to create a protocol for MQ (IBM MQ) in Mountebank, which creates a mq client and connects to the IBM MQ server running outside mountebank (Unlike other protocols which create their server within Mountebank). 

This mq client is now capable of subscribing to any queue passed in the imposter creation request and listen to it. Hence, when another application drops a message onto the same queue, Mountebank is able to consume the message and publish a hard coded message onto another queue.

The problem is I want this hard coded to be resolved by a message passed in the imposter creation request, after matching the predicate. (which is the essence  of Mountebank)

Basically if someone could explain how are stubs resolved in mountebank. I am somehow getting lost in the code and unable to follow the pattern of steps.

Can someone please lend helping hand in this ???  I can provide a detail explanation if this is unclear.

Thanks,
Sumit

Brandon Byars

unread,
Mar 20, 2018, 12:31:26 PM3/20/18
to sumit.pra...@gmail.com, mountebank-discuss
Hi Sumit,
Sorry for the slow response. I'm back from vacation and happy to walk you through it. Is there a good time to chat this week?
-Brandon

--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

KP

unread,
May 3, 2018, 8:53:25 AM5/3/18
to mountebank-discuss
> To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

I am also interested to know how to implement MQ protocol in Mountebank. It will be great if you can please share a sample for reference.

nishat....@bnc.ca

unread,
Feb 27, 2019, 9:59:58 AM2/27/19
to mountebank-discuss
Hello Sunil,

Did you get the info on the issue you had? Can you share the info with me as i have to mock the MQ for my services?
Thanks in advance for the help.

Nishat

Brandon Byars

unread,
Feb 27, 2019, 11:15:04 AM2/27/19
to nishat....@bnc.ca, mountebank-discuss
I'm getting close to the next release of mountebank, which should make this much easier. You will be able to build protocol implementations in the language of your choice without having to understand all the mountebank code. All you'll have to understand is how to convert an incoming network request to a JSON representation, one (or two, with proxying) API calls into mountebank to get the JSON response representation, and how to convert the JSON response into a network response.

I haven't documented it yet (that's one of the things holding up the release) but if it's helpful I'm happy to go into more details before I can finish the release.
-Brandon


nishat....@bnc.ca

unread,
Mar 6, 2019, 1:24:23 PM3/6/19
to mountebank-discuss
Hello Brandon,

Sure i will be interested to know about this release. Let me know if we can connect directly and the preferred way.

I will be waiting for your response.

Regards
Nishat

Brandon Byars

unread,
Mar 22, 2019, 9:34:05 AM3/22/19
to nishat....@bnc.ca, mountebank-discuss
Hi Nishat,
Sorry for the late reply, but the v2.0.0 release went out last weekend, which allows you to create an MQ server in languages like Java and communicate to mountebank via a pretty small API. The documentation is here. Happy to chat offline if you need some help.
-Brandon

timlane...@gmail.com

unread,
Apr 1, 2019, 1:44:51 AM4/1/19
to mountebank-discuss
Brandon,

thanks for supporting mountebank, I love it.

I'm also working on a MQ implementation using mountebank and had spent a lot of time failing at getting rabbit mq running in node.js and then leveraging mountebank.

I noticed that v2 had custom protocols and while I can get the java code working in my simple IDE (reads off a queue OK) when I included it in the protocols.json and run it it tells its using a custom protocol but the messages never leave the queue.

Protocol.json:

{
"http": {
"createCommand": "node http.js",
"testRequest": {
"method": "GET",
"path": "/",
"query": {},
"headers": {},
"form": {},
"body": ""
},
"testProxyResponse": {
"statusCode": 200,
"headers": {},
"body": ""
}
},
"mbtest": {
"createCommand": "java \\_git\\perf_sven_protocol_test\\mbTest"
}
}

warn: [mb:2525] Using custom http implementation instead of the built-in one
info: [mb:2525] Loaded custom protocol mbtest
info: [mb:2525] mountebank v2.0.0 now taking orders - point your browser to http://localhost:2525/ for help


I've also got Systemm.out.println in my java code with the string info in my messages but none turn up in the log files.

Any pointers would be appreciated...

Also, there's an extra comma on your documentation page which causes a json error,

"createCommand": "java foo",
should be:
"createCommand": "java foo"

nishat....@bnc.ca

unread,
Apr 1, 2019, 9:45:52 AM4/1/19
to mountebank-discuss
Hello Guys

Can we have a chat on gmail to fix all this and make a running environment. It will be helpful for all and we can document it somewhere. Please let me know. waiting.

Brandon Byars

unread,
Apr 2, 2019, 10:20:07 AM4/2/19
to timlane...@gmail.com, mountebank-discuss
Hmm hard to say what's going on. Couple steps to help troubleshoot:
  • Try turning on the debug logs (mb --loglevel debug) to see if you get more info
  • Run the Java command outside of mountebank. You can pass the JSON object yourself on the command line with the fields you need, but you'll obviously have to construct it yourself. Verify the Java process is pulling messages off the queue. It could be something as simple as ignoring the port that mountebank is passing it.
Is it possible to share the Java code so I can take a look?
-Brandon

Brandon Byars

unread,
Apr 2, 2019, 10:27:09 AM4/2/19
to nishat....@bnc.ca, mountebank-discuss
Hi there,
Getting MQ working is clearly quite strategic for the product, and I'm happy to invest some time in helping troubleshoot where other people are trying. I've found in the past that group chats are difficult because people are spread out all over the globe, and unfortunately I have a pretty hectic schedule in my day job that makes it hard to respond real time. I certainly don't want to discourage you from collaborating with anyone else, but if you'd like my focused time it's probably easiest to schedule a video call, and I'm happy to include any interested parties for whom the time works.

I expect to be in the Central US time zone (Dallas) for the next few weeks. Where are you?
-Brandon

timlane...@gmail.com

unread,
Apr 2, 2019, 6:51:27 PM4/2/19
to mountebank-discuss
Hi,

code is in github, (https://github.com/bobruub/mbTest) pretty crude but it does work when run standalone but doesn't have any of the callback functions yet.

Sample Response when run standalone.

[*] Waiting for messages. To exit press CTRL+C
INFO: this is a test message

It also write to a text file (out.txt) when it starts as a check...

No change running it in debug mode.

When I run it in mountebank, the out.txt file is not updated and when I put a message on the queue the messages is not consumed.

I suspect I am doing something wrong in the protocol.json file.






On Wednesday, April 3, 2019 at 1:20:07 AM UTC+11, Brandon Byars wrote:
> Hmm hard to say what's going on. Couple steps to help troubleshoot:
> Try turning on the debug logs (mb --loglevel debug) to see if you get more infoRun the Java command outside of mountebank. You can pass the JSON object yourself on the command line with the fields you need, but you'll obviously have to construct it yourself. Verify the Java process is pulling messages off the queue. It could be something as simple as ignoring the port that mountebank is passing it.

Brandon Byars

unread,
Apr 2, 2019, 7:27:27 PM4/2/19
to timlane...@gmail.com, mountebank-discuss
One other simple question that I should have asked looking at your previous log output -- are you actually creating an mbtest imposter? If so, it's not represented in the log output, you're just showing the startup logs.

It looks like you're adding to protocols.json correctly, but adding it to there simply allows mountebank to accept imposters with a protocol of "mbtest". It doesn't actually create an imposter -- you'd still need to create one just like you would with http. For example, you could define the request format as 

{
  "message": "the output of delivery.getBody()"
}

Right now, you're just acking the request message. If you wanted the "response" to be a message on a separate queue, you could define the response format as something like:

{
  "message": "response message",
  "hostname": "",
  "queueName: ""
}

Then you could create an mbtest protocol, for example, with the following configuration:

{
  "port": 3000,
  "protocol": "mbtest",
  "stubs": [{
    "predicates": [{
      "contains": {
        "message": "TEST"
      }
    }],
    "responses": [{
      "message": "Got TEST message",
      "hostname": "outgoing-host-name",
      "queueName": "outgoing-queue-name"
    }]
  }]
}

You could send that on startup by passing the --configfile command line flag, or by POSTing to http://localhost:2525/imposters after startup. In that case, anything that didn't match the predicate wouldn't send an outgoing message (although your implementation should still ack the request message).

Make sense? When you get to the point of creating the imposter, feel free to send the debug logs if it's still not grabbing the message off the queue.
-Brandon


Message has been deleted
Message has been deleted

timlane...@gmail.com

unread,
Apr 3, 2019, 1:40:59 AM4/3/19
to mountebank-discuss
thanks for the feedback, with your advice I am getting closer.

Firstly, your sample returns an error when I try to start it.

info: [mb:1234] Loaded custom protocol mbtest
info: [mb:1234] mountebank v2.0.0 now taking orders - point your browser to http://localhost:1234/ for help
debug: [mb:1234] config: {"options":{"protofile":"protocols.json","configfile":"protocols.ejs","loglevel":"debug","port":1234,"allowInjection":true,"callbackURLTemplate":"http://localhost:2525/imposters/:2525/_requests","noParse":false,"pidfile":"mb.pid","nologfile":false,"logfile":"mb.log","localOnly":false,"ipWhitelist":["*"],"mock":false,"debug":false,"heroku":false},"process":{"nodeVersion":"v8.12.0","architecture":"x64","platform":"win32"}}
warn: [mb:1234] Running with --allowInjection set. See http://localhost:1234/docs/security for security info
info: [mb:1234] PUT /imposters
debug: [mb:1234] ::ffff:127.0.0.1:53282 => {"imposters":[{"port":3000,"protocol":"mbtest","stubs":[{"predicates":[{"contains":{"message":"TEST"}}],"responses":[{"message":"Got TEST message","hostname":"outgoing-host-name","queueName":"outgoing-queue-name"}]}]}]}
error: [mb:1234] error creating imposter: [{"code":"bad data","message":"unrecognized response type","source":{"message":"Got TEST message","hostname":"outgoing-host-name","queueName":"outgoing-queue-name"}}]

So i pivoted and hacked one from an existing service i'd built.

it's a bit convaluted so I'll provide all my configs.

protocols.json
{
"mbtest": {
"createCommand": "mbTest.cmd"
}
}

protocols.ejs
{
"port": 3000,
"protocol": "mbtest",
"name": "**-- Protocol Test - port 3000 --**",
"stubs": [{
"responses":
[{
"inject": "<%- stringify(filename, 'spectrum//showme.ejs') %>"
}],
"predicates":
[{
"contains": {"message": "TEST"}}]
}]
}

spectrum//showme
function (request, state, logger) {
logger.info('Show Me Debugging');

return {"SVEN SPECTRUM STUB - showme test page"};
}

Startup Command
C:\_software\mountebank-v2.0.0-win-x64\mb.cmd --protofile protocols.json --configfile protocols.ejs --loglevel debug --port 1234 --allowInjection --callbackURLTemplate http://localhost:2525/imposters/:2525/_requests

info: [mb:1234] Loaded custom protocol mbtest
info: [mb:1234] mountebank v2.0.0 now taking orders - point your browser to http://localhost:1234/ for help
debug: [mb:1234] config: {"options":{"protofile":"protocols.json","configfile":"protocols.ejs","loglevel":"debug","port":1234,"allowInjection":true,"callbackURLTemplate":"http://localhost:2525/imposters/:2525/_requests","noParse":false,"pidfile":"mb.pid","nologfile":false,"logfile":"mb.log","localOnly":false,"ipWhitelist":["*"],"mock":false,"debug":false,"heroku":false},"process":{"nodeVersion":"v8.12.0","architecture":"x64","platform":"win32"}}
warn: [mb:1234] Running with --allowInjection set. See http://localhost:1234/docs/security for security info
info: [mb:1234] PUT /imposters
debug: [mb:1234] ::ffff:127.0.0.1:53539 => {"imposters":[{"port":3000,"protocol":"mbtest","name":"**-- Protocol Test - port 3000 --**","stubs":[{"responses":[{"inject":"function (request, state, logger) {\r\n logger.info('Show Me Debugging');\r\n\t\t\t\r\n\treturn {\"SVEN SPECTRUM STUB - showme test page\"};\t\r\n}"}],"predicates":[{"contains":{"message":"TEST"}}]}]}]}
info: [mbtest:3000 **-- Protocol Test - port 3000 --**] Open for business...

and when I put a message onto the queue it is actually consumed :)

However, i see no activity in any of the log files :(

But movement is progress...


nishat....@bnc.ca

unread,
Apr 3, 2019, 9:53:11 PM4/3/19
to mountebank-discuss
Hello guys,

i am getting below error while running it. any clue.

./mbstart.sh
warn: [mb:1234] Using custom http implementation instead of the built-in one
info: [mb:1234] Loaded custom protocol mbtest
info: [mb:1234] mountebank v2.0.0 now taking orders - point your browser to http://localhost:1234/ for help
debug: [mb:1234] config: {"options":{"noParse":false,"nologfile":false,"allowInjection":true,"localOnly":false,"mock":false,"debug":false,"heroku":false,"protofile":"protocols.json","configfile":"protocols.ejs","loglevel":"debug","port":1234,"callbackURLTemplate":"http://localhost:2525/imposters/:2525/_requests","pidfile":"mb.pid","logfile":"mb.log","ipWhitelist":["*"]},"process":{"nodeVersion":"v8.15.1","architecture":"x64","platform":"darwin"}}
warn: [mb:1234] Running with --allowInjection set. See http://localhost:1234/docs/security for security info
info: [mb:1234] PUT /imposters
debug: [mb:1234] ::ffff:127.0.0.1:63130 => {"imposters":[{"port":3000,"protocol":"mbtest","name":"**-- Protocol Test - port 3000 --**","stubs":[{"responses":[{"inject":"function (request, state, logger) { \n logger.info('Show Me Debugging'); \n return {\"SVEN SPECTRUM STUB - showme test page\"}; \n}"}],"predicates":[{"contains":{"message":"TEST"}}]}]}]}
error: [mb:1234] error creating imposter: {"code":"cannot start server","message":"Invalid configuration for protocol \"mbtest\": cannot run \"mbstart.sh\"","source":"mbstart.sh","details":{"errno":"ENOENT","code":"ENOENT","syscall":"spawn mbstart.sh","path":"mbstart.sh","spawnargs":["{\"port\":3000,\"callbackURLTemplate\":\"http://localhost:1234/imposters/:port/_requests\",\"loglevel\":\"debug\",\"allowInjection\":true}"]},"domain":{"domain":null,"_events":{},"_eventsCount":1,"members":[]},"domainThrown":true,"name":"Error","stack":"Error\n at Object.from (/Users/s00001/Downloads/mountebank-v2.0.0-darwin-x64/mountebank/src/util/inherit.js:15:17)\n at createError (/Users/s00001/Downloads/mountebank-v2.0.0-darwin-x64/mountebank/src/util/errors.js:10:26)\n at Object.ProtocolError (/Users/s00001/Downloads/mountebank-v2.0.0-darwin-x64/mountebank/src/util/errors.js:21:34)\n at ChildProcess.imposterProcess.on.error (/Users/s00001/Downloads/mountebank-v2.0.0-darwin-x64/mountebank/src/models/protocols.js:60:40)\n at emitOne (events.js:116:13)\n at ChildProcess.emit (events.js:211:7)\n at Process.ChildProcess._handle.onexit (internal/child_process.js:196:12)\n at onErrorNT (internal/child_process.js:362:16)\n at _combinedTickCallback (internal/process/next_tick.js:139:11)\n at process._tickCallback (internal/process/next_tick.js:181:9)"}

Brandon Byars

unread,
Apr 4, 2019, 11:43:31 AM4/4/19
to nishat....@bnc.ca, mountebank-discuss
It means that the createCommand referenced in the protocols.json file fails. ENOENT means the file can't be found or accessed, which could be due to the current working directory of the mb process being different than what you expect. I'd try using an absolute path to see if that fixes it.
-Brandon
Message has been deleted

reshma...@gmail.com

unread,
Jul 18, 2019, 9:49:06 AM7/18/19
to mountebank-discuss
Hi Team,
Thanks for raising this issue over this mounteBank group.

As per this group chain i have tried the same steps which are mentioned above.

I am able to create the MQ Jar and I am able to create the imposter also.

But the issue i am facing is, i cant see any consumers on the Queue and no messages are getting consumed from the queue [Rather those are getting piled up]

So could you please analyse the jar files which i have created and help me to understand where am i going wrong.

So it will be very helpful, if you can share the jar file which you have created and working fine

Kindly let me know, if you need any other details on the same.

Regards
Reshma

####PFB the java source code###

package com.sv.test.kewill;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Properties;

import com.ibm.mq.MQException;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPutMessageOptions;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.constants.MQConstants;

public class Mountebanktest {

String hostName=null; // host name
String channel=null; // server connection channel
String port=null; // port number on which the QMGR is running
// FileInputStream fileInputStream = new FileInputStream(fileName);
String qmgrName=null;
// define the name of the QueueManager
private static final String qManager = "test";

// and define the name of the Queue
private static final String qName = "REQ";

/**
* Main entry point
*
* @param args - command line arguments (ignored)
* @throws MQException
* @throws InterruptedException
*/
public static void main(String[] args) throws MQException, InterruptedException{
mqOpen("Test1");
}
public static void mqOpen(String output) throws MQException, InterruptedException {

//String hostName=null; // host name
//String channel=null; // server connection channel
// String port=null;
//String qName=null;// port number on which the QMGR is running
//public String qmgrName; // queue manager name
//public String qName; // queue name

Hashtable<String, Object> props = new Hashtable<String, Object>();

props.put(MQConstants.CHANNEL_PROPERTY, "test");
// props.put(MQConstants.CHANNEL_PROPERTY, channel);
props.put(MQConstants.PORT_PROPERTY, 1414);
//props.put(MQConstants.PORT_PROPERTY, port);
props.put(MQConstants.HOST_NAME_PROPERTY, "test");
// props.put(MQConstants.HOST_NAME_PROPERTY,hostName);
MQQueueManager qMgr=null;
try {
// Create a connection to the QueueManager
System.out.println("Connecting to queue manager: " + qManager);
qMgr = new MQQueueManager(qManager,props);
System.out.println("mgr"+qMgr.toString());

// Set up the options on the queue we wish to open
int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT;

// Now specify the queue that we wish to open and the open options
System.out.println("Accessing queue: " + qName);
MQQueue queue = qMgr.accessQueue(qName, openOptions);

// Define a simple WebSphere MQ Message ...
MQMessage msg = new MQMessage();
// ... and write some text in UTF8 format
//msg.writeUTF("Hello, World!");
// msg.writeBytes("Hello, World!");
// msg.writeString("Hello, World!");
msg.writeString(output);

// Specify the default put message options
MQPutMessageOptions pmo = new MQPutMessageOptions();

// Put the message to the queue
System.out.println("Sending a message...");
queue.put(msg, pmo);
// Thread.sleep(8000);

// Now get the message back again. First define a WebSphere MQ
// message
// to receive the data
// MQMessage rcvMessage = new MQMessage();

// Specify default get message options
//MQGetMessageOptions gmo = new MQGetMessageOptions();

// Get the message off the queue.
// System.out.println("...and getting the message back again");
//queue.get(rcvMessage, gmo);

// And display the message text...
// String msgText = rcvMessage.readUTF();
// System.out.println("The message is: " + msgText);

// Close the queue
System.out.println("Closing the queue");
queue.close();


}
catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode
+ " Reason Code " + ex.reasonCode);
ex.printStackTrace();
for (Throwable t = ex.getCause(); t != null; t = t.getCause()) {
System.out.println("... Caused by ");
t.printStackTrace();
}

}
catch (java.io.IOException ex) {
System.out.println("An IOException occured whilst writing to the message buffer: " + ex);
}
finally{
// Disconnect from the QueueManager
System.out.println("Disconnecting from the Queue Manager");

qMgr.close();
qMgr.disconnect();
System.out.println("Done!");

}

return;
}

}

reshma...@gmail.com

unread,
Sep 30, 2019, 5:02:58 AM9/30/19
to mountebank-discuss
Hi Team,

Could you please provide an update on this MQ support for mountebank.

Thanks and Regards,
Reshma

vaibhavja...@gmail.com

unread,
Jan 22, 2020, 4:48:58 AM1/22/20
to mountebank-discuss
Hi Brandon,

Hope you are doing well.

I was trying to configure the custom protocol for IBM MQ. I am able to invoke the jar file (which reads messages from a queue and responds a static message to another queue). However, i am not sure how to have the data part aligned with the imposter, as the incoming request (read from MQ) should be sent to imposter for a response and then same response should be sent as reply over MQ.

Could you please help me with some pointers.

Kind Regards,
Vaibhav Jain
> > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.

>
> >
>
> > >
>
> >
>
> > > For more options, visit https://groups.google.com/d/optout.
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
>
> >
>
> > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.

>
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.

raghuramgu...@gmail.com

unread,
Jan 29, 2020, 9:16:49 AM1/29/20
to mountebank-discuss
Hi Vaibhav,

would you please send me the sample code it, as we are trying to do to the same thing and I'm newbie to this Mountebank

sonalkh...@gmail.com

unread,
Jun 30, 2020, 7:46:15 AM6/30/20
to mountebank-discuss
Can you please someone share the code or steps how to use ibm mq with mounteBank.i am new to this tool.

bhavy...@gmail.com

unread,
Jul 19, 2020, 12:27:08 PM7/19/20
to mountebank-discuss
Hi Reshma, 

I went thru your below code . Were you successful in making a connection between MQ and moutebank?

palaksa...@gmail.com

unread,
Jul 27, 2020, 7:35:12 AM7/27/20
to mountebank-discuss
Hi, 

I am getting below error:


error: [mb:1234] error creating imposter: {"code":"cannot start server","message":"Invalid configuration for protocol \"mbtest\": cannot run \"mbTest.cmd\"","source":"mbTest.cmd","details":{"errno":"ENOENT","code":"ENOENT","syscall":"spawn mbTest.cmd","path":"mbTest.cmd","spawnargs":["{\"port\":3000,\"callbackURLTemplate\":\"http://localhost:1234/imposters/:port/_requests\",\"loglevel\":\"debug\",\"allowInjection\":true}"]},"domainThrown":true,"name":"Error","stack":"Error\n    at Object.from (C:\\Users\\palak.salgotra\\AppData\\Roaming\\npm\\node_modules\\mountebank\\src\\util\\inherit.js:15:17)\n    at createError (C:\\Users\\palak.salgotra\\AppData\\Roaming\\npm\\node_modules\\mountebank\\src\\util\\errors.js:10:26)\n    at Object.ProtocolError (C:\\Users\\palak.salgotra\\AppData\\Roaming\\npm\\node_modules\\mountebank\\src\\util\\errors.js:21:34)\n    at ChildProcess.<anonymous> (C:\\Users\\palak.salgotra\\AppData\\Roaming\\npm\\node_modules\\mountebank\\src\\models\\protocols.js:78:40)\n    at ChildProcess.emit (events.js:315:20)\n    at ChildProcess.EventEmitter.emit (domain.js:482:12)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)\n    at onErrorNT (internal/child_process.js:469:16)\n    at processTicksAndRejections (internal/process/task_queues.js:84:21)"}


Could somebody explain. Any solution to run below mentioned command?

> > > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > > For more options, visit https://groups.google.com/d/optout.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > --
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> >
> > >
> >
> > > For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.

Brandon Byars

unread,
Jul 27, 2020, 7:48:05 AM7/27/20
to palaksa...@gmail.com, mountebank-discuss
Hi there,
It looks like the createCommand in the protocol file refers to mbTest.cmd, but mbTest.cmd doesn't exist. You may need to give an absolute path. It's possible you also need to wrap it with the shell executable ("cmd /c ./mbTest.cmd")
-Brandon


> > > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > > For more options, visit https://groups.google.com/d/optout.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > --
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
> >
> > >
> >
> > > For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mountebank-discuss/cd623f14-d274-4352-aae4-6e5718c9e519o%40googlegroups.com.

palaksa...@gmail.com

unread,
Jul 28, 2020, 3:28:12 AM7/28/20
to mountebank-discuss
Hi Brandon,

We tried your suggestion  and are able to make a connection as below:


D:\mbTest-master\mbTest-master>mb.cmd --protofile protocols.json --configfile protocols.ejs --loglevel debug --port 1114 --allowInjection --callbackURLTemplate http://localhost:2525/imposters/:2525/_requests
info: [mb:1114] Loaded custom protocol mbtest
warn: [mb:1114] Running with --allowInjection set. See http://localhost:1114/docs/security for security info
info: [mb:1114] mountebank v2.2.1 now taking orders - point your browser to http://localhost:1114/ for help
debug: [mb:1114] config: {"options":{"protofile":"protocols.json","configfile":"protocols.ejs","loglevel":"debug","port":1114,"allowInjection":true,"callbackURLTemplate":"http://localhost:2525/imposters/:2525/_requests","noParse":false,"pidfile":"mb.pid","nologfile":false,"logfile":"mb.log","localOnly":false,"ipWhitelist":["*"],"mock":false,"debug":false,"heroku":false},"process":{"nodeVersion":"v12.18.2","architecture":"x64","platform":"win32"}}
info: [mb:1114] PUT /imposters
debug: [mb:1114] ::ffff:127.0.0.1:59994 => {"imposters":[{"port":3000,"protocol":"mbtest","name":"**-- Protocol Test - port 3000 --**","stubs":[{"responses":[{"inject":"function (request, state, logger) {\r\n    logger.info('Show Me Debugging');\r\n                        \r\n        return {\"SVEN SPECTRUM STUB - showme test page\"};        \r\n}"}],"predicates":[{"contains":{"message":"TEST"}}]}]}]}
info: [mbtest:3000 **-- Protocol Test - port 3000 --**] Open for business...



Can you suggest what next is to be done? How to publish and subscribe messages?
A little suggestion would also be helpful as we are new to this tool.


Thanks
Palak

______________________________________________________________________________________________________________________________________________
> > > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > > For more options, visit https://groups.google.com/d/optout.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > --
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> >
> > >
> >
> > > For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send an email to <a

palaksa...@gmail.com

unread,
Jul 28, 2020, 8:45:50 AM7/28/20
to mountebank-discuss

Hi Brandon

 

Our requirement is to virtualize active MQ.

We have below code to connect, subscribe, publish message to active MQ. Can you please tell me how to integrate with our protocol.json file.

Also note that, we are starting activeMq client in command prompt (D:\............\apache-activemq-5.15.13-bin\apache-activemq-5.15.13\bin\win64\activemq)

 


var stompit = require('stompit');

 

// Configure connection management

 

var servers = [

  {

    host: 'localhost',

    port: 61613,

    connectHeaders:{

      'host': 'localhost',

      'login': 'admin',

      'passcode': 'password',

      'heart-beat': '100,100'

    }

  }

];

 

var reconnectOptions = {

  maxReconnects: 1

};

 

var connections = new stompit.ConnectFailover(servers, reconnectOptions);

 

// Log connection events

 

connections.on('connecting', function(connector) {

 

  var address = connector.serverProperties.remoteAddress.transportPath;

 

  console.log('Connecting to ' + address);

});

 

connections.on('error', function(error) {

 

  var connectArgs = error.connectArgs;

  var address = connectArgs.host + ':' + connectArgs.port;

 

  console.log('Connection error to ' + address + ': ' + error.message);

});

 

// Create channel, subscribe to a queue, and consume one message

 

var channelFactory = new stompit.ChannelFactory(connections);

 

 

channelFactory.channel(function(error, channel) {

 

  if (error) {

    console.log('channel factory error: ' + error.message);

    return;

  }

 

  var headers = {

    'destination': '/queue/testactivemq',

    'ack': 'client-individual'

  };

 

  channel.subscribe(headers, function(error, message, subscription){

   

    if (error) {

      console.log('subscribe error: ' + error.message);

      return;

    }

   

    message.readString('utf8', function(error, string) {

         

      if (error) {

        console.log('read message error: ' + error.message);

        return;

      }

     

      console.log('receive message: ' + string);

 

      channel.ack(message);

     

      // We only want to consume one message so we unsubscribe now 

      subscription.unsubscribe();

    });

  });

});

 


Thanks

Palak

-------------------------------------------------------------------------------------------------


On Monday, July 27, 2020 at 5:18:05 PM UTC+5:30, Brandon Byars wrote:
> > > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > > For more options, visit https://groups.google.com/d/optout.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > --
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > >
> >
> > > >
> >
> > >
> >
> > > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
> >
> > >
> >
> > > For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send an email to <a

Ramya Thiyagu

unread,
Aug 27, 2020, 7:35:28 AM8/27/20
to mountebank-discuss
Hi Brandon,

I am trying to implement IBM MQ Protocol in Mountebank.I have created a separate java file that will read message from a queue, post message to Mountebank(which is using http protocol) , get the response from Mountebank and put the response message to another Queue.I want to implement this as a protocol in Mountebank using protocols.json. I created jar file and called it from protocols.json but when the java program posts the request queue message to  http://localhost:2525/imposters/:port/_requests(CallBackUrl). I am getting  500 Internal Server error.The error message says 
TypeError: Cannot read property &#39;ip&#39; of undefined<br> &nbsp; &nbsp;at Object.getResponseFor (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\src\models\imposter.js:69:42)<br> &nbsp; &nbsp;at postRequest (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\src\controllers\imposterController.js:129:18)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\node_modules\express\lib\router\layer.js:95:5)<br> &nbsp; &nbsp;at next (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\node_modules\express\lib\router\route.js:137:13)<br> &nbsp; &nbsp;at validateImposterExists (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\src\util\middleware.js:90:13)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\node_modules\express\lib\router\layer.js:95:5)<br> &nbsp; &nbsp;at next (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\node_modules\express\lib\router\route.js:137:13)<br> &nbsp; &nbsp;at Route.dispatch (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\node_modules\express\lib\router\route.js:112:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\node_modules\express\lib\router\layer.js:95:5)<br> &nbsp; &nbsp;at C:\mountebank-v2.1.0-win-x64\mountebank-v2.1.0-win-x64\mountebank\node_modules\express\lib\router\index.js:281:22</pre>    .

Please could you explain how to communicate to mountebank with the request message and get response back .

Thanks and Regards,
Ramya.

Brandon Byars

unread,
Aug 30, 2020, 3:35:55 PM8/30/20
to Ramya Thiyagu, mountebank-discuss
Hi Ramya,
Can you show me the body you're POSTing to http://localhost:2525/imposters/:port/_requests(CallBackUrl)? Also, just to confirm, the actual URL should look something like http://localhost:2525/imposters/3000/_requests, right?
-Brandon

To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.

Ramya Thiyagu

unread,
Aug 31, 2020, 3:29:10 AM8/31/20
to mountebank-discuss
Hi Brandon,

PFB the java method that I am using to post message to Mountebank which listens on port 4548 and is a http service.The callback url will be replaced by the port like  http://localhost:2525/imposters/4548/_requests when I make it as a protocol. The Data that the below method accepts is the request message taken from a queue.It is a json request message. Please let me know if you need any other details.

private static String sendingPostRequest(String Data) throws Exception {
 
  String url = "http://localhost:4548";
  URL obj = new URL(url);
  HttpURLConnection con = (HttpURLConnection) obj.openConnection();
 
        // Setting basic post request
  con.setRequestMethod("POST");
  con.setRequestProperty("User-Agent", USER_AGENT);
  con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  con.setRequestProperty("Content-Type","application/json");
 
  String postJsonData = Data;
  
  // Send post request
  con.setDoOutput(true);
  DataOutputStream wr = new DataOutputStream(con.getOutputStream());
  wr.writeBytes(postJsonData);
  wr.flush();
  wr.close();
 
  int responseCode = con.getResponseCode();
  System.out.println("nSending 'POST' request to URL : " + url);
  System.out.println("Post Data : " + postJsonData);
  System.out.println("Response Code : " + responseCode);
 
  BufferedReader in = new BufferedReader(
          new InputStreamReader(con.getInputStream()));
  String output;
  StringBuffer response = new StringBuffer();
 
  while ((output = in.readLine()) != null) {
   response.append(output);
  }
  in.close();
  
  //printing result from response
  System.out.println(response.toString());
  return response.toString();
}
Message has been deleted

Brandon Byars

unread,
Sep 7, 2020, 4:10:56 PM9/7/20
to Ramya Thiyagu, mountebank-discuss
Thanks Ramya. The JSON object you POST has to contain a "request" key, with the custom request fields following. Try changing {"Article":{"articleIds":["10005242"],"query":"ABC"}} to { "request": { "Article": ..., "query": "ABC" } } and see if that does the trick.
-Brandon

On Mon, Aug 31, 2020 at 3:22 AM Ramya Thiyagu <ramyath...@gmail.com> wrote:
Hi Brandon,

The body that I am posting to   http://localhost:2525/imposters/4548/_requests  looks like {"Article":{"articleIds":["10005242"],"query":"ABC"}}.
My imposter is 
{
  "port": 4548,
  "protocol": "IBMMQ",
   "name": "test",
               "defaultResponse": {
                              "statusCode": 405,
                              "body": "Invalid Input",
                              "headers": {
                                             "Content-Type": "text/plain",
                                             "Response": "From Default"
                              }
               },
  "stubs": [
    {
      "responses": [
               {
                   "is": {
                        "statusCode": 200,
                        "headers": {
                            "Content-Type": "application/json"
                        }
                    },
          "_behaviors": {
            "shellTransform": ["node OMS002b.js"]
          }
        }
      ]
    }
  ]
}

Thanks and Regards,
Ramya.

Brandon Byars

unread,
Sep 7, 2020, 4:19:03 PM9/7/20
to Ramya Thiyagu, mountebank-discuss
And thanks for showing the JSON you were sending. That made me realize that the docs were unclear on that point; I've just committed an update to hopefully clarify.
-Brandon

palak salgotra

unread,
Sep 9, 2020, 9:40:48 AM9/9/20
to mountebank-discuss

Hi Brandon,

We are fetching the messageId from headers in MQMD tags in request in get function/call  for MQ, but not able to push it in response body in header through  put function/call.
can yo usuggest anything on this
Message has been deleted

Brandon Byars

unread,
Sep 26, 2020, 10:23:08 AM9/26/20
to palak salgotra, mountebank-discuss
Hi Palak,
There's not a lot of detail in your message, but it sounds like a different issue than the MQ implementation. If true, can you start a new thread and provide enough detail to help troubleshoot, which generally involves sample imposter configuration and error message.
-Brandon

On Tue, Sep 22, 2020 at 12:35 PM palak salgotra <palaksa...@gmail.com> wrote:
Hi,

We are using keystore and other files in kdb format for SSL configuration in the code, but we are getting some key repository error. Could you help us with this?

Message has been deleted

palak salgotra

unread,
Sep 28, 2020, 7:59:37 AM9/28/20
to mountebank-discuss
Hi Brandon,

We are trying to make a secure connection using SSL . We have given details of cipher suite, keystore file(kdb format) and other queue configurations details.

While running with all details, we are either getting SSL_INITIALISATION_ERROR  or KEY_REPOSITOTY_ERROR.

Could you help us with this secure connection how to do that ?

Thanks
Palak

Muthukumar Selvarasu

unread,
Apr 28, 2021, 2:52:15 AM4/28/21
to mountebank-discuss
Hi all, 

does anyone have a reference for MQ protocol or community extension

please advise. 

Thanks

Muthukumar Selvarasu

unread,
Apr 28, 2021, 3:04:29 AM4/28/21
to mountebank-discuss
Hi all, 

I want to add MQ protocol implementation in NodeJs. 

Thanks 

Guru Prasad

unread,
Apr 4, 2023, 1:59:30 AM4/4/23
to mountebank-discuss
Hi Team,

I would like to learn Mountebank.
Can anyone have Mountebank videos pls send to me.
I'd be grateful if you could provide videos ASAP.


Thanks & Regards,
Guruprasad.


> > > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.

>
> >
>
> > >
>
> >
>
> > > For more options, visit https://groups.google.com/d/optout.
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
>
> >
>
> > To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
> To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.

>
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages