Service-now.com can currently connect external systems such as Tibco through JMS in order to perform a bi-directional integration. In the early years of Servicenow, this integration required custom jar files on the Servicenow instance in the datacenter. As Servicenow has grown, it has become apparent that the company cannot give instances the ability to have custom jar files in their instance. With this change, the old JMS integration does not work for new customers.

I spent a few days trying to work out a proof of concept that enables bidirectional JMS data through a MID server.

The current prototype is rough, at best, but it outlines the possibility for modifying the current JMS plugin to work through a MID Server.

OpenJMS

Since we are going through a MID Server we will need to install our JMS libraries there. For this example, we will be using OpenJMS. You can get it at the OpenJMS download page.

Once you have the OpenJMS files downloaded and extracted, you will see files in the following directory layout.

  • bin – runs a local instance of a JMS Server on your computer
  • config – sets up the configuration for your test JMS Server
  • db – databaser files for the queue
  • docs – documentation for OpenJMS
  • examples – some code you can compile in order to send and retrieve messages from the test JMS Server.
  • lib – The jar files needed for a program to perform the JMS actions

Start the JMS Server

The first goal is to get the test JMS Server running so that you can send and receive messages from JMS queues. Follow the instructions from OpenJMS to get the server installed and running:
Installing OpenJMS

Once you have the OpenJMS server running, you can launch the admin console by running “bin/admin.sh” (or .bat if on windows).

When the Admin GUI comes up, you will need to click

Actions->Connections->Online

to connect to the server.

Once you do that you will see the queues associated with your test server (see the picture below).

Helpful Tools

OpenJMS comes with some helpful tools that allow you to populate or retrieve messages from the JMS Queues. I used these to help me with the messages that I was posting and retrieving in Servicenow.

In order to use these you will need to browse to the

examples/basic

directory and configure the jndi.properties file.

Once that is configured, you can use the tools in that same directory to add messages to one of the queues by issuing a command similar to this:

run.sh Sender queue1 14

This command will send 14 messages to JMS queue: “queue1”. If you look in the admin utility GUI you will see that it has 14 messages in the queue.

If you then run:

run.sh Receiver queue2 14

it will pop those 14 messages off the queue and print their messages to the console.

MID Server

Up until now, none of the other instructions are really required for getting a MID Server to talk to a JMS queue. Everything up until this point has just been to help us test the solution.

Since we will be doing some JMS operations that are not part of a standard Java SDK, we need to add the additional Jar files to the MID Server’s library. In order to do this, we need to browse to the MID Server’s directory and add the libraries manually.

Under the “agent” directory (as shown above) you will want to create a directory called “extlib”, if it doesn’t not already exist. This extlib directory is where you can place Jar files that are dynamically loaded by the MID Server on startup.

I placed all of the library Jar from OpenJMS “lib” directory into the MID Server’s extlib directory:

You may notice that I have also included Tibco’s JMS jar file in the mix for future testing of the prototype. However, it will not be covered here.

Sending JMS Messages
In order to send messages to a JMS queue, we will create a MID Server Script include that will be launched using a JavascriptProbe.

NAME: JMSMIDSender

SCRIPT:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
var JMSMIDSender = Class.create();

