
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 07:47 AM
Hello.
A have 3 MID server mid_docker_dev, mid_docker_test and mid_docker_prod for dev , test, prod instances relatively and some number of configured outbound REST messages.
I have to problems:
1)When i get prod instance cloned to dev. All outbound REST messages are configured to use mid_docker_prod.
2)When some new REST outbound message is created and captured in update set it capture pointing to mid_docker_dev. Now when update set is moved to test/prod i have to fix end-point.
So my question - is there a way to automatically fix MID endpont for outbound REST?
Good that would work for me is creating a fail-over cluster and add all 3 MID server to it so only 1 would be available per instance.
However i was not able to select MID servers cluster as an endpoint for outbound REST.
Thanks,
Igor
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 09:14 AM
You could create a scheduled job or post-clone cleanup script to keep them in sync.
I'm thinking create three system properties: default.mid_server.companyname, default.mid_server.companynametest, and default.mid_server.companynamedev, which would store the sys_ids of the respective MID Servers.
// Grab the instance name.
var instance = gs.getProperty('instance_name');
// Find the default MID Server based on the instance name.
var midServer = gs.getProperty('default.mid_server.' + instance);
// Write code to update the HTTP Methods.
var gr = new GlideRecord('sys_rest_message_fn');
gr.addNotNullQuery('use_mid_server');
gr.query();
while (gr.next()) {
gr.setValue('use_mid_server', midServer);
gr.update();
}
There may be a better way, but this is just an idea.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 09:14 AM
You could create a scheduled job or post-clone cleanup script to keep them in sync.
I'm thinking create three system properties: default.mid_server.companyname, default.mid_server.companynametest, and default.mid_server.companynamedev, which would store the sys_ids of the respective MID Servers.
// Grab the instance name.
var instance = gs.getProperty('instance_name');
// Find the default MID Server based on the instance name.
var midServer = gs.getProperty('default.mid_server.' + instance);
// Write code to update the HTTP Methods.
var gr = new GlideRecord('sys_rest_message_fn');
gr.addNotNullQuery('use_mid_server');
gr.query();
while (gr.next()) {
gr.setValue('use_mid_server', midServer);
gr.update();
}
There may be a better way, but this is just an idea.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 08:51 AM
Yes. This should solve the problem.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2017 11:32 AM
We use a function like the following to dynamically select a MID server for outbound REST messages
function getMidServer() {
var gr = new GlideRecord('ecc_agent');
gr.addEncodedQuery('statusSTARTSWITHup^validatedINtrue');
gr.setLimit(1);
gr.query();
if (gr.next()) {
return gr.name;
} else {
return null;
}
}
Then to assign the MID server to the REST message:
var mid = getMidServer();
if (!gs.nil(mid)) {
var restMessage = new sn_ws.RESTMessageV2('rest msg', 'get');
restMessage.setMIDServer(mid);
restMessage.execute();
} else {
gs.error('No MID server up and validated');
}
You can adjust the encoded query to take advantage of any naming convention for the MID servers that are eligible. For example, contains 'integration'.
Steve