Skip to content
Browse files

Working on getting message listener to work.

  • Loading branch information...
1 parent c94a454 commit cca7694a9c3ceb35aa44a71e1c577bfc65e47502 ckaminsk committed Jun 20, 2012
Showing with 34 additions and 6 deletions.
  1. +8 −1 src/main/java/com/darthcoder/JMSTestServlet/MainServlet.java
  2. +26 −5 src/main/webapp/index.jsp
View
9 src/main/java/com/darthcoder/JMSTestServlet/MainServlet.java
@@ -11,6 +11,8 @@
@SuppressWarnings("serial")
public class MainServlet extends HttpServlet {
+ boolean stopFlag = false;
+
private String getJMSNames() {
StringBuilder retVal = new StringBuilder();
try {
@@ -38,11 +40,16 @@ private String getJMSNames() {
// TODO: Add authentication capabilities.
void runMessageListener(HttpServletRequest request, HttpServletResponse response) {
+ System.out.println("Starting runMessageListener");
+
String connFactoryName = request.getParameter("ConnFactoryName");
String replyToName = request.getParameter("ReplyToName");
String replyToType = request.getParameter("ReplyToType");
InitialContext ctx = null;
+ assert(connFactoryName != null) : "ConnectionFactoryName is null";
+ assert(replyToName != null) : "ReplyTo destination is null!";
+
try {
ctx = new InitialContext();
ConnectionFactory cfactory = (ConnectionFactory) ctx.lookup(connFactoryName);
@@ -55,7 +62,7 @@ void runMessageListener(HttpServletRequest request, HttpServletResponse response
MessageConsumer consumer = msgSession.createConsumer(queue);
conn.start();
- while ( 1 ) {
+ while ( !stopFlag ) {
// TODO: wait on exit flag
// TODO: make this a user-specifiable parameter.
Message msg = consumer.receive(1000);
View
31 src/main/webapp/index.jsp
@@ -6,20 +6,41 @@
<script type="text/javascript">
$(document).ready(function() {
$.get('./jmsops/?action=jmsdata', function(data) {
- alert("returned jmsdata equals: [" + data + "]");
+ //alert("JMSDATA: " + data);
+ var strs = data.split(";");
+ for ( idx in strs ) {
+ var value = strs[idx];
+ //alert("Using value: " + value);
+ $('#CFactory').append($('<option>', { value : value }).text(value));
+ $('#Source').append($('<option>', { value : value }).text(value));
+ $('#ReplyTo').append($('<option>', { value : value }).text(value));
+ }
+
});
});
+
+function startListener() {
+ var argumentStr = $('#CFactory').val() + '&' + $('#ReplyTo').val();
+ var urlString = "./jmsops/?action=jmsmessages&" + argumentStr;
+ alert("Using URLString " + urlString);
+ $.ajax({ url: urlString, success: function(data){
+ alert("we have data" + data);
+ //Update your dashboard gauge
+ //salesGauge.setValue(data.value);
+
+ }, dataType: "json", complete: startListener, timeout: 30000 });
+}
</script>
</head>
<body>
-Connection Factory: <select name="CFactory"> <option value=""/> </select> Custom: <input type="text" name="CFactoryCustom"/> <br/>
-Source: <select name="Source"> <option value="" /> </select> Custom: <input type="text" name="SourceCustom"/> <br/>
-ReplyTo: <select name="ReplyTo"> <option value=""/> </select> Custom: <input type="text" name="ReplyToCustom"/> <br/>
+Connection Factory: <select id="CFactory" name="CFactory"> <option value=""/> </select> Custom: <input type="text" name="CFactoryCustom"/> <br/>
+Source: <select id="Source" name="Source"> <option value="" /> </select> Custom: <input type="text" name="SourceCustom"/> <br/>
+ReplyTo: <select id="ReplyTo" name="ReplyTo"> <option value=""/> </select> Custom: <input type="text" name="ReplyToCustom"/> <br/>
<input type="radio" name="ConnectionType" value="Queue">Queue</input>
<input type="radio" name="ConnectionType" value="Topic">Topic</input>
-<input type="submit" name="submitbutton" value="Start Listening"/>
+<input type="submit" name="submitbutton" value="Start Listening" onClick='startListener()'/>
<br/>
</body>

0 comments on commit cca7694

Please sign in to comment.
Something went wrong with that request. Please try again.