JMSMIDSender.prototype = {

    initialize : function() {
  try{
  this.StringUtil = Packages.com.glide.util.StringUtil;
  this.jmsUrl = probe.getParameter("glide.jms.url");
  this.jmsFactory = probe.getParameter("glide.jms.factory");
  this.jmsFactoryName = probe.getParameter("glide.jms.factory.name");
  this.jmsInputQueue = probe.getParameter("glide.jms.input.queue");
  this.jmsOutputQueue = probe.getParameter("glide.jms.output.queue");
  this.jmsUser = probe.getParameter("glide.jms.user");
  this.jmsPassword = probe.getParameter("glide.jms.password");
  this.fDebug = probe.getParameter("debug");
  this.logString = "EXECUTION LOG: ";
  this.jmsPayload = probe.getParameter("jmsPayload");
  this.log("jmsPayload: " + this.jmsPayload);

//Connection Variables
  this.connectionErrorMessage = "";
  this.fContext = null;
  this.fConnection = null;
  this.fSession = null;
  this.fDestination = null;

  this.currentQueue = this.jmsOutputQueue;


//Initialize the Connection

  var initResult = this.init();
  this.log("Init Result: " + initResult);
  if (!initResult) {
    message = "JMSECCSender cannot connect to JMS: " + this.connectionErrorMessage;
    this.log(message);
    probe.setParameter("JMS_ERROR_MESSAGE", message);
    this.term();
  } else {
    this.log("Sending Message Payload: " + this.jmsPayload);
    this.send(this.jmsPayload);
    this.term();
  }
  } catch (e){
    this.addLogToPayload();
  }
  this.addLogToPayload();
},
init : function() {
  var StringUtil = this.StringUtil;
  var InitialContext = Packages.javax.naming.InitialContext;
  var Destination = Packages.javax.jms.Destination;
  var Session = Packages.javax.jms.Session;
  var Context = Packages.javax.naming.Context;
  var initLog = "INIT LOG: "; //TODO: Delete me
  if (this.fDebug) {
    probe.setParameter("PROBE_DEBUG", "SET TO: " + this.fDebug);
    this.log("JMS Connection requested for queue: " + this.currentQueue);
    this.log("JMS URL: " + this.jmsUrl);
    this.log("JMS Factory: " + this.jmsFactory);
    this.log("JMS FactoryName: " + this.jmsFactoryName);
    this.log("JMS User: " + this.jmsUser);
    this.log("JMS Password: " + this.jmsPassword);
  }
  fErrorMessage = null;
  var answer = false;
  this.log("Checking JMS Properties");
  if (StringUtil.nil(this.jmsUrl) || StringUtil.nil(this.jmsFactory) || StringUtil.nil(this.jmsFactoryName)) {
    fErrorMessage = "JMS Properties have not been set";
    return answer;
  }
  this.log("Setting up JMS Connection Properties");
  var properties = new Packages.java.util.Hashtable();
  properties.put(Context.INITIAL_CONTEXT_FACTORY, this.jmsFactory);
  properties.put(Context.PROVIDER_URL, this.jmsUrl);
  if (!StringUtil.nil(this.jmsUser)) {
    properties.put(Context.SECURITY_PRINCIPAL, this.jmsUser);
    properties.put(Context.SECURITY_CREDENTIALS, this.jmsPassword);
    properties.put("java.naming.security.authentication", "simple");
  }

  try {
//  create the JNDI initial context.
    this.log("Creating the JNDI Initial Context");
    this.fContext = new InitialContext(properties);
    this.log("After the instanteation of the InitialContext class");
    if (this.fDebug) {
      this.log("JMS Connection Context Created");
    }
//  look up the Destination
    this.log("Looking up the destination: " + this.currentQueue);
    this.fDestination = this.fContext.lookup(this.currentQueue);

    if (this.fDebug) {
      this.log("JMS Connection Destination lookup OK");
    }
//  look up the ConnectionFactory
    this.log("Looking up the ConnectionFactory: " + this.jmsFactoryName);
    var factory = this.fContext.lookup(this.jmsFactoryName);

    if (this.fDebug) {
      this.log("JMS Connection connection factory lookup OK");
    }
//  create the connection
    this.log("Creating the Connection: " + this.jmsUser + "/" + this.jmsPassword);
    if (StringUtil.nil(this.jmsUser)){
      this.log("Creating GENERIC connection");
      this.fConnection = factory.createConnection();
    }
    else{
      this.fConnection = factory.createConnection(this.jmsUser, this.jmsPassword);
      this.log("Creating a username/password connection: " + this.jmsUser + "/" + this.jmsPassword);
    }
    if (this.fDebug) {
      this.log("JMS Connection connection created");
    }
//  create the session
    this.log("Creating the session: " + this.fConnection);
    this.fSession = this.fConnection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    if (this.fDebug) {
      this.log("JMS Connection session created");
    }
    answer = true;
  } catch (e) {
    if (this.fDebug){
      this.log("Exception Message: " + e.message);
      this.log("Exception Object: " + e);
      this.log("Exception Name: " + e.name);
    }
    fErrorMessage = e.message;
  }
  this.connectionErrorMessage = fErrorMessage;
  return answer;

},
send : function(text){
//create the sender
  try {
    var mp = this.fSession.createProducer(this.fDestination);

//  start the connection, to enable message sends
    this.fConnection.start();

    var message = this.fSession.createTextMessage();
    message.setText(text);
    mp.send(message);
    this.log("Sent: " + message.getText());

  } catch (e) {
    this.log("EXCEPTION:::JMS Error producing data", e);
  }
},
term : function() {
  if (this.fContext != null) {
    try {
      this.log("Closing the JMS Context");
      this.fContext.close();
    } catch (e) {
      this.log("ERROR Closing JMS Context: " + e.message);
    }
  }

//close the connection
  if (this.fConnection != null) {
    try {
      this.log("Closing the JMS Connection");
      this.fConnection.close();
    } catch (e) {
      this.log("ERROR Closing JMS Connection: " + e.message);
    }
  }
},
log : function( logString ){
  this.logString += "\n" + logString;
  ms.log(logString);
  //probe.setParameter("LOG", this.logString);
},
addLogToPayload : function () {
  probe.createCDATAElement("LOG", this.logString);
}
};

