[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-18 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/jmeter/pull/325


---


[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150327668
  
--- Diff: 
src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java ---
@@ -142,48 +173,244 @@ public SampleResult sample(Entry entry) {
 res.sampleStart();
 
 try {
-TextMessage msg = createMessage();
-if (isOneway()) {
-int deliveryMode = isNonPersistent() ? 
-
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
-producer.send(msg, deliveryMode, 
Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-res.setResponseOK();
-res.setResponseData("Oneway request has no response data", 
null);
+LOGGER.debug("Point-to-point mode: " + 
getCommunicationstyle());
+if (isBrowse()) {
+handleBrowse(res);
+} else if (isClearQueue()) {
+handleClearQueue(res);
+} else if (isOneway()) {
+handleOneWay(res);
+} else if (isRead()) {
+handleRead(context, res);
 } else {
-if (!useTemporyQueue()) {
-msg.setJMSReplyTo(receiveQueue);
-}
-Message replyMsg = executor.sendAndReceive(msg,
-isNonPersistent() ? DeliveryMode.NON_PERSISTENT : 
DeliveryMode.PERSISTENT, 
-Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-if (replyMsg == null) {
-res.setResponseMessage("No reply message received");
-} else {
-if (replyMsg instanceof TextMessage) {
-res.setResponseData(((TextMessage) 
replyMsg).getText(), null);
-} else {
-res.setResponseData(replyMsg.toString(), null);
-}
-
res.setResponseHeaders(Utils.messageProperties(replyMsg));
-res.setResponseOK();
-}
+handleRequestResponse(res);
 }
 } catch (Exception e) {
 LOGGER.warn(e.getLocalizedMessage(), e);
-if (thrown != null){
+if (thrown != null) {
 res.setResponseMessage(thrown.toString());
-} else {
+} else {
 res.setResponseMessage(e.getLocalizedMessage());
 }
 }
 res.sampleEnd();
 return res;
 }
 
+private void handleBrowse(SampleResult res) throws JMSException {
+LOGGER.debug("isBrowseOnly");
+StringBuffer sb = new StringBuffer("");
--- End diff --

StringBuilder would be better here, and wherever StringBuffer is used


---


[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150327166
  
--- Diff: docs/usermanual/component_reference.html ---
@@ -4276,10 +4289,32 @@ 
 temporary queues will be used for the communication between the 
requestor and the server.
 This is very different from the fixed reply queue. With temporary 
queues the sending thread will block until the reply message has been received.
 With Request Response mode, you need to have 
a Server that listens to messages sent to Request Queue and sends replies to 
-queue referenced by message.getJMSReplyTo().
-
+queue referenced by message.getJMSReplyTo().
+
+
+
+Read
+
+ will read a message from an outgoing queue which has no listeners 
attached. This can be convenient for testing purposes.
+ This method can be used if you need to handle queues without a 
binding file (in case the jmeter-jms-skip-jndi library is used),
+ which only works with the JMS Point-to-Point sampler.
+ In case binding files are used, one can also use the JMS Subscriber 
Sampler for reading from a queue.
+
+
+
+Browse
+
+ will determine the current queue depth without removing messages from 
the queue, returning the number of messages on the queue. 
--- End diff --

Would it be possible to provide screenshots as it makes documentation much 
clearer


---


[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150328441
  
--- Diff: 
src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java ---
@@ -142,48 +173,244 @@ public SampleResult sample(Entry entry) {
 res.sampleStart();
 
 try {
-TextMessage msg = createMessage();
-if (isOneway()) {
-int deliveryMode = isNonPersistent() ? 
-
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
-producer.send(msg, deliveryMode, 
Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-res.setResponseOK();
-res.setResponseData("Oneway request has no response data", 
null);
+LOGGER.debug("Point-to-point mode: " + 
getCommunicationstyle());
+if (isBrowse()) {
+handleBrowse(res);
+} else if (isClearQueue()) {
+handleClearQueue(res);
+} else if (isOneway()) {
+handleOneWay(res);
+} else if (isRead()) {
+handleRead(context, res);
 } else {
-if (!useTemporyQueue()) {
-msg.setJMSReplyTo(receiveQueue);
-}
-Message replyMsg = executor.sendAndReceive(msg,
-isNonPersistent() ? DeliveryMode.NON_PERSISTENT : 
DeliveryMode.PERSISTENT, 
-Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-if (replyMsg == null) {
-res.setResponseMessage("No reply message received");
-} else {
-if (replyMsg instanceof TextMessage) {
-res.setResponseData(((TextMessage) 
replyMsg).getText(), null);
-} else {
-res.setResponseData(replyMsg.toString(), null);
-}
-
res.setResponseHeaders(Utils.messageProperties(replyMsg));
-res.setResponseOK();
-}
+handleRequestResponse(res);
 }
 } catch (Exception e) {
 LOGGER.warn(e.getLocalizedMessage(), e);
-if (thrown != null){
+if (thrown != null) {
 res.setResponseMessage(thrown.toString());
-} else {
+} else {
 res.setResponseMessage(e.getLocalizedMessage());
 }
 }
 res.sampleEnd();
 return res;
 }
 
+private void handleBrowse(SampleResult res) throws JMSException {
+LOGGER.debug("isBrowseOnly");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Browse message on Send Queue " + 
sendQueue.getQueueName());
+sb.append(browseQueueDetails(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleClearQueue(SampleResult res) throws JMSException {
+LOGGER.debug("isClearQueue");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Clear messages on Send Queue " + 
sendQueue.getQueueName());
+sb.append(clearQueue(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleOneWay(SampleResult res) throws JMSException {
+LOGGER.debug("isOneWay");
+TextMessage msg = createMessage();
+int deliveryMode = isNonPersistent() ? DeliveryMode.NON_PERSISTENT 
: DeliveryMode.PERSISTENT;
+producer.send(msg, deliveryMode, Integer.parseInt(getPriority()), 
Long.parseLong(getExpiration()));
+res.setRequestHeaders(Utils.messageProperties(msg));
+res.setResponseOK();
+res.setResponseData("Oneway request has no response data", null);
+}
+
+private void handleRead(JMeterContext context, SampleResult res) {
+LOGGER.debug("isRead");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+Sampler sampler = context.getPreviousSampler();
+SampleResult sr = context.getPreviousResult();
+String jmsSelector = getJMSSelector();
+if (jmsSelector.equals("_PREV_SAMPLER_")) {
+if (sampler instanceof JMSSampler) {
+

[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150328248
  
--- Diff: 
src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java ---
@@ -142,48 +173,244 @@ public SampleResult sample(Entry entry) {
 res.sampleStart();
 
 try {
-TextMessage msg = createMessage();
-if (isOneway()) {
-int deliveryMode = isNonPersistent() ? 
-
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
-producer.send(msg, deliveryMode, 
Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-res.setResponseOK();
-res.setResponseData("Oneway request has no response data", 
null);
+LOGGER.debug("Point-to-point mode: " + 
getCommunicationstyle());
+if (isBrowse()) {
+handleBrowse(res);
+} else if (isClearQueue()) {
+handleClearQueue(res);
+} else if (isOneway()) {
+handleOneWay(res);
+} else if (isRead()) {
+handleRead(context, res);
 } else {
-if (!useTemporyQueue()) {
-msg.setJMSReplyTo(receiveQueue);
-}
-Message replyMsg = executor.sendAndReceive(msg,
-isNonPersistent() ? DeliveryMode.NON_PERSISTENT : 
DeliveryMode.PERSISTENT, 
-Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-if (replyMsg == null) {
-res.setResponseMessage("No reply message received");
-} else {
-if (replyMsg instanceof TextMessage) {
-res.setResponseData(((TextMessage) 
replyMsg).getText(), null);
-} else {
-res.setResponseData(replyMsg.toString(), null);
-}
-
res.setResponseHeaders(Utils.messageProperties(replyMsg));
-res.setResponseOK();
-}
+handleRequestResponse(res);
 }
 } catch (Exception e) {
 LOGGER.warn(e.getLocalizedMessage(), e);
-if (thrown != null){
+if (thrown != null) {
 res.setResponseMessage(thrown.toString());
-} else {
+} else {
 res.setResponseMessage(e.getLocalizedMessage());
 }
 }
 res.sampleEnd();
 return res;
 }
 
+private void handleBrowse(SampleResult res) throws JMSException {
+LOGGER.debug("isBrowseOnly");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Browse message on Send Queue " + 
sendQueue.getQueueName());
+sb.append(browseQueueDetails(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleClearQueue(SampleResult res) throws JMSException {
+LOGGER.debug("isClearQueue");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Clear messages on Send Queue " + 
sendQueue.getQueueName());
+sb.append(clearQueue(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleOneWay(SampleResult res) throws JMSException {
+LOGGER.debug("isOneWay");
+TextMessage msg = createMessage();
+int deliveryMode = isNonPersistent() ? DeliveryMode.NON_PERSISTENT 
: DeliveryMode.PERSISTENT;
+producer.send(msg, deliveryMode, Integer.parseInt(getPriority()), 
Long.parseLong(getExpiration()));
+res.setRequestHeaders(Utils.messageProperties(msg));
+res.setResponseOK();
+res.setResponseData("Oneway request has no response data", null);
+}
+
+private void handleRead(JMeterContext context, SampleResult res) {
+LOGGER.debug("isRead");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+Sampler sampler = context.getPreviousSampler();
+SampleResult sr = context.getPreviousResult();
+String jmsSelector = getJMSSelector();
+if (jmsSelector.equals("_PREV_SAMPLER_")) {
+if (sampler instanceof JMSSampler) {
+

[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150328288
  
--- Diff: 
src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java ---
@@ -142,48 +173,244 @@ public SampleResult sample(Entry entry) {
 res.sampleStart();
 
 try {
-TextMessage msg = createMessage();
-if (isOneway()) {
-int deliveryMode = isNonPersistent() ? 
-
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
-producer.send(msg, deliveryMode, 
Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-res.setResponseOK();
-res.setResponseData("Oneway request has no response data", 
null);
+LOGGER.debug("Point-to-point mode: " + 
getCommunicationstyle());
+if (isBrowse()) {
+handleBrowse(res);
+} else if (isClearQueue()) {
+handleClearQueue(res);
+} else if (isOneway()) {
+handleOneWay(res);
+} else if (isRead()) {
+handleRead(context, res);
 } else {
-if (!useTemporyQueue()) {
-msg.setJMSReplyTo(receiveQueue);
-}
-Message replyMsg = executor.sendAndReceive(msg,
-isNonPersistent() ? DeliveryMode.NON_PERSISTENT : 
DeliveryMode.PERSISTENT, 
-Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-if (replyMsg == null) {
-res.setResponseMessage("No reply message received");
-} else {
-if (replyMsg instanceof TextMessage) {
-res.setResponseData(((TextMessage) 
replyMsg).getText(), null);
-} else {
-res.setResponseData(replyMsg.toString(), null);
-}
-
res.setResponseHeaders(Utils.messageProperties(replyMsg));
-res.setResponseOK();
-}
+handleRequestResponse(res);
 }
 } catch (Exception e) {
 LOGGER.warn(e.getLocalizedMessage(), e);
-if (thrown != null){
+if (thrown != null) {
 res.setResponseMessage(thrown.toString());
-} else {
+} else {
 res.setResponseMessage(e.getLocalizedMessage());
 }
 }
 res.sampleEnd();
 return res;
 }
 
+private void handleBrowse(SampleResult res) throws JMSException {
+LOGGER.debug("isBrowseOnly");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Browse message on Send Queue " + 
sendQueue.getQueueName());
+sb.append(browseQueueDetails(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleClearQueue(SampleResult res) throws JMSException {
+LOGGER.debug("isClearQueue");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Clear messages on Send Queue " + 
sendQueue.getQueueName());
+sb.append(clearQueue(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleOneWay(SampleResult res) throws JMSException {
+LOGGER.debug("isOneWay");
+TextMessage msg = createMessage();
+int deliveryMode = isNonPersistent() ? DeliveryMode.NON_PERSISTENT 
: DeliveryMode.PERSISTENT;
+producer.send(msg, deliveryMode, Integer.parseInt(getPriority()), 
Long.parseLong(getExpiration()));
+res.setRequestHeaders(Utils.messageProperties(msg));
+res.setResponseOK();
+res.setResponseData("Oneway request has no response data", null);
+}
+
+private void handleRead(JMeterContext context, SampleResult res) {
+LOGGER.debug("isRead");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+Sampler sampler = context.getPreviousSampler();
+SampleResult sr = context.getPreviousResult();
+String jmsSelector = getJMSSelector();
+if (jmsSelector.equals("_PREV_SAMPLER_")) {
+if (sampler instanceof JMSSampler) {
+

[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150328999
  
--- Diff: 
src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java ---
@@ -142,48 +173,244 @@ public SampleResult sample(Entry entry) {
 res.sampleStart();
 
 try {
-TextMessage msg = createMessage();
-if (isOneway()) {
-int deliveryMode = isNonPersistent() ? 
-
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
-producer.send(msg, deliveryMode, 
Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-res.setResponseOK();
-res.setResponseData("Oneway request has no response data", 
null);
+LOGGER.debug("Point-to-point mode: " + 
getCommunicationstyle());
+if (isBrowse()) {
+handleBrowse(res);
+} else if (isClearQueue()) {
+handleClearQueue(res);
+} else if (isOneway()) {
+handleOneWay(res);
+} else if (isRead()) {
+handleRead(context, res);
 } else {
-if (!useTemporyQueue()) {
-msg.setJMSReplyTo(receiveQueue);
-}
-Message replyMsg = executor.sendAndReceive(msg,
-isNonPersistent() ? DeliveryMode.NON_PERSISTENT : 
DeliveryMode.PERSISTENT, 
-Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-if (replyMsg == null) {
-res.setResponseMessage("No reply message received");
-} else {
-if (replyMsg instanceof TextMessage) {
-res.setResponseData(((TextMessage) 
replyMsg).getText(), null);
-} else {
-res.setResponseData(replyMsg.toString(), null);
-}
-
res.setResponseHeaders(Utils.messageProperties(replyMsg));
-res.setResponseOK();
-}
+handleRequestResponse(res);
 }
 } catch (Exception e) {
 LOGGER.warn(e.getLocalizedMessage(), e);
-if (thrown != null){
+if (thrown != null) {
 res.setResponseMessage(thrown.toString());
-} else {
+} else {
 res.setResponseMessage(e.getLocalizedMessage());
 }
 }
 res.sampleEnd();
 return res;
 }
 
+private void handleBrowse(SampleResult res) throws JMSException {
+LOGGER.debug("isBrowseOnly");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Browse message on Send Queue " + 
sendQueue.getQueueName());
+sb.append(browseQueueDetails(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleClearQueue(SampleResult res) throws JMSException {
+LOGGER.debug("isClearQueue");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Clear messages on Send Queue " + 
sendQueue.getQueueName());
+sb.append(clearQueue(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleOneWay(SampleResult res) throws JMSException {
+LOGGER.debug("isOneWay");
+TextMessage msg = createMessage();
+int deliveryMode = isNonPersistent() ? DeliveryMode.NON_PERSISTENT 
: DeliveryMode.PERSISTENT;
+producer.send(msg, deliveryMode, Integer.parseInt(getPriority()), 
Long.parseLong(getExpiration()));
+res.setRequestHeaders(Utils.messageProperties(msg));
+res.setResponseOK();
+res.setResponseData("Oneway request has no response data", null);
+}
+
+private void handleRead(JMeterContext context, SampleResult res) {
+LOGGER.debug("isRead");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+Sampler sampler = context.getPreviousSampler();
+SampleResult sr = context.getPreviousResult();
+String jmsSelector = getJMSSelector();
+if (jmsSelector.equals("_PREV_SAMPLER_")) {
+if (sampler instanceof JMSSampler) {
+

[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150328360
  
--- Diff: 
src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java ---
@@ -142,48 +173,244 @@ public SampleResult sample(Entry entry) {
 res.sampleStart();
 
 try {
-TextMessage msg = createMessage();
-if (isOneway()) {
-int deliveryMode = isNonPersistent() ? 
-
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
-producer.send(msg, deliveryMode, 
Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-res.setResponseOK();
-res.setResponseData("Oneway request has no response data", 
null);
+LOGGER.debug("Point-to-point mode: " + 
getCommunicationstyle());
+if (isBrowse()) {
+handleBrowse(res);
+} else if (isClearQueue()) {
+handleClearQueue(res);
+} else if (isOneway()) {
+handleOneWay(res);
+} else if (isRead()) {
+handleRead(context, res);
 } else {
-if (!useTemporyQueue()) {
-msg.setJMSReplyTo(receiveQueue);
-}
-Message replyMsg = executor.sendAndReceive(msg,
-isNonPersistent() ? DeliveryMode.NON_PERSISTENT : 
DeliveryMode.PERSISTENT, 
-Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-if (replyMsg == null) {
-res.setResponseMessage("No reply message received");
-} else {
-if (replyMsg instanceof TextMessage) {
-res.setResponseData(((TextMessage) 
replyMsg).getText(), null);
-} else {
-res.setResponseData(replyMsg.toString(), null);
-}
-
res.setResponseHeaders(Utils.messageProperties(replyMsg));
-res.setResponseOK();
-}
+handleRequestResponse(res);
 }
 } catch (Exception e) {
 LOGGER.warn(e.getLocalizedMessage(), e);
-if (thrown != null){
+if (thrown != null) {
 res.setResponseMessage(thrown.toString());
-} else {
+} else {
 res.setResponseMessage(e.getLocalizedMessage());
 }
 }
 res.sampleEnd();
 return res;
 }
 
+private void handleBrowse(SampleResult res) throws JMSException {
+LOGGER.debug("isBrowseOnly");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Browse message on Send Queue " + 
sendQueue.getQueueName());
+sb.append(browseQueueDetails(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleClearQueue(SampleResult res) throws JMSException {
+LOGGER.debug("isClearQueue");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Clear messages on Send Queue " + 
sendQueue.getQueueName());
+sb.append(clearQueue(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleOneWay(SampleResult res) throws JMSException {
+LOGGER.debug("isOneWay");
+TextMessage msg = createMessage();
+int deliveryMode = isNonPersistent() ? DeliveryMode.NON_PERSISTENT 
: DeliveryMode.PERSISTENT;
+producer.send(msg, deliveryMode, Integer.parseInt(getPriority()), 
Long.parseLong(getExpiration()));
+res.setRequestHeaders(Utils.messageProperties(msg));
+res.setResponseOK();
+res.setResponseData("Oneway request has no response data", null);
+}
+
+private void handleRead(JMeterContext context, SampleResult res) {
+LOGGER.debug("isRead");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+Sampler sampler = context.getPreviousSampler();
+SampleResult sr = context.getPreviousResult();
+String jmsSelector = getJMSSelector();
+if (jmsSelector.equals("_PREV_SAMPLER_")) {
+if (sampler instanceof JMSSampler) {
+

[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150327021
  
--- Diff: docs/usermanual/component_reference.html ---
@@ -3813,7 +3813,7 @@ 
   
--- End diff --

HTML files are generated from XML. Could you update comonent_reference.xml 
instead ?


---


[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread pmouawad
Github user pmouawad commented on a diff in the pull request:

https://github.com/apache/jmeter/pull/325#discussion_r150328109
  
--- Diff: 
src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/JMSSampler.java ---
@@ -142,48 +173,244 @@ public SampleResult sample(Entry entry) {
 res.sampleStart();
 
 try {
-TextMessage msg = createMessage();
-if (isOneway()) {
-int deliveryMode = isNonPersistent() ? 
-
DeliveryMode.NON_PERSISTENT:DeliveryMode.PERSISTENT;
-producer.send(msg, deliveryMode, 
Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-res.setResponseOK();
-res.setResponseData("Oneway request has no response data", 
null);
+LOGGER.debug("Point-to-point mode: " + 
getCommunicationstyle());
+if (isBrowse()) {
+handleBrowse(res);
+} else if (isClearQueue()) {
+handleClearQueue(res);
+} else if (isOneway()) {
+handleOneWay(res);
+} else if (isRead()) {
+handleRead(context, res);
 } else {
-if (!useTemporyQueue()) {
-msg.setJMSReplyTo(receiveQueue);
-}
-Message replyMsg = executor.sendAndReceive(msg,
-isNonPersistent() ? DeliveryMode.NON_PERSISTENT : 
DeliveryMode.PERSISTENT, 
-Integer.parseInt(getPriority()), 
-Long.parseLong(getExpiration()));
-res.setRequestHeaders(Utils.messageProperties(msg));
-if (replyMsg == null) {
-res.setResponseMessage("No reply message received");
-} else {
-if (replyMsg instanceof TextMessage) {
-res.setResponseData(((TextMessage) 
replyMsg).getText(), null);
-} else {
-res.setResponseData(replyMsg.toString(), null);
-}
-
res.setResponseHeaders(Utils.messageProperties(replyMsg));
-res.setResponseOK();
-}
+handleRequestResponse(res);
 }
 } catch (Exception e) {
 LOGGER.warn(e.getLocalizedMessage(), e);
-if (thrown != null){
+if (thrown != null) {
 res.setResponseMessage(thrown.toString());
-} else {
+} else {
 res.setResponseMessage(e.getLocalizedMessage());
 }
 }
 res.sampleEnd();
 return res;
 }
 
+private void handleBrowse(SampleResult res) throws JMSException {
+LOGGER.debug("isBrowseOnly");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Browse message on Send Queue " + 
sendQueue.getQueueName());
+sb.append(browseQueueDetails(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleClearQueue(SampleResult res) throws JMSException {
+LOGGER.debug("isClearQueue");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+sb.append("\n \n  Clear messages on Send Queue " + 
sendQueue.getQueueName());
+sb.append(clearQueue(sendQueue, res));
+res.setResponseData(sb.toString().getBytes());
+}
+
+private void handleOneWay(SampleResult res) throws JMSException {
+LOGGER.debug("isOneWay");
+TextMessage msg = createMessage();
+int deliveryMode = isNonPersistent() ? DeliveryMode.NON_PERSISTENT 
: DeliveryMode.PERSISTENT;
+producer.send(msg, deliveryMode, Integer.parseInt(getPriority()), 
Long.parseLong(getExpiration()));
+res.setRequestHeaders(Utils.messageProperties(msg));
+res.setResponseOK();
+res.setResponseData("Oneway request has no response data", null);
+}
+
+private void handleRead(JMeterContext context, SampleResult res) {
+LOGGER.debug("isRead");
+StringBuffer sb = new StringBuffer("");
+res.setSuccessful(true);
+Sampler sampler = context.getPreviousSampler();
+SampleResult sr = context.getPreviousResult();
+String jmsSelector = getJMSSelector();
+if (jmsSelector.equals("_PREV_SAMPLER_")) {
+if (sampler instanceof JMSSampler) {
+

[GitHub] jmeter pull request #325: 61544 - Added read, browse and clear as communicat...

2017-11-10 Thread bennyvw
GitHub user bennyvw opened a pull request:

https://github.com/apache/jmeter/pull/325

61544 - Added read, browse and clear as communication styles to JMSSampler

## Description
In JMS Point-to-Point Sampler, besides the standard options for 
communication style, Request Only and Request Response, we added options to 
Read a message, Clear the queue (purge all messages) and Browse the queue 
(count number of messages on the queue).
The property  JMSSampler.connectionmode is replaced by an 
 JMSSampler.communicationstyle. This way, multiple languages for the 
options are supported.

## Motivation and Context
It does not solve a problem, but adds some functionality.

## How Has This Been Tested?
This change is NOT backwards compatible in that it will not find the 
intProp communicationStyle in existing scripts, thus resetting them to 'Clear' 
option. Hmm, typing this I realize that 'Request Only' might have been the 
better default option to save existing functionality where possible.

## Screenshots (if appropriate):

## Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [X] Breaking change (fix or feature that would cause existing 
functionality to not work as expected)

## Checklist:
- [X] My code follows the code style of this project.
- [X] My change requires a change to the documentation.
- [X] I have updated the documentation accordingly.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/bennyvw/jmeter 61544

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jmeter/pull/325.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #325


commit 12a68e3777be4df9b588a2c47994ad059ffe1aa7
Author: DELL_WORK\manfred 
Date:   2017-09-20T09:33:28Z

Added jms communication styles (read, browse and clear).

commit 9e6cc05f0a96d8c34de0f53a5a6b78047637cd71
Author: DELL_WORK\manfred 
Date:   2017-10-31T11:23:20Z

Updated documentation with Read, Browse, Clear actions for the JMSSampler.
Renamed connectionMode to communicationStyle.

commit 60c96bffc3dde7aeca669efa09fde6c2325a5486
Author: Manfred M. Schürhoff 
Date:   2017-11-07T17:52:04Z

Fixed compilation issues (removed unused packages).

commit 539b7adf33efba15d936122b2cb56c48997edfd5
Author: Benny van Wijngaarden 
Date:   2017-11-09T15:31:45Z

Changed formatting for the sake of checkstyle




---