The code is now in place. In order to send a message to a JMS queue, we need to create an ECC Record that tells us to do this and with what parameters.

The following is a sample ECC Record that could be created that would launch a SEND action:

The ECC Queue Record Payload:

1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="UTF-8"?>
<parameters>
  <parameter name="script" value="var req = new JMSMIDSender();"></parameter>
  <parameter name="glide.jms.url" value="tcp://192.168.1.183:3035/"></parameter>
  <parameter name="glide.jms.factory" value="org.exolab.jms.jndi.InitialContextFactory"></parameter>
  <parameter name="glide.jms.factory.name" value="ConnectionFactory"></parameter>
  <parameter name="glide.jms.output.queue" value="queue1"></parameter>
  <parameter name="glide.jms.user" value="admin"></parameter>
  <parameter name="glide.jms.password" value="openjms"></parameter>
  <parameter name="debug" value="true"></parameter>
  <parameter name="jmsPayload" value="My payload 1 2 3"></parameter>
</parameters>

The parameters that were used in the ECC Queue Record Payload are as follow:

  • script – this is the MID Server Script Include that we will be launching
  • glide.jms.url – this is the URL to the JMS Server (including port)
  • glide.jms.factory – this is the Java class factory that will be used to transport the JMS message. The factory listed here is the one for OpenJMS. In order to switch to Tibco, or some other JMS server, you would change this string to the Java package string used by the server.
  • glide.jms.factory.name – The factory type used to connect to the JMS server
  • glide.jms.output.queue – the name of the queue that we will be sending messages to
  • glide.jms.user – the username for the jms server
  • glide.jms.password – the password for the jms server
  • debug – set this to true if you want logging messages sent back to the ECC Queue with the response
  • jmsPayload – the message that we are sending

Some notes on the current Payload XML:

In real life, the glide.jms.* settings would be automatically generated based off of the settings in the JMS Properties page of the original JMS Integration. For this prototype, we enter them manually.

Please note, for this prototype, we are sending clear text user and passwords. In an official version, I would hash the credentials together and encrypt them.

Another caveat to this solution is that if the jmsPayload contains double-quote characters(“) you will have some issues. You will need to escape the double-quotes in the message (eg: the HTML escape code for a double quote is: &#34;).

Now that the Sending record is on the ECC Queue, we can check the OpenJMS admin utility to ensure that it arrived in Queue2 as expected:

We can pop it off the queue using OpenJMS’s command line example program:

Receiving JMS Queue Messages
Now that we can send messages to a JMS queue, and we were able to verify it with OpenJMS tools, lets talk about receiving messages from a JMS Queue.

For this, I created a MID Server Script Include called, “MIDJMSReceiver”. Here is the script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
var JMSMIDReceiver = Class.create();

JMSMIDReceiver.prototype = {

  initialize : function() {
    this.StringUtil = Packages.com.glide.util.StringUtil;
    this.jmsUrl = probe.getParameter("glide.jms.url");
    this.jmsFactory = probe.getParameter("glide.jms.factory");
    this.jmsFactoryName = probe.getParameter("glide.jms.factory.name");
    this.jmsInputQueue = probe.getParameter("glide.jms.input.queue");
    this.jmsUser = probe.getParameter("glide.jms.user");
    this.jmsPassword = probe.getParameter("glide.jms.password");
    this.fDebug = probe.getParameter("debug");
    this.logString = "EXECUTION LOG: ";
    this.returnPayload = new Array();

    // Connection Variables
  this.connectionErrorMessage = "";
  this.fContext = null;
  this.fConnection = null;
  this.fSession = null;
  this.fDestination = null;

  this.currentQueue = this.jmsInputQueue;

  //
  // Initialize the Connection
  //
  try{
  var initResult = this.init();
  this.log("Init Result: " + initResult);
  if (!initResult) {
    message = "JMSECCReceiver cannot connect to JMS: "
        + this.connectionErrorMessage;
    this.log(message);
    probe.setParameter("JMS_ERROR_MESSAGE", message);
    this.term();
  } else {
    this.receive();
    this.term();
  }
  this.addLogToPayload();
  } catch (e){
    this.addLogToPayload();
  }
},
init : function() {
  var StringUtil = this.StringUtil;
  var InitialContext = Packages.javax.naming.InitialContext;
  var Destination = Packages.javax.jms.Destination;
  var Session = Packages.javax.jms.Session;
  var Context = Packages.javax.naming.Context;
  var initLog = "INIT LOG: "; // TODO: Delete me
  if (this.fDebug) {
    probe.setParameter("PROBE_DEBUG", "SET TO: " + this.fDebug);
    this.log("JMS Connection requested for queue: " + this.currentQueue);
    this.log("JMS URL: " + this.jmsUrl);
    this.log("JMS Factory: " + this.jmsFactory);
    this.log("JMS FactoryName: " + this.jmsFactoryName);
    this.log("JMS User: " + this.jmsUser);
    this.log("JMS Password: " + this.jmsPassword);
  }
  fErrorMessage = null;
  var answer = false;
  this.log("Checking JMS Properties");
  if (StringUtil.nil(this.jmsUrl) || StringUtil.nil(this.jmsFactory)
      || StringUtil.nil(this.jmsFactoryName)) {
    fErrorMessage = "JMS Properties have not been set";
    return answer;
  }
  this.log("Setting up JMS Connection Properties");
  var properties = new Packages.java.util.Hashtable();
  properties.put(Context.INITIAL_CONTEXT_FACTORY, this.jmsFactory);
  properties.put(Context.PROVIDER_URL, this.jmsUrl);
  if (!StringUtil.nil(this.jmsUser)) {
    properties.put(Context.SECURITY_PRINCIPAL, this.jmsUser);
    properties.put(Context.SECURITY_CREDENTIALS, this.jmsPassword);
    properties.put("java.naming.security.authentication", "simple");
  }

  try {
    // create the JNDI initial context.
    this.log("Creating the JNDI Initial Context");
    this.fContext = new InitialContext(properties);
    this.log("After the instanteation of the InitialContext class");
    if (this.fDebug) {
      this.log("JMS Connection Context Created");
    }
    // look up the Destination
    this.log("Looking up the destination: " + this.currentQueue);
    this.fDestination = this.fContext.lookup(this.currentQueue);

    if (this.fDebug) {
      this.log("JMS Connection Destination lookup OK");
    }
    // look up the ConnectionFactory
    this.log("Looking up the ConnectionFactory: " + this.jmsFactoryName);
    var factory = this.fContext.lookup(this.jmsFactoryName);

    if (this.fDebug) {
      this.log("JMS Connection connection factory lookup OK");
    }
    // create the connection
    this.log("Creating the Connection: " + this.jmsUser + "/"
        + this.jmsPassword);
    if (StringUtil.nil(this.jmsUser)) {
      this.log("Creating GENERIC connection");
      this.fConnection = factory.createConnection();
    } else {
      this.fConnection = factory.createConnection(this.jmsUser,
          this.jmsPassword);
      this.log("Creating a username/password connection: " + this.jmsUser + "/"
          + this.jmsPassword);
    }
    if (this.fDebug) {
      this.log("JMS Connection connection created");
    }
    // create the session
    this.log("Creating the session: " + this.fConnection);
    this.fSession = this.fConnection.createSession(false,
        Session.AUTO_ACKNOWLEDGE);
    if (this.fDebug) {
      this.log("JMS Connection session created");
    }
    answer = true;
  } catch (e) {
    if (this.fDebug) {
      this.log("Exception Message: " + e.message);
      this.log("Exception Object: " + e);
      this.log("Exception Name: " + e.name);
    }
    fErrorMessage = e.message;
  }
  this.connectionErrorMessage = fErrorMessage;
  return answer;

},
receive : function(text) {
  // create the receiver
  var fReceiver = Packages.javax.jms.MessageConsumer;
  try {
    this.log("Creating a Session Consumer for Queue: " + this.fDestination);
    var receiver = this.fSession.createConsumer(this.fDestination);
    this.log("Got a Session Consumer: " + receiver);

    // start the connection, to enable message receives
    this.log("Starting the connection...");
    this.fConnection.start();
    this.log("Connection Started");

    var count = 1;
    count = this.getQueueSize();
    this.log("Number of messages we will retrieve from queue: " + count);
    for (var i = 0; i < count; ++i) {
      this.log("Receiving Message ("+i+")...");
      var message = receiver.receive();
      this.log("Received message: " + message.getText());
      this.log("Message Type: " + typeof(message));
      this.addToReturnPayload(message.getText());
    }    
    this.setReturnPayload();
  } catch (e) {
    this.log("EXCEPTION:::JMS Error getting data", e);
    this.term();
  }
},
term : function() {
  if (this.fContext != null) {
    try {
      this.log("Closing the JMS Context");
      this.fContext.close();
    } catch (e) {
      this.log("ERROR Closing JMS Context: " + e.message);
    }
  }

  // close the connection
  if (this.fConnection != null) {
    try {
      this.log("Closing the JMS Connection");
      this.fConnection.close();
    } catch (e) {
      this.log("ERROR Closing JMS Connection: " + e.message);
    }
  }
},
getQueueSize : function() {
  var Context = Packages.javax.naming.Context;
  var StringUtil = this.StringUtil;

  try {
    this.log("Setting up JMS Connection Properties for Queue");
    var properties = new Packages.java.util.Hashtable();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, this.jmsFactory);
    properties.put(Context.PROVIDER_URL, this.jmsUrl);
    if (!StringUtil.nil(this.jmsUser)) {
      properties.put(Context.SECURITY_PRINCIPAL, this.jmsUser);
      properties.put(Context.SECURITY_CREDENTIALS, this.jmsPassword);
      properties.put("java.naming.security.authentication", "simple");
    }

    var ctx = new Packages.javax.naming.InitialContext(properties);
    var Session = Packages.javax.jms.Session;

    var queue = ctx.lookup(this.currentQueue);
    var connFactory = ctx.lookup(this.jmsFactoryName);
    var queueConn = connFactory.createQueueConnection();
    var queueSession = queueConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    var queueBrowser = queueSession.createBrowser(queue);
    queueConn.start();
    count = Packages.java.util.Collections.list(queueBrowser.getEnumeration()).size();
    this.log("Queue Size: " + count);
    queueConn.close();
    return count;  
  }catch(e){
    this.log("GetQueueSize EXCEPTION: ", e);
    this.log(e.message);
    queueConn.close();
    return -1;
  }
},

addToReturnPayload : function(message){
  var xml = "&"+"lt;message&"+"gt;" + message + "&"+"lt;/message&"+"gt;";
  this.returnPayload.push(xml);
},
setReturnPayload : function(){
  var returnXml = "&"+"lt;messages&"+"gt;";
  for(var i in this.returnPayload){
    returnXml += this.returnPayload[i];
  }
  returnXml += "&"+"lt;/messages&"+"gt;";
  probe.createCDATAElement("returnPayload", returnXml);
},
log : function(logString) {
  this.logString += "\n" + logString;
  ms.log(logString);
},
addLogToPayload : function () {
  probe.createCDATAElement("LOG", this.logString);
}

};

Now, to trigger the receive to take place, we would normally have a scheduled job that would write the following type of ECC Queue Record…for now, we just place it on the ECC Queue manually:

1
2
3
4
5
6
7
8
9
10
<parameters>
  <parameter name="script" value="var req = new JMSMIDReceiver();"></parameter>
  <parameter name="glide.jms.url" value="tcp://192.168.1.183:3035/"></parameter>
  <parameter name="glide.jms.factory" value="org.exolab.jms.jndi.InitialContextFactory"></parameter>
  <parameter name="glide.jms.factory.name" value="ConnectionFactory"></parameter>
  <parameter name="glide.jms.input.queue" value="queue2"></parameter>
  <parameter name="glide.jms.user" value="admin"></parameter>
  <parameter name="glide.jms.password" value="openjms"></parameter>
  <parameter name="debug" value="true"></parameter>
</parameters>

This XML is very similar to the Sending XML. The main difference is that we specify the “input” queue instead of the “output” queue. We also don’t need a jmsPayload parameter because we are receiving, not sending out a payload.

Before we save this on the ECC queue, we should populate the queue with one or more messages. I will do it using the OpenJMS utility:

Now that the queue is populated, create the ECC Queue Entry described above.

After a few seconds, you should get an Input Record in the ECC Queue for the result.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="UTF-8"?>
<results probe_time="1781">
<returnPayload><![CDATA[&lt;messages&gt;&lt;message&gt;Message 1&lt;/message&gt;&lt;message&gt;Message 2&lt;/message&gt;&lt;message&gt;Message 3&lt;/message&gt;&lt;message&gt;Message 4&lt;/message&gt;&lt;message&gt;Message 5&lt;/message&gt;&lt;message&gt;Message 6&lt;/message&gt;&lt;message&gt;Message 7&lt;/message&gt;&lt;message&gt;Message 8&lt;/message&gt;&lt;message&gt;Message 9&lt;/message&gt;&lt;message&gt;Message 10&lt;/message&gt;&lt;/messages&gt;]]></returnPayload>
<LOG><![CDATA[EXECUTION LOG:
JMS Connection requested for queue: queue2
JMS URL: tcp://192.168.1.183:3035/
JMS Factory: org.exolab.jms.jndi.InitialContextFactory
JMS FactoryName: ConnectionFactory
JMS User: admin
JMS Password: openjms
Checking JMS Properties
Setting up JMS Connection Properties
Creating the JNDI Initial Context
After the instanteation of the InitialContext class
JMS Connection Context Created
Looking up the destination: queue2
JMS Connection Destination lookup OK
Looking up the ConnectionFactory: ConnectionFactory
JMS Connection connection factory lookup OK
Creating the Connection: admin/openjms
Creating a username/password connection: admin/openjms
JMS Connection connection created
Creating the session: org.exolab.jms.client.JmsConnection@ae2d66
JMS Connection session created
Init Result: true
Creating a Session Consumer for Queue: queue2-true
Got a Session Consumer: org.exolab.jms.client.JmsMessageConsumer@ee644c
Starting the connection...
Connection Started
Setting up JMS Connection Properties for Queue
Queue Size: 10
Number of messages we will retrieve from queue: 10
Receiving Message (0)...
Received message: Message 1
Message Type: object
Receiving Message (1)...
Received message: Message 2
Message Type: object
Receiving Message (2)...
Received message: Message 3
Message Type: object
Receiving Message (3)...
Received message: Message 4
Message Type: object
Receiving Message (4)...
Received message: Message 5
Message Type: object
Receiving Message (5)...
Received message: Message 6
Message Type: object
Receiving Message (6)...
Received message: Message 7
Message Type: object
Receiving Message (7)...
Received message: Message 8
Message Type: object
Receiving Message (8)...
Received message: Message 9
Message Type: object
Receiving Message (9)...
Received message: Message 10
Message Type: object
Closing the JMS Context
Closing the JMS Connection]]></LOG>
<result><output>org.mozilla.javascript.Undefined@c87621</output></result>
<parameters>
    <parameter name="queue" value="output"/>
    <parameter name="state" value="ready"/>
    <parameter name="debug" value="true"/>
    <parameter name="ecc_queue" value="34a8c44ec0a801b77af60bbde9913b80"/>
    <parameter name="glide.jms.user" value="admin"/>
    <parameter name="table_name" value="ecc_queue"/>
    <parameter name="name" value="JMSMIDReceiver"/>
    <parameter name="glide.jms.factory" value="org.exolab.jms.jndi.InitialContextFactory"/>
    <parameter name="topic" value="JavascriptProbe"/>
    <parameter name="PROBE_DEBUG" value="SET TO: true"/>
    <parameter name="glide.jms.input.queue" value="queue2"/>
    <parameter name="sys_id" value="34a8c44ec0a801b77af60bbde9913b80"/>
    <parameter name="script" value="var req = new JMSMIDReceiver();"/>
    <parameter name="glide.jms.password" value="openjms"/>
    <parameter name="agent" value="mid.server.RadRoadTrips.com"/>
    <parameter name="sequence" value="12e34a8c44e0000001"/>
    <parameter name="glide.jms.factory.name" value="ConnectionFactory"/>
    <parameter name="glide.jms.url" value="tcp://192.168.1.183:3035/"/>
</parameters></results>

We get a lot of debugging information in the result because we had debugging set to true in our ECC Queue Receiver Payload.

The important thing to note from this response is the “returnPayload” element. This contains and escaped XML string. We would probably have a business rule set on the ECC Queue so that when we get JMS responses like this, we would unescape the return Payload and we would be able to convert the string to XML and work on processing the data into other ECC Queue records that the existing JMS integration will recognize and react on.

If you read through this entire article, congratulations…go get a doughnut on me :-).

I hope to move this into the existing JMS integration in the near